mirror of
https://github.com/ArthurDanjou/handson-ml3.git
synced 2026-01-14 12:14:36 +01:00
Remove redundant code examples
This commit is contained in:
@@ -750,57 +750,6 @@
|
||||
"plt.show()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 37,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"backup = oecd_bli, gdp_per_capita\n",
|
||||
"\n",
|
||||
"def prepare_country_stats(oecd_bli, gdp_per_capita):\n",
|
||||
" return sample_data"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 38,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Replace this linear model:\n",
|
||||
"import sklearn.linear_model\n",
|
||||
"model = sklearn.linear_model.LinearRegression()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 39,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# with this k-neighbors regression model:\n",
|
||||
"import sklearn.neighbors\n",
|
||||
"model = sklearn.neighbors.KNeighborsRegressor(n_neighbors=3)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 40,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"X = np.c_[country_stats[\"GDP per capita\"]]\n",
|
||||
"y = np.c_[country_stats[\"Life satisfaction\"]]\n",
|
||||
"\n",
|
||||
"# Train the model\n",
|
||||
"model.fit(X, y)\n",
|
||||
"\n",
|
||||
"# Make a prediction for Cyprus\n",
|
||||
"X_new = np.array([[22587.0]]) # Cyprus' GDP per capita\n",
|
||||
"print(model.predict(X_new)) # outputs [[ 5.76666667]]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
|
||||
Reference in New Issue
Block a user