Skip to content

Commit

Permalink
fix get_dummies dtype + log reg output
Browse files Browse the repository at this point in the history
  • Loading branch information
anhquan0412 committed Feb 19, 2024
1 parent bcacc4e commit bef1b6e
Show file tree
Hide file tree
Showing 7 changed files with 601 additions and 492 deletions.
784 changes: 427 additions & 357 deletions nbs/00_end_to_end_example.ipynb

Large diffs are not rendered by default.

214 changes: 107 additions & 107 deletions nbs/01_data_preprocess.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -803,9 +803,9 @@
" else:\n",
" X_total = X_train.copy()\n",
" if len(cat_cols):\n",
" X_total = pd.get_dummies(X_total,columns=cat_cols,drop_first=False)\n",
" X_total = pd.get_dummies(X_total,columns=cat_cols,drop_first=False,dtype=float)\n",
" if len(bi_cols):\n",
" X_total = pd.get_dummies(X_total,columns=bi_cols,drop_first=True)\n",
" X_total = pd.get_dummies(X_total,columns=bi_cols,drop_first=True,dtype=float)\n",
" return X_total if X_test is None else (X_total.iloc[:n_train].copy(), X_total.iloc[n_train:].copy())"
]
},
Expand Down Expand Up @@ -976,36 +976,36 @@
" <tr>\n",
" <th>0</th>\n",
" <td>1</td>\n",
" <td>False</td>\n",
" <td>True</td>\n",
" <td>False</td>\n",
" <td>False</td>\n",
" <td>0.0</td>\n",
" <td>1.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>2</td>\n",
" <td>True</td>\n",
" <td>False</td>\n",
" <td>False</td>\n",
" <td>True</td>\n",
" <td>1.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>1.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>3</td>\n",
" <td>False</td>\n",
" <td>False</td>\n",
" <td>True</td>\n",
" <td>False</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>1.0</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" C B_a B_b B_c A_b\n",
"0 1 False True False False\n",
"1 2 True False False True\n",
"2 3 False False True False"
" C B_a B_b B_c A_b\n",
"0 1 0.0 1.0 0.0 0.0\n",
"1 2 1.0 0.0 0.0 1.0\n",
"2 3 0.0 0.0 1.0 0.0"
]
},
"metadata": {},
Expand Down Expand Up @@ -1192,51 +1192,51 @@
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>100</th>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <th>84</th>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>female</td>\n",
" <td>28.0</td>\n",
" <td>17.0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>S</td>\n",
" </tr>\n",
" <tr>\n",
" <th>122</th>\n",
" <th>4</th>\n",
" <td>0</td>\n",
" <td>2</td>\n",
" <td>3</td>\n",
" <td>male</td>\n",
" <td>32.5</td>\n",
" <td>1</td>\n",
" <td>35.0</td>\n",
" <td>0</td>\n",
" <td>C</td>\n",
" </tr>\n",
" <tr>\n",
" <th>43</th>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>female</td>\n",
" <td>3.0</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>C</td>\n",
" <td>0</td>\n",
" <td>S</td>\n",
" </tr>\n",
" <tr>\n",
" <th>113</th>\n",
" <th>101</th>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>female</td>\n",
" <td>20.0</td>\n",
" <td>1</td>\n",
" <td>male</td>\n",
" <td>NaN</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>S</td>\n",
" </tr>\n",
" <tr>\n",
" <th>87</th>\n",
" <th>48</th>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>male</td>\n",
" <td>NaN</td>\n",
" <td>2</td>\n",
" <td>0</td>\n",
" <td>C</td>\n",
" </tr>\n",
" <tr>\n",
" <th>112</th>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>male</td>\n",
" <td>22.0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>S</td>\n",
Expand All @@ -1247,11 +1247,11 @@
],
"text/plain": [
" Survived Pclass Sex Age SibSp Parch Embarked\n",
"100 0 3 female 28.0 0 0 S\n",
"122 0 2 male 32.5 1 0 C\n",
"43 1 2 female 3.0 1 2 C\n",
"113 0 3 female 20.0 1 0 S\n",
"87 0 3 male NaN 0 0 S"
"84 1 2 female 17.0 0 0 S\n",
"4 0 3 male 35.0 0 0 S\n",
"101 0 3 male NaN 0 0 S\n",
"48 0 3 male NaN 2 0 C\n",
"112 0 3 male 22.0 0 0 S"
]
},
"execution_count": null,
Expand Down Expand Up @@ -1562,73 +1562,73 @@
" <td>-0.325526</td>\n",
" <td>0.2</td>\n",
" <td>0.0</td>\n",
" <td>False</td>\n",
" <td>False</td>\n",
" <td>True</td>\n",
" <td>False</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>1.0</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>134</th>\n",
" <td>2</td>\n",
" <td>-0.252796</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>False</td>\n",
" <td>False</td>\n",
" <td>True</td>\n",
" <td>True</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>1.0</td>\n",
" <td>1.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>120</th>\n",
" <td>2</td>\n",
" <td>-0.543716</td>\n",
" <td>0.4</td>\n",
" <td>0.0</td>\n",
" <td>False</td>\n",
" <td>False</td>\n",
" <td>True</td>\n",
" <td>True</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>1.0</td>\n",
" <td>1.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>50</th>\n",
" <td>3</td>\n",
" <td>-1.561938</td>\n",
" <td>0.8</td>\n",
" <td>0.2</td>\n",
" <td>False</td>\n",
" <td>False</td>\n",
" <td>True</td>\n",
" <td>True</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>1.0</td>\n",
" <td>1.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>133</th>\n",
" <td>2</td>\n",
" <td>0.038125</td>\n",
" <td>0.2</td>\n",
" <td>0.0</td>\n",
" <td>False</td>\n",
" <td>False</td>\n",
" <td>True</td>\n",
" <td>False</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>1.0</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Pclass Age SibSp Parch Embarked_C Embarked_Q Embarked_S \n",
"142 3 -0.325526 0.2 0.0 False False True \\\n",
"134 2 -0.252796 0.0 0.0 False False True \n",
"120 2 -0.543716 0.4 0.0 False False True \n",
"50 3 -1.561938 0.8 0.2 False False True \n",
"133 2 0.038125 0.2 0.0 False False True \n",
"142 3 -0.325526 0.2 0.0 0.0 0.0 1.0 \\\n",
"134 2 -0.252796 0.0 0.0 0.0 0.0 1.0 \n",
"120 2 -0.543716 0.4 0.0 0.0 0.0 1.0 \n",
"50 3 -1.561938 0.8 0.2 0.0 0.0 1.0 \n",
"133 2 0.038125 0.2 0.0 0.0 0.0 1.0 \n",
"\n",
" Sex_male \n",
"142 False \n",
"134 True \n",
"120 True \n",
"50 True \n",
"133 False "
"142 0.0 \n",
"134 1.0 \n",
"120 1.0 \n",
"50 1.0 \n",
"133 0.0 "
]
},
"execution_count": null,
Expand Down Expand Up @@ -1683,73 +1683,73 @@
" <td>-0.616446</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>False</td>\n",
" <td>False</td>\n",
" <td>True</td>\n",
" <td>True</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>1.0</td>\n",
" <td>1.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>145</th>\n",
" <td>2</td>\n",
" <td>-0.689176</td>\n",
" <td>0.2</td>\n",
" <td>0.2</td>\n",
" <td>False</td>\n",
" <td>False</td>\n",
" <td>True</td>\n",
" <td>True</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>1.0</td>\n",
" <td>1.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>115</th>\n",
" <td>3</td>\n",
" <td>-0.543716</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>False</td>\n",
" <td>False</td>\n",
" <td>True</td>\n",
" <td>True</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>1.0</td>\n",
" <td>1.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>106</th>\n",
" <td>3</td>\n",
" <td>-0.543716</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>False</td>\n",
" <td>False</td>\n",
" <td>True</td>\n",
" <td>False</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>1.0</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>2</td>\n",
" <td>-1.052827</td>\n",
" <td>0.2</td>\n",
" <td>0.0</td>\n",
" <td>True</td>\n",
" <td>False</td>\n",
" <td>False</td>\n",
" <td>False</td>\n",
" <td>1.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Pclass Age SibSp Parch Embarked_C Embarked_Q Embarked_S \n",
"91 3 -0.616446 0.0 0.0 False False True \\\n",
"145 2 -0.689176 0.2 0.2 False False True \n",
"115 3 -0.543716 0.0 0.0 False False True \n",
"106 3 -0.543716 0.0 0.0 False False True \n",
"9 2 -1.052827 0.2 0.0 True False False \n",
"91 3 -0.616446 0.0 0.0 0.0 0.0 1.0 \\\n",
"145 2 -0.689176 0.2 0.2 0.0 0.0 1.0 \n",
"115 3 -0.543716 0.0 0.0 0.0 0.0 1.0 \n",
"106 3 -0.543716 0.0 0.0 0.0 0.0 1.0 \n",
"9 2 -1.052827 0.2 0.0 1.0 0.0 0.0 \n",
"\n",
" Sex_male \n",
"91 True \n",
"145 True \n",
"115 True \n",
"106 False \n",
"9 False "
"91 1.0 \n",
"145 1.0 \n",
"115 1.0 \n",
"106 0.0 \n",
"9 0.0 "
]
},
"execution_count": null,
Expand Down
Loading

0 comments on commit bef1b6e

Please sign in to comment.