mirror of
https://github.com/ArthurDanjou/ml_exercises.git
synced 2026-01-14 04:04:28 +01:00
add pandas output transform to scaler
This commit is contained in:
@@ -778,8 +778,8 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# scale the data\n",
|
||||
"scaler = StandardScaler()\n",
|
||||
"# scale the data (but make sure it stays a pandas dataframe)\n",
|
||||
"scaler = StandardScaler().set_output(transform=\"pandas\")\n",
|
||||
"# training data: fit & transform \n",
|
||||
"# (fit: compute mean and std of each feature; transform: subtract mean from each feature and divide by std)\n",
|
||||
"X_train = scaler.fit_transform(X_train)\n",
|
||||
@@ -836,7 +836,7 @@
|
||||
"y = df_new[\"faulty\"]\n",
|
||||
"X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33, random_state=15)\n",
|
||||
"# and don't forget to scale the data again!\n",
|
||||
"scaler = StandardScaler()\n",
|
||||
"scaler = StandardScaler().set_output(transform=\"pandas\")\n",
|
||||
"X_train = scaler.fit_transform(X_train)\n",
|
||||
"X_test = scaler.transform(X_test)\n",
|
||||
"# train the model again with most of the default parameter setting\n",
|
||||
|
||||
Reference in New Issue
Block a user