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

Convert to the new Boston data source. #12

Open
wants to merge 2 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
13 changes: 8 additions & 5 deletions 02_fundamentals/Code.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"metadata": {},
"outputs": [],
"source": [
"from sklearn.datasets import load_boston"
"import pandas as pd"
]
},
{
Expand All @@ -56,7 +56,9 @@
"metadata": {},
"outputs": [],
"source": [
"boston = load_boston()"
"# New source for Boston housing data per https://scikit-learn.org/1.0/whats_new/v1.0.html#changes-1-0\n",
"data_url = \"http://lib.stat.cmu.edu/datasets/boston\"\n",
"raw_df = pd.read_csv(data_url, sep=\"\\s+\", skiprows=22, header=None)"
]
},
{
Expand All @@ -65,9 +67,10 @@
"metadata": {},
"outputs": [],
"source": [
"data = boston.data\n",
"target = boston.target\n",
"features = boston.feature_names"
"data = np.hstack([raw_df.values[::2, :], raw_df.values[1::2, :2]])\n",
"target = raw_df.values[1::2, 2]\n",
"features = np.array(['CRIM', 'ZN', 'INDUS', 'CHAS', 'NOX', 'RM', 'AGE', 'DIS',\n",
" 'RAD', 'TAX', 'PTRATIO', 'B', 'LSTAT'])"
]
},
{
Expand Down
11 changes: 6 additions & 5 deletions 03_dlfs/Code.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -820,12 +820,13 @@
"metadata": {},
"outputs": [],
"source": [
"from sklearn.datasets import load_boston\n",
"import pandas as pd\n",
"data_url = \"http://lib.stat.cmu.edu/datasets/boston\"\n",
"raw_df = pd.read_csv(data_url, sep=\"\\s+\", skiprows=22, header=None)\n",
"\n",
"boston = load_boston()\n",
"data = boston.data\n",
"target = boston.target\n",
"features = boston.feature_names"
"data = np.hstack([raw_df.values[::2, :], raw_df.values[1::2, :2]])\n",
"target = raw_df.values[1::2, 2]\n",
"features = np.array(['CRIM', 'ZN', 'INDUS', 'CHAS', 'NOX', 'RM', 'AGE', 'DIS', 'RAD', 'TAX', 'PTRATIO', 'B', 'LSTAT'])"
]
},
{
Expand Down
12 changes: 6 additions & 6 deletions 07_PyTorch/Code.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@
"metadata": {},
"outputs": [],
"source": [
"from sklearn.datasets import load_boston\n",
"\n",
"boston = load_boston()\n",
"import pandas as pd\n",
"data_url = \"http://lib.stat.cmu.edu/datasets/boston\"\n",
"raw_df = pd.read_csv(data_url, sep=\"\\s+\", skiprows=22, header=None)\n",
"\n",
"data = boston.data\n",
"target = boston.target\n",
"features = boston.feature_names\n",
"data = np.hstack([raw_df.values[::2, :], raw_df.values[1::2, :2]])\n",
"target = raw_df.values[1::2, 2]\n",
"features = np.array(['CRIM', 'ZN', 'INDUS', 'CHAS', 'NOX', 'RM', 'AGE', 'DIS', 'RAD', 'TAX', 'PTRATIO', 'B', 'LSTAT'])\n",
"\n",
"from sklearn.preprocessing import StandardScaler\n",
"s = StandardScaler()\n",
Expand Down