Sync notebook 04 with book code
parent
bac934811a
commit
77da622124
|
@ -205,6 +205,8 @@
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
|
"import matplotlib.pyplot as plt\n",
|
||||||
|
"\n",
|
||||||
"plt.figure(figsize=(6, 4)) # not in the book\n",
|
"plt.figure(figsize=(6, 4)) # not in the book\n",
|
||||||
"plt.plot(X_new, y_predict, \"r-\", label=\"Predictions\")\n",
|
"plt.plot(X_new, y_predict, \"r-\", label=\"Predictions\")\n",
|
||||||
"plt.plot(X, y, \"b.\")\n",
|
"plt.plot(X, y, \"b.\")\n",
|
||||||
|
@ -1052,14 +1054,14 @@
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
|
"# not in the book\n",
|
||||||
|
"\n",
|
||||||
"np.random.seed(42)\n",
|
"np.random.seed(42)\n",
|
||||||
"m = 100\n",
|
"m = 100\n",
|
||||||
"X = 6 * np.random.rand(m, 1) - 3\n",
|
"X = 6 * np.random.rand(m, 1) - 3\n",
|
||||||
"y = 0.5 * X ** 2 + X + 2 + np.random.randn(m, 1)\n",
|
"y = 0.5 * X ** 2 + X + 2 + np.random.randn(m, 1)\n",
|
||||||
"# X_train, X_val, y_train, y_val = train_test_split(\n",
|
"X_train, y_train = X[: m // 2], y[: m // 2, 0]\n",
|
||||||
"# X[:50], y[:50].ravel(), test_size=0.5, random_state=10)\n",
|
"X_valid, y_valid = X[m // 2 :], y[m // 2 :, 0]"
|
||||||
"X_train, y_train = X[:50], y[:50, 0]\n",
|
|
||||||
"X_valid, y_valid = X[50:], y[50:, 0]"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1070,6 +1072,7 @@
|
||||||
"source": [
|
"source": [
|
||||||
"from copy import deepcopy\n",
|
"from copy import deepcopy\n",
|
||||||
"from sklearn.metrics import mean_squared_error\n",
|
"from sklearn.metrics import mean_squared_error\n",
|
||||||
|
"from sklearn.preprocessing import StandardScaler\n",
|
||||||
"\n",
|
"\n",
|
||||||
"preprocessing = make_pipeline(PolynomialFeatures(degree=90, include_bias=False),\n",
|
"preprocessing = make_pipeline(PolynomialFeatures(degree=90, include_bias=False),\n",
|
||||||
" StandardScaler())\n",
|
" StandardScaler())\n",
|
||||||
|
@ -1192,7 +1195,7 @@
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"print(iris.data.head())"
|
"iris.data.head(3)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1201,7 +1204,7 @@
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"iris.target.head() # note that the instances are not shuffled"
|
"iris.target.head(3) # note that the instances are not shuffled"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue