Skip to content

Commit

Permalink
Jupyter file
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterLegend committed Nov 5, 2021
1 parent 2f7e6ca commit 9580990
Show file tree
Hide file tree
Showing 12 changed files with 18,086 additions and 0 deletions.
845 changes: 845 additions & 0 deletions 1. Python简介.ipynb

Large diffs are not rendered by default.

1,373 changes: 1,373 additions & 0 deletions 2. Python的基本使用.ipynb

Large diffs are not rendered by default.

2,400 changes: 2,400 additions & 0 deletions 3. Python文件读写,库.ipynb

Large diffs are not rendered by default.

684 changes: 684 additions & 0 deletions 4. 机器学习简介.ipynb

Large diffs are not rendered by default.

177 changes: 177 additions & 0 deletions 5.1 机器学习算法.ipynb

Large diffs are not rendered by default.

509 changes: 509 additions & 0 deletions 5.2 吸附中的线性回归.ipynb

Large diffs are not rendered by default.

191 changes: 191 additions & 0 deletions 5.3 非线性回归.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "ada63d23",
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "c3f95fe9",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>0</th>\n",
" <th>1</th>\n",
" <th>2</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>3.000000e-10</td>\n",
" <td>2.270000e-12</td>\n",
" <td>2.240000e-12</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>3.000000e-10</td>\n",
" <td>2.060000e-12</td>\n",
" <td>1.900000e-12</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>3.000000e-10</td>\n",
" <td>2.790000e-12</td>\n",
" <td>1.560000e-12</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>2.990000e-10</td>\n",
" <td>2.600000e-12</td>\n",
" <td>1.930000e-12</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>2.990000e-10</td>\n",
" <td>1.740000e-12</td>\n",
" <td>9.890000e-13</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" 0 1 2\n",
"0 3.000000e-10 2.270000e-12 2.240000e-12\n",
"1 3.000000e-10 2.060000e-12 1.900000e-12\n",
"2 3.000000e-10 2.790000e-12 1.560000e-12\n",
"3 2.990000e-10 2.600000e-12 1.930000e-12\n",
"4 2.990000e-10 1.740000e-12 9.890000e-13"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"with open('iz.csv', mode = 'r', encoding = 'UTF-8') as f:\n",
" df = pd.read_csv(f, header = None)\n",
"df.head()"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "00c012a6",
"metadata": {},
"outputs": [],
"source": [
"df[3] = 0.5 * (df[1] + df[2])\n",
"z = np.array(df[0]) * 1e10\n",
"current = np.array(df[3]) * 1e12"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "fcd90eab",
"metadata": {},
"outputs": [],
"source": [
"from sklearn.linear_model import LinearRegression\n",
"from scipy.optimize import curve_fit"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "922886ba",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[[ 3.60225002e+00 -2.56599244e-03]\n",
" [-2.56599244e-03 1.89800824e-06]]\n",
"4.306461770837465 3.919756213516532\n"
]
}
],
"source": [
"def func(x, a, b):\n",
" return a * np.exp(b*x)\n",
"\n",
"def cal_wf_lin(z, current):\n",
" lr = LinearRegression()\n",
" lr.fit(z.reshape(-1, 1), np.log(current))\n",
" wf = 0.952 * pow(lr.coef_[0], 2)\n",
" return wf\n",
"\n",
"def cal_wf(z, current):\n",
" pfit, pcov = curve_fit(func, z, current)\n",
" print(pcov)\n",
" wf = 0.952 * pow(pfit[1], 2)\n",
" return wf\n",
"\n",
"res1 = cal_wf_lin(z, current)\n",
"res2 = cal_wf(z, current)\n",
"print(res1, res2)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e8d4bea2",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.8"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading

0 comments on commit 9580990

Please sign in to comment.