Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

新建jupyter notebook #23

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
113 changes: 113 additions & 0 deletions sicp/Exercises/1.1.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"# 引言"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": []
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"预测2023年全国高考录取率为: 45.64666666666653\n",
"预测2023年湖北省本科录取率为: 45.64666666666653\n",
"预测2023年湖北省一本录取率为: 16.953333333333333\n",
"预测2023年湖北省211录取率为: 5.280000000000001\n",
"预测2023年湖北省985录取率为: 2.153333333333336\n",
"预测2023年湖北省本科录取人数为: 219103.99999999936\n",
"预测2023年湖北省一本录取人数为: 81376.0\n",
"预测2023年湖北省211录取人数为: 25344.000000000004\n",
"预测2023年湖北省985录取人数为: 10336.000000000013\n"
]
}
],
"source": [
"import pandas as pd\n",
"from sklearn.linear_model import LinearRegression\n",
"\n",
"# 假设您已经获得了2020-2022年的湖北高考录取率数据,存储在一个Pandas DataFrame中\n",
"data = {'年份': [2020, 2021, 2022],\n",
" '本科录取率': [42.1, 45.14, 44],\n",
" '一本录取率': [15.8, 18.9, 15.89],\n",
" '211录取率': [5.2, 5.6, 5.16],\n",
" '985录取率': [2.1, 2.1, 2.14]}\n",
"df = pd.DataFrame(data)\n",
"\n",
"# 使用线性回归模型拟合数据\n",
"X = df[['年份']]\n",
"y1 = df['本科录取率']\n",
"y2 = df['一本录取率']\n",
"y3 = df['211录取率']\n",
"y4 = df['985录取率']\n",
"model1 = LinearRegression().fit(X, y1)\n",
"model2 = LinearRegression().fit(X, y2)\n",
"model3 = LinearRegression().fit(X, y3)\n",
"model4 = LinearRegression().fit(X, y4)\n",
"\n",
"# 预测2023年的录取率\n",
"this_year = pd.DataFrame({'年份': [2023]})\n",
"predicted_本科录取率 = model1.predict(this_year)[0]\n",
"predicted_一本录取率 = model2.predict(this_year)[0]\n",
"predicted_211录取率 = model3.predict(this_year)[0]\n",
"predicted_985录取率 = model4.predict(this_year)[0]\n",
"\n",
"# 计算全国录取率\n",
"全国高考报名人数 = 12910000\n",
"湖北高考人数 = 480000\n",
"全国录取人数 = 全国高考报名人数 * predicted_本科录取率 / 100\n",
"湖北本科录取人数 = 湖北高考人数 * predicted_本科录取率 / 100\n",
"湖北一本录取人数 = 湖北高考人数 * predicted_一本录取率 / 100\n",
"湖北211录取人数 = 湖北高考人数 * predicted_211录取率 / 100\n",
"湖北985录取人数 = 湖北高考人数 * predicted_985录取率 / 100\n",
"全国录取率 = 全国录取人数 / 全国高考报名人数 * 100\n",
"\n",
"# 输出结果\n",
"print('预测2023年全国高考录取率为:', 全国录取率)\n",
"print('预测2023年湖北省本科录取率为:', predicted_本科录取率)\n",
"print('预测2023年湖北省一本录取率为:', predicted_一本录取率)\n",
"print('预测2023年湖北省211录取率为:', predicted_211录取率)\n",
"print('预测2023年湖北省985录取率为:', predicted_985录取率)\n",
"print('预测2023年湖北省本科录取人数为:', 湖北本科录取人数)\n",
"print('预测2023年湖北省一本录取人数为:', 湖北一本录取人数)\n",
"print('预测2023年湖北省211录取人数为:', 湖北211录取人数)\n",
"print('预测2023年湖北省985录取人数为:', 湖北985录取人数)"
]
}
],
"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.10.8"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.