Merge pull request #6 from vi3itor/ch2-errata
Fix a few typos and deprecated np.object referencemain
commit
ec67af216b
|
@ -11,7 +11,7 @@
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
"*This notebook contains all the sample code and solutions to the exercices in chapter 2.*"
|
"*This notebook contains all the sample code and solutions to the exercises in chapter 2.*"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -3747,7 +3747,7 @@
|
||||||
"\n",
|
"\n",
|
||||||
"preprocessing = make_column_transformer(\n",
|
"preprocessing = make_column_transformer(\n",
|
||||||
" (num_pipeline, make_column_selector(dtype_include=np.number)),\n",
|
" (num_pipeline, make_column_selector(dtype_include=np.number)),\n",
|
||||||
" (cat_pipeline, make_column_selector(dtype_include=np.object)),\n",
|
" (cat_pipeline, make_column_selector(dtype_include=object)),\n",
|
||||||
")"
|
")"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -3918,7 +3918,7 @@
|
||||||
" (\"log\", log_pipeline, [\"total_bedrooms\", \"total_rooms\",\n",
|
" (\"log\", log_pipeline, [\"total_bedrooms\", \"total_rooms\",\n",
|
||||||
" \"population\", \"households\", \"median_income\"]),\n",
|
" \"population\", \"households\", \"median_income\"]),\n",
|
||||||
" (\"geo\", cluster_simil, [\"latitude\", \"longitude\"]),\n",
|
" (\"geo\", cluster_simil, [\"latitude\", \"longitude\"]),\n",
|
||||||
" (\"cat\", cat_pipeline, make_column_selector(dtype_include=np.object)),\n",
|
" (\"cat\", cat_pipeline, make_column_selector(dtype_include=object)),\n",
|
||||||
" ],\n",
|
" ],\n",
|
||||||
" remainder=default_num_pipeline) # one column remaining: housing_median_age"
|
" remainder=default_num_pipeline) # one column remaining: housing_median_age"
|
||||||
]
|
]
|
||||||
|
@ -4381,7 +4381,7 @@
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
"**Warning:** the following cell make take a few minutes to run:"
|
"**Warning:** the following cell may take a few minutes to run:"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -4660,7 +4660,7 @@
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
"**Warning:** the following cell make take a few minutes to run:"
|
"**Warning:** the following cell may take a few minutes to run:"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -5214,7 +5214,7 @@
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
"Alternatively, we could use a z-scores rather than t-scores—since the test set is not too small, it won't make a big difference:"
|
"Alternatively, we could use a z-score rather than a t-score. Since the test set is not too small, it won't make a big difference:"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -5234,7 +5234,7 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"source": [
|
"source": [
|
||||||
"# extra code – computes a confidence interval again using z-score\n",
|
"# extra code – computes a confidence interval again using a z-score\n",
|
||||||
"zscore = stats.norm.ppf((1 + confidence) / 2)\n",
|
"zscore = stats.norm.ppf((1 + confidence) / 2)\n",
|
||||||
"zmargin = zscore * squared_errors.std(ddof=1) / np.sqrt(m)\n",
|
"zmargin = zscore * squared_errors.std(ddof=1) / np.sqrt(m)\n",
|
||||||
"np.sqrt(mean - zmargin), np.sqrt(mean + zmargin)"
|
"np.sqrt(mean - zmargin), np.sqrt(mean + zmargin)"
|
||||||
|
@ -5746,7 +5746,7 @@
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
"Rather than restrict ourselves to k-Nearest Neighbors regressors, let's create a transform that accepts any regressor. For this, we can extend the `MetaEstimatorMixin` and have a required `estimator` argument in the constructor. The `fit()` method must work on a clone of this estimator, and it must also save `feature_names_in_`. The `MetaEstimatorMixin` will ensure that `estimator` is listed as a required parameters, and it will update `get_params()` and `set_params()` to make the estimator's hyperparameters available for tuning. Lastly, we create a `get_feature_names_out()` method: the output column name is the "
|
"Rather than restrict ourselves to k-Nearest Neighbors regressors, let's create a transformer that accepts any regressor. For this, we can extend the `MetaEstimatorMixin` and have a required `estimator` argument in the constructor. The `fit()` method must work on a clone of this estimator, and it must also save `feature_names_in_`. The `MetaEstimatorMixin` will ensure that `estimator` is listed as a required parameters, and it will update `get_params()` and `set_params()` to make the estimator's hyperparameters available for tuning. Lastly, we create a `get_feature_names_out()` method: the output column name is the ..."
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -6070,7 +6070,7 @@
|
||||||
" self.scale_ = X.std(axis=0)\n",
|
" self.scale_ = X.std(axis=0)\n",
|
||||||
" self.n_features_in_ = X.shape[1] # every estimator stores this in fit()\n",
|
" self.n_features_in_ = X.shape[1] # every estimator stores this in fit()\n",
|
||||||
" if hasattr(X_orig, \"columns\"):\n",
|
" if hasattr(X_orig, \"columns\"):\n",
|
||||||
" self.feature_names_in_ = np.array(X_orig.columns, dtype=np.object)\n",
|
" self.feature_names_in_ = np.array(X_orig.columns, dtype=object)\n",
|
||||||
" return self # always return self!\n",
|
" return self # always return self!\n",
|
||||||
"\n",
|
"\n",
|
||||||
" def transform(self, X):\n",
|
" def transform(self, X):\n",
|
||||||
|
@ -6133,7 +6133,7 @@
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
"Now let's ensure we the transformation works as expected:"
|
"Now let's ensure the transformation works as expected:"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue