This commit is contained in:
Petrus committed 2025-10-31 16:03:54 +01:00
1 parent 52a78af447
commit abbd45298a
9 files changed
+61 -61

No files matched your search

+49 -49
View File
@@ -6,7 +6,7 @@
"metadata": {},
"source": [
"### Toymodel as an initial test\n",
"This section is mostly the initial feature engineering. We also create a simple toymodel just to see how the decision tree performs"
"This section is mostly the initial feature engineering. We also create a simple toymodel just to see how the decision tree performs and a correlation matrix to find possible redundant features. "
]
},
{
@@ -17,7 +17,7 @@
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA7sAAAOwCAYAAAD/XWM1AAAAOnRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjEwLjcsIGh0dHBzOi8vbWF0cGxvdGxpYi5vcmcvTLEjVAAAAAlwSFlzAAAPYQAAD2EBqD+naQABAABJREFUeJzs3Xd0VPXaxfHvpHdCGqRQQu8dBEE6iChiRVFpooiIICgqIiJgAxVERRRFFKSjCIJ0SOi9914CCamktynvH0CuvKJSEk7K/qzlujA5c2bPXJLJnnN+zzHZbDYbIiIiIiIiIoWIndEBRERERERERHKbyq6IiIiIiIgUOiq7IiIiIiIiUuio7IqIiIiIiEiho7IrIiIiIiIihY7KroiIiIiIiBQ6KrsiIiIiIiJS6KjsioiIiIiISKGjsisiIiIiIiKFjsquiIiIiIiIFDoquyIiIiIiIlLoqOyKiIiIiIhIoaOyKyIiIiIiIoWOyq6IiIiIiIgUOiq7IiIiIiIiUuio7IqIiIiIiEiho7IrIiIiIiIihY7KroiIiIiIiBQ6KrsiIiIiIiJS6KjsioiIiIiISKGjsisiIiIiIiKFjsquiIiIiIiIFDoquyIiIiIiIlLoqOyKiIiIiIhIoaOyKyIiIiIiIoWOyq6IiIiIiIgUOiq7IiIiIiIiUuio7IqIiIiIiEiho7IrIiIiIiIihY7KroiIiIiIiBQ6KrsiIiIiIiJS6KjsioiIiIiISKGjsisiIiIiIiKFjsquiIiIiIiIFDoquyIiIiIiIlLoqOyKiIiIiIhIo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s3Xd4VFXixvHvpHdCeughBJLQqxSpKnaavYBlVUBRV9cCgg2kBkURkGJBkCoIUgSkhV5CDyn0UEIoSQhJSJ+Z3x8IKz/LAibcTPJ+nsdnYXLnzjuzJJl3zj3nmKxWqxURERERERERG2VndAARERERERGRf0LFVkRERERERGyaiq2IiIiIiIjYNBVbERERERERsWkqtiIiIiIiImLTVGxFRERERETEpqnYioiIiIiIiE1TsRURERERERGbpmIrIiIiIiIiNk3FVkRERERERGyaiq2IiIiIiIjYNBVbERERERERsWkqtiIiIiIiImLTVGxFRERERETEpqnYioiIiIiIiE1TsRURERERERGbpmIrIiIiIiIiNk3FVkRERERERGyaiq2IiIiIiIjYNBVbERERERERsWkqtiIiIiIiImLTVGxFRERERETEpqnYioiIiIiIiE1TsRURERERERGbpmIrIiIiIiIiNk3FVkRERERERGyaiq2IiIiIiIjYNBVbERERERERsWkqtiIiIiIiImLTVGxFRERERETEpqnYioiIiIiIiE1TsRURERERERGbpmIrIiIiIiIiNk3FVkRERERERGyaiq2IiIiIiIjYNBVbERERERERsWkqtiIiIiIiImLTVGxFRERERETEpqnYioiIiIiIiE1TsRURERERERGbpmIrIiIiIiIiNk3FVkRERERERGyaiq2IiIiIiIjYNBVbERERERERsWkqtiIiIiIiImLTVGxFRERERETEpqnYioiIiIiIiE1TsRURERERERGbpmIrIiIiIiIiNk3FVkRERERERGyaiq2IiIiIiIjYNBVbERERERERsWkqtiIiIiIiImLTVGxFRERERETEpqnYioiIiIiIiE1TsRURERERERGbpmIrIiIiIiIiNk3FVkRERERERGyaiq2IiIiIiIjYNBVbERERERERsWkqtiIiIiIiImLTVGxFRERERETEpqnYioiIiIiIiE1TsRURERERERGbpmIrIiIiIiIiNk3FVkRERERERGyaiq2IiIiIiIjYNBVbERERERERsWkqtiIiIiIiImLTVGxFRERERETEpqnYioiIiIiIiE1TsRURERERERGb5mB0ABEREbl5+fn5nDp1CovFYnSUG2YymahUqRJubm5GRxERERunYisiImKjTp06RYf27Thy9JjRUW6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DXrl307t2bHTt20Lt3b4YPH07FihWv4562IScnh08++YSoqChq1qzJxIkT6dixo9GxRETERmjEVkREpBTLzMzk9ddfp3nz5uTn57N582YmTpxYpkotv21dNGzYMPbs2UNAQACdOnWiV69enDt3zuhoIiJiA1RsRURESiGr1cr8+fOJiIjg66+/ZuTIkezcubNUr3hcHOrWrcu6dev4+uuvWbp0KeHh4Xz99ddYLBajo4mISCmmYisiIlLKJCUl8eCDD/Lwww/TtGlT4uPjeeutt3B0dDQ62i1hZ2fHv/71LxITE+nSpQsvvvgi7dq1Y//+/UZHExGRUkrFVkREpJQLine truncated
"text/plain": [
"<Figure size 1200x1200 with 1 Axes>"
]
@@ -35,6 +35,16 @@
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAtkAAAJsCAYAAAAoSr9YAAAAOnRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjEwLjcsIGh0dHBzOi8vbWF0cGxvdGxpYi5vcmcvTLEjVAAAAAlwSFlzAAAPYQAAD2EBqD+naQABAABJREFUeJzs3XdUVMfbwPHvLl26dKR3pNoVe+810Rhj19g1aozGWNCfxhJ7L4m9a+y9YO9dLNgQu6IgLCDS9/0DWFhZqhJN3vmcs+fI3efe++zszDg7O/euRC6XyxEEQRAEQRAE4bORfukEBEEQBEEQBOG/RgyyBUEQBEEQBOEzE4NsQRAEQRAEQfjMxCBbEARBEARBED4zMcgWBEEQBEEQhM9MDLIFQRAEQRAE4TMTg2xBEARBEARB+MzEIFsQBEEQBEEQPjMxyBYEQRAEQRCEz0wMsgVBEAph5cqVSCQSHj9+/NmO+fjxYyQSCStXrvxsxxQEQRC+LDHIFgThiwsNDaV37944OTmhra2NgYEBVatWZc6cOXz48OFLp/fZrF+/ntmzZ3/pNJR07doVPT29XJ+XSCQMGDCgWHNYuHCh+IAhCMJ/jvqXTkAQhP/f9u7dS9u2bdHS0qJz5854e3uTlJTE6dOn+eWXX7h9+zZLly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Zo3b67yuNOmTaNx48ZUqVKFHj16KG7hZ2hoyLhx44r8Wj9Vp06d2Lx5M3369OHYsWNUrVqV1NRU7t69y+bNmxX3Jm/QoAGampo0b96c3r17ExcXx59//om5uTmvXr1SOma5cuVYtGgREydOxMXFBXNzc8WFlJ+iadOmzJw5k0aNGtGhQwfevHnDggULcHFxITg4OEe8t7c3DRs2VLqFH8D48eM/ORdBEP4f+tK3NxEEQbh//778xx9/lDs4OMg1NTXl+vr68qpVq8rnzZundAu85ORk+fjx4+WOjo5yDQ0Nua2trXzkyJFKMfKMW/g1bdo0x3kyb+G3ZcsWlXlcu3ZN3qZNG7mJiYlcS0tLbm9vL2/Xrp08KChIEaPqFn5nzpyRV65cWa6joyO3traWDx8+XH7w4EE5ID927JgiLi4uTt6hQwe5kZGRHFDczk/VLfzkcrn8yJEj8qpVq8p1dHTkBgYG8ubNm8vv3LmjFJN5C7+3b98qbVeVpypdunSR6+rq5vr8x7fwk2fcBm/q1KlyLy8vuZaWltzY2Fherlw5+fjx4+UymUwRt2vXLrmvr69cW1tb7uDgIJ86dap8+fLlOfJ6/fq1vGnTpnJ9fX05oLgNX+ZruHTpUoFes6rXsmzZMrmrq6tcS0tL7uHhIV+xYoVif1Wvc+3atYr4MmXKKL1/giAIhSGRf+6rYgRBEAThX0YikdC/f3/mz5//pVMRBOE/QqzJFgRBEARBEITPTAyyBUEQBEEQBOEzE4NsQRAEQRAEQfjMxCBbEARB+H9PLpeL9diC8C9x8uRJmjdvjrW1NRKJJNfbcmZ3/PhxypYti5aWFi4uLqxcubLY8xSDbEEQBEEQBOFf4/379/j5+bFgwYICxYeFhdG0aVNq167N9evXGTx4MD179uTgwYPFmqe4u4ggCIIgCILwrySRSNi+fTutWrXKNWbEiBHs3buXW7duKba1b9+e6OhoDhw4UGy5iZlsQRAEQRAE4YtKTEwkJiZG6ZGYmPhZjn3u3Dnq1auntK1Line truncated
"text/plain": [
"<Figure size 800x600 with 2 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
@@ -48,11 +58,7 @@
" accuracy 0.81 6033\n",
" macro avg 0.74 0.75 0.74 6033\n",
" weighted avg 0.81 0.81 0.81 6033\n",
"\n",
"Index(['age', 'workclass', 'education.num', 'marital.status', 'occupation',\n",
" 'relationship', 'race', 'sex', 'capital.gain', 'capital.loss',\n",
" 'hours.per.week', 'native.country'],\n",
" dtype='object')\n"
"\n"
]
}
],
@@ -65,6 +71,7 @@
"from sklearn.tree import DecisionTreeClassifier, plot_tree\n",
"from sklearn.preprocessing import LabelEncoder\n",
"from sklearn.metrics import classification_report, confusion_matrix, ConfusionMatrixDisplay\n",
"import seaborn as sns\n",
"\n",
"# Load dataset\n",
"df = pd.read_csv('./Datasets/adult.csv', comment = '#')\n",
@@ -84,7 +91,7 @@
" le = LabelEncoder()\n",
" df_encoded[column] = le.fit_transform(df_encoded[column])\n",
"\n",
"# Now properly separate features and target\n",
"# Separate features and target\n",
"X = df_encoded.drop(columns=['income'])\n",
"y = df_encoded['income']\n",
"\n",
@@ -124,10 +131,15 @@
"plt.title(\"Confusion Matrix\")\n",
"plt.show() \n",
"\n",
"print(\"Classification Report:\")\n",
"print(classification_report(y_val, y_pred, target_names=[\"Lower-earning\", \"Higher-earning\"]))\n",
"# Create a correlation matrix\n",
"matrix = X_train.corr()\n",
"plt.figure(figsize=(8,6))\n",
"sns.heatmap(matrix, annot=True, cmap=\"coolwarm\", fmt=\".2f\", linewidths=0.5)\n",
"plt.title(\"Correlation Heatmap\")\n",
"plt.show()\n",
"\n",
"print(X_train_val.columns)"
"print(\"Classification Report:\")\n",
"print(classification_report(y_val, y_pred, target_names=[\"Lower-earning\", \"Higher-earning\"]))"
]
},
{
@@ -143,7 +155,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 24,
"id": "e68b1ea9",
"metadata": {},
"outputs": [],
@@ -286,7 +298,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 25,
"id": "d6fd1fee",
"metadata": {},
"outputs": [
@@ -306,15 +318,15 @@
"\n",
"------ Results Sorted by Accuracy ------\n",
" Model Accuracy Precision Recall F1 Score Best Params Training Time (s) Prediction Time (s) Total Time (s)\n",
" XGBoost 0.868059 0.863590 0.868059 0.863957 {'learning_rate': 0.2, 'max_depth': 5, 'n_estimators': 100} 28.797149 0.005661 28.802809\n",
"Random Forest 0.858942 0.853479 0.858942 0.853443 {'max_depth': 20, 'min_samples_split': 10, 'n_estimators': 100} 166.736673 0.098411 166.835085\n",
"Decision Tree 0.848334 0.844900 0.848334 0.846228 {'max_depth': 10, 'min_samples_split': 5} 9.839182 0.004644 9.843826\n",
" XGBoost 0.868059 0.863590 0.868059 0.863957 {'learning_rate': 0.2, 'max_depth': 5, 'n_estimators': 100} 54.522120 0.022445 54.544564\n",
"Random Forest 0.858942 0.853479 0.858942 0.853443 {'max_depth': 20, 'min_samples_split': 10, 'n_estimators': 100} 152.761754 0.094559 152.856313\n",
"Decision Tree 0.848334 0.844900 0.848334 0.846228 {'max_depth': 10, 'min_samples_split': 5} 7.268746 0.003260 7.272006\n",
"\n",
"------ Results Sorted by Total Time ------\n",
" Model Accuracy Precision Recall F1 Score Best Params Training Time (s) Prediction Time (s) Total Time (s)\n",
"Decision Tree 0.848334 0.844900 0.848334 0.846228 {'max_depth': 10, 'min_samples_split': 5} 9.839182 0.004644 9.843826\n",
" XGBoost 0.868059 0.863590 0.868059 0.863957 {'learning_rate': 0.2, 'max_depth': 5, 'n_estimators': 100} 28.797149 0.005661 28.802809\n",
"Random Forest 0.858942 0.853479 0.858942 0.853443 {'max_depth': 20, 'min_samples_split': 10, 'n_estimators': 100} 166.736673 0.098411 166.835085\n"
"Decision Tree 0.848334 0.844900 0.848334 0.846228 {'max_depth': 10, 'min_samples_split': 5} 7.268746 0.003260 7.272006\n",
" XGBoost 0.868059 0.863590 0.868059 0.863957 {'learning_rate': 0.2, 'max_depth': 5, 'n_estimators': 100} 54.522120 0.022445 54.544564\n",
"Random Forest 0.858942 0.853479 0.858942 0.853443 {'max_depth': 20, 'min_samples_split': 10, 'n_estimators': 100} 152.761754 0.094559 152.856313\n"
]
}
],
@@ -336,7 +348,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 26,
"id": "4185a428",
"metadata": {},
"outputs": [
@@ -350,15 +362,15 @@
"\n",
"------ Results Sorted by Accuracy ------\n",
" Model Accuracy Precision Recall F1 Score Best Params Training Time (s) Prediction Time (s) Total Time (s)\n",
" XGBoost 0.868556 0.864049 0.868556 0.864181 {'learning_rate': 0.2, 'max_depth': 5, 'n_estimators': 75} 24.887917 0.011055 24.898972\n",
"Random Forest 0.858942 0.853479 0.858942 0.853443 {'max_depth': 20, 'min_samples_split': 10, 'n_estimators': 100} 91.218867 0.037435 91.256302\n",
"Decision Tree 0.849163 0.843062 0.849163 0.839388 {'max_depth': 8, 'min_samples_split': 6} 0.872687 0.001455 0.874143\n",
" XGBoost 0.868556 0.864049 0.868556 0.864181 {'learning_rate': 0.2, 'max_depth': 5, 'n_estimators': 75} 27.877137 0.011091 27.888228\n",
"Random Forest 0.858942 0.853479 0.858942 0.853443 {'max_depth': 20, 'min_samples_split': 10, 'n_estimators': 100} 136.946045 0.074518 137.020563\n",
"Decision Tree 0.849163 0.843062 0.849163 0.839388 {'max_depth': 8, 'min_samples_split': 6} 2.567322 0.006399 2.573721\n",
"\n",
"------ Results Sorted by Total Time ------\n",
" Model Accuracy Precision Recall F1 Score Best Params Training Time (s) Prediction Time (s) Total Time (s)\n",
"Decision Tree 0.849163 0.843062 0.849163 0.839388 {'max_depth': 8, 'min_samples_split': 6} 0.872687 0.001455 0.874143\n",
" XGBoost 0.868556 0.864049 0.868556 0.864181 {'learning_rate': 0.2, 'max_depth': 5, 'n_estimators': 75} 24.887917 0.011055 24.898972\n",
"Random Forest 0.858942 0.853479 0.858942 0.853443 {'max_depth': 20, 'min_samples_split': 10, 'n_estimators': 100} 91.218867 0.037435 91.256302\n"
"Decision Tree 0.849163 0.843062 0.849163 0.839388 {'max_depth': 8, 'min_samples_split': 6} 2.567322 0.006399 2.573721\n",
" XGBoost 0.868556 0.864049 0.868556 0.864181 {'learning_rate': 0.2, 'max_depth': 5, 'n_estimators': 75} 27.877137 0.011091 27.888228\n",
"Random Forest 0.858942 0.853479 0.858942 0.853443 {'max_depth': 20, 'min_samples_split': 10, 'n_estimators': 100} 136.946045 0.074518 137.020563\n"
]
},
{
@@ -433,7 +445,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 27,
"id": "776cdb17",
"metadata": {},
"outputs": [
@@ -441,27 +453,15 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Tuning Decision Tree ...\n"
]
},
{
"ename": "KeyboardInterrupt",
"evalue": "",
"output_type": "error",
"traceback": [
"\u001b[31m---------------------------------------------------------------------------\u001b[39m",
"\u001b[31mKeyboardInterrupt\u001b[39m Traceback (most recent call last)",
"\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[13]\u001b[39m\u001b[32m, line 12\u001b[39m\n\u001b[32m 10\u001b[39m \u001b[38;5;66;03m# Train decision tree without redundant features\u001b[39;00m\n\u001b[32m 11\u001b[39m cmp_dt = ClassifierComparisonOpt(X_dt, y_train_val)\n\u001b[32m---> \u001b[39m\u001b[32m12\u001b[39m \u001b[43mcmp_dt\u001b[49m\u001b[43m.\u001b[49m\u001b[43mfit_models\u001b[49m\u001b[43m(\u001b[49m\u001b[43m{\u001b[49m\u001b[33;43m'\u001b[39;49m\u001b[33;43mDecision Tree\u001b[39;49m\u001b[33;43m'\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mfine_grid\u001b[49m\u001b[43m[\u001b[49m\u001b[33;43m'\u001b[39;49m\u001b[33;43mDecision Tree\u001b[39;49m\u001b[33;43m'\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m}\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 14\u001b[39m \u001b[38;5;66;03m# Train XGBoost without redundant features\u001b[39;00m\n\u001b[32m 15\u001b[39m cmp_xgb = ClassifierComparisonOpt(X_xgb, y_train_val)\n",
"\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[12]\u001b[39m\u001b[32m, line 63\u001b[39m, in \u001b[36mClassifierComparisonOpt.fit_models\u001b[39m\u001b[34m(self, models_with_params)\u001b[39m\n\u001b[32m 60\u001b[39m grid_search = GridSearchCV(model, param_grid, scoring=\u001b[33m'\u001b[39m\u001b[33maccuracy\u001b[39m\u001b[33m'\u001b[39m, cv=cv, n_jobs=-\u001b[32m1\u001b[39m)\n\u001b[32m 62\u001b[39m start_train = time.time()\n\u001b[32m---> \u001b[39m\u001b[32m63\u001b[39m \u001b[43mgrid_search\u001b[49m\u001b[43m.\u001b[49m\u001b[43mfit\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mX_train\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43my_train\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 64\u001b[39m end_train = time.time()\n\u001b[32m 66\u001b[39m best_model = grid_search.best_estimator_\n",
"\u001b[36mFile \u001b[39m\u001b[32m~/Documents/MLP/Projects/MLPproject/.venv/lib64/python3.13/site-packages/sklearn/base.py:1365\u001b[39m, in \u001b[36m_fit_context.<locals>.decorator.<locals>.wrapper\u001b[39m\u001b[34m(estimator, *args, **kwargs)\u001b[39m\n\u001b[32m 1358\u001b[39m estimator._validate_params()\n\u001b[32m 1360\u001b[39m \u001b[38;5;28;01mwith\u001b[39;00m config_context(\n\u001b[32m 1361\u001b[39m skip_parameter_validation=(\n\u001b[32m 1362\u001b[39m prefer_skip_nested_validation \u001b[38;5;129;01mor\u001b[39;00m global_skip_validation\n\u001b[32m 1363\u001b[39m )\n\u001b[32m 1364\u001b[39m ):\n\u001b[32m-> \u001b[39m\u001b[32m1365\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mfit_method\u001b[49m\u001b[43m(\u001b[49m\u001b[43mestimator\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n",
"\u001b[36mFile \u001b[39m\u001b[32m~/Documents/MLP/Projects/MLPproject/.venv/lib64/python3.13/site-packages/sklearn/model_selection/_search.py:1051\u001b[39m, in \u001b[36mBaseSearchCV.fit\u001b[39m\u001b[34m(self, X, y, **params)\u001b[39m\n\u001b[32m 1045\u001b[39m results = \u001b[38;5;28mself\u001b[39m._format_results(\n\u001b[32m 1046\u001b[39m all_candidate_params, n_splits, all_out, all_more_results\n\u001b[32m 1047\u001b[39m )\n\u001b[32m 1049\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m results\n\u001b[32m-> \u001b[39m\u001b[32m1051\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_run_search\u001b[49m\u001b[43m(\u001b[49m\u001b[43mevaluate_candidates\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 1053\u001b[39m \u001b[38;5;66;03m# multimetric is determined here because in the case of a callable\u001b[39;00m\n\u001b[32m 1054\u001b[39m \u001b[38;5;66;03m# self.scoring the return type is only known after calling\u001b[39;00m\n\u001b[32m 1055\u001b[39m first_test_score = all_out[\u001b[32m0\u001b[39m][\u001b[33m\"\u001b[39m\u001b[33mtest_scores\u001b[39m\u001b[33m\"\u001b[39m]\n",
"\u001b[36mFile \u001b[39m\u001b[32m~/Documents/MLP/Projects/MLPproject/.venv/lib64/python3.13/site-packages/sklearn/model_selection/_search.py:1605\u001b[39m, in \u001b[36mGridSearchCV._run_search\u001b[39m\u001b[34m(self, evaluate_candidates)\u001b[39m\n\u001b[32m 1603\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34m_run_search\u001b[39m(\u001b[38;5;28mself\u001b[39m, evaluate_candidates):\n\u001b[32m 1604\u001b[39m \u001b[38;5;250m \u001b[39m\u001b[33;03m\"\"\"Search all candidates in param_grid\"\"\"\u001b[39;00m\n\u001b[32m-> \u001b[39m\u001b[32m1605\u001b[39m \u001b[43mevaluate_candidates\u001b[49m\u001b[43m(\u001b[49m\u001b[43mParameterGrid\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mparam_grid\u001b[49m\u001b[43m)\u001b[49m\u001b[43m)\u001b[49m\n",
"\u001b[36mFile \u001b[39m\u001b[32m~/Documents/MLP/Projects/MLPproject/.venv/lib64/python3.13/site-packages/sklearn/model_selection/_search.py:997\u001b[39m, in \u001b[36mBaseSearchCV.fit.<locals>.evaluate_candidates\u001b[39m\u001b[34m(candidate_params, cv, more_results)\u001b[39m\n\u001b[32m 989\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m.verbose > \u001b[32m0\u001b[39m:\n\u001b[32m 990\u001b[39m \u001b[38;5;28mprint\u001b[39m(\n\u001b[32m 991\u001b[39m \u001b[33m\"\u001b[39m\u001b[33mFitting \u001b[39m\u001b[38;5;132;01m{0}\u001b[39;00m\u001b[33m folds for each of \u001b[39m\u001b[38;5;132;01m{1}\u001b[39;00m\u001b[33m candidates,\u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m 992\u001b[39m \u001b[33m\"\u001b[39m\u001b[33m totalling \u001b[39m\u001b[38;5;132;01m{2}\u001b[39;00m\u001b[33m fits\u001b[39m\u001b[33m\"\u001b[39m.format(\n\u001b[32m 993\u001b[39m n_splits, n_candidates, n_candidates * n_splits\n\u001b[32m 994\u001b[39m )\n\u001b[32m 995\u001b[39m )\n\u001b[32m--> \u001b[39m\u001b[32m997\u001b[39m out = \u001b[43mparallel\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m 998\u001b[39m \u001b[43m \u001b[49m\u001b[43mdelayed\u001b[49m\u001b[43m(\u001b[49m\u001b[43m_fit_and_score\u001b[49m\u001b[43m)\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m 999\u001b[39m \u001b[43m \u001b[49m\u001b[43mclone\u001b[49m\u001b[43m(\u001b[49m\u001b[43mbase_estimator\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1000\u001b[39m \u001b[43m \u001b[49m\u001b[43mX\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1001\u001b[39m \u001b[43m \u001b[49m\u001b[43my\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1002\u001b[39m \u001b[43m \u001b[49m\u001b[43mtrain\u001b[49m\u001b[43m=\u001b[49m\u001b[43mtrain\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1003\u001b[39m \u001b[43m \u001b[49m\u001b[43mtest\u001b[49m\u001b[43m=\u001b[49m\u001b[43mtest\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1004\u001b[39m \u001b[43m \u001b[49m\u001b[43mparameters\u001b[49m\u001b[43m=\u001b[49m\u001b[43mparameters\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1005\u001b[39m \u001b[43m \u001b[49m\u001b[43msplit_progress\u001b[49m\u001b[43m=\u001b[49m\u001b[43m(\u001b[49m\u001b[43msplit_idx\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mn_splits\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1006\u001b[39m \u001b[43m \u001b[49m\u001b[43mcandidate_progress\u001b[49m\u001b[43m=\u001b[49m\u001b[43m(\u001b[49m\u001b[43mcand_idx\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mn_candidates\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1007\u001b[39m \u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mfit_and_score_kwargs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1008\u001b[39m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 1009\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43;01mfor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43m(\u001b[49m\u001b[43mcand_idx\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mparameters\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m(\u001b[49m\u001b[43msplit_idx\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m(\u001b[49m\u001b[43mtrain\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mtest\u001b[49m\u001b[43m)\u001b[49m\u001b[43m)\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01min\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mproduct\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m 1010\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43menumerate\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mcandidate_params\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1011\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43menumerate\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mcv\u001b[49m\u001b[43m.\u001b[49m\u001b[43msplit\u001b[49m\u001b[43m(\u001b[49m\u001b[43mX\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43my\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mrouted_params\u001b[49m\u001b[43m.\u001b[49m\u001b[43msplitter\u001b[49m\u001b[43m.\u001b[49m\u001b[43msplit\u001b[49m\u001b[43m)\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1012\u001b[39m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 1013\u001b[39m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 1015\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mlen\u001b[39m(out) < \u001b[32m1\u001b[39m:\n\u001b[32m 1016\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\n\u001b[32m 1017\u001b[39m \u001b[33m\"\u001b[39m\u001b[33mNo fits were performed. \u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m 1018\u001b[39m \u001b[33m\"\u001b[39m\u0Line truncated
"\u001b[36mFile \u001b[39m\u001b[32m~/Documents/MLP/Projects/MLPproject/.venv/lib64/python3.13/site-packages/sklearn/utils/parallel.py:82\u001b[39m, in \u001b[36mParallel.__call__\u001b[39m\u001b[34m(self, iterable)\u001b[39m\n\u001b[32m 73\u001b[39m warning_filters = warnings.filters\n\u001b[32m 74\u001b[39m iterable_with_config_and_warning_filters = (\n\u001b[32m 75\u001b[39m (\n\u001b[32m 76\u001b[39m _with_config_and_warning_filters(delayed_func, config, warning_filters),\n\u001b[32m (...)\u001b[39m\u001b[32m 80\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m delayed_func, args, kwargs \u001b[38;5;129;01min\u001b[39;00m iterable\n\u001b[32m 81\u001b[39m )\n\u001b[32m---> \u001b[39m\u001b[32m82\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43msuper\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[43m.\u001b[49m\u001b[34;43m__call__\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43miterable_with_config_and_warning_filters\u001b[49m\u001b[43m)\u001b[49m\n",
"\u001b[36mFile \u001b[39m\u001b[32m~/Documents/MLP/Projects/MLPproject/.venv/lib64/python3.13/site-packages/joblib/parallel.py:2072\u001b[39m, in \u001b[36mParallel.__call__\u001b[39m\u001b[34m(self, iterable)\u001b[39m\n\u001b[32m 2066\u001b[39m \u001b[38;5;66;03m# The first item from the output is blank, but it makes the interpreter\u001b[39;00m\n\u001b[32m 2067\u001b[39m \u001b[38;5;66;03m# progress until it enters the Try/Except block of the generator and\u001b[39;00m\n\u001b[32m 2068\u001b[39m \u001b[38;5;66;03m# reaches the first `yield` statement. This starts the asynchronous\u001b[39;00m\n\u001b[32m 2069\u001b[39m \u001b[38;5;66;03m# dispatch of the tasks to the workers.\u001b[39;00m\n\u001b[32m 2070\u001b[39m \u001b[38;5;28mnext\u001b[39m(output)\n\u001b[32m-> \u001b[39m\u001b[32m2072\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m output \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m.return_generator \u001b[38;5;28;01melse\u001b[39;00m \u001b[38;5;28;43mlist\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43moutput\u001b[49m\u001b[43m)\u001b[49m\n",
"\u001b[36mFile \u001b[39m\u001b[32m~/Documents/MLP/Projects/MLPproject/.venv/lib64/python3.13/site-packages/joblib/parallel.py:1682\u001b[39m, in \u001b[36mParallel._get_outputs\u001b[39m\u001b[34m(self, iterator, pre_dispatch)\u001b[39m\n\u001b[32m 1679\u001b[39m \u001b[38;5;28;01myield\u001b[39;00m\n\u001b[32m 1681\u001b[39m \u001b[38;5;28;01mwith\u001b[39;00m \u001b[38;5;28mself\u001b[39m._backend.retrieval_context():\n\u001b[32m-> \u001b[39m\u001b[32m1682\u001b[39m \u001b[38;5;28;01myield from\u001b[39;00m \u001b[38;5;28mself\u001b[39m._retrieve()\n\u001b[32m 1684\u001b[39m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mGeneratorExit\u001b[39;00m:\n\u001b[32m 1685\u001b[39m \u001b[38;5;66;03m# The generator has been garbage collected before being fully\u001b[39;00m\n\u001b[32m 1686\u001b[39m \u001b[38;5;66;03m# consumed. This aborts the remaining tasks if possible and warn\u001b[39;00m\n\u001b[32m 1687\u001b[39m \u001b[38;5;66;03m# the user if necessary.\u001b[39;00m\n\u001b[32m 1688\u001b[39m \u001b[38;5;28mself\u001b[39m._exception = \u001b[38;5;28;01mTrue\u001b[39;00m\n",
"\u001b[36mFile \u001b[39m\u001b[32m~/Documents/MLP/Projects/MLPproject/.venv/lib64/python3.13/site-packages/joblib/parallel.py:1800\u001b[39m, in \u001b[36mParallel._retrieve\u001b[39m\u001b[34m(self)\u001b[39m\n\u001b[32m 1789\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m.return_ordered:\n\u001b[32m 1790\u001b[39m \u001b[38;5;66;03m# Case ordered: wait for completion (or error) of the next job\u001b[39;00m\n\u001b[32m 1791\u001b[39m \u001b[38;5;66;03m# that have been dispatched and not retrieved yet. If no job\u001b[39;00m\n\u001b[32m (...)\u001b[39m\u001b[32m 1795\u001b[39m \u001b[38;5;66;03m# control only have to be done on the amount of time the next\u001b[39;00m\n\u001b[32m 1796\u001b[39m \u001b[38;5;66;03m# dispatched job is pending.\u001b[39;00m\n\u001b[32m 1797\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m (nb_jobs == \u001b[32m0\u001b[39m) \u001b[38;5;129;01mor\u001b[39;00m (\n\u001b[32m 1798\u001b[39m \u001b[38;5;28mself\u001b[39m._jobs[\u001b[32m0\u001b[39m].get_status(timeout=\u001b[38;5;28mself\u001b[39m.timeout) == TASK_PENDING\n\u001b[32m 1799\u001b[39m ):\n\u001b[32m-> \u001b[39m\u001b[32m1800\u001b[39m \u001b[43mtime\u001b[49m\u001b[43m.\u001b[49m\u001b[43msleep\u001b[49m\u001b[43m(\u001b[49m\u001b[32;43m0.01\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[32m 1801\u001b[39m \u001b[38;5;28;01mcontinue\u001b[39;00m\n\u001b[32m 1803\u001b[39m \u001b[38;5;28;01melif\u001b[39;00m nb_jobs == \u001b[32m0\u001b[39m:\n\u001b[32m 1804\u001b[39m \u001b[38;5;66;03m# Case unordered: jobs are added to the list of jobs to\u001b[39;00m\n\u001b[32m 1805\u001b[39m \u001b[38;5;66;03m# retrieve `self._jobs` only once completed or in error, which\u001b[39;00m\n\u001b[32m (...)\u001b[39m\u001b[32m 1811\u001b[39m \u001b[38;5;66;03m# timeouts before any other dispatched job has completed and\u001b[39;00m\n\u001b[32m 1812\u001b[39m \u001b[38;5;66;03m# been added to `self._jobs` to be retrieved.\u001b[39;00m\n",
"\u001b[31mKeyboardInterrupt\u001b[39m: "
"Tuning Decision Tree ...\n",
"Tuning XGBoost ...\n",
"Tuning Random Forest ...\n",
"\n",
"------ Results Sorted by Accuracy ------\n",
" Model Accuracy Precision Recall F1 Score Best Params Training Time (s) Prediction Time (s) Total Time (s)\n",
" XGBoost 0.867893 0.863335 0.867893 0.863496 {'learning_rate': 0.15, 'max_depth': 5, 'n_estimators': 100} 27.545653 0.011063 27.556716\n",
"Random Forest 0.859606 0.854161 0.859606 0.853520 {'max_depth': 15, 'min_samples_split': 8, 'n_estimators': 150} 117.926460 0.047736 117.974195\n",
"Decision Tree 0.848666 0.843533 0.848666 0.837078 {'max_depth': 8, 'min_samples_split': 4} 1.503573 0.004421 1.507995\n"
]
}
],
@@ -504,7 +504,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 28,
"id": "a470fd20",
"metadata": {},
"outputs": [
+1 -1
View File
@@ -57,7 +57,6 @@
\newlabel{rf_metrics@cref}{{[table][4][]4}{[1][4][]4}}
\@writefile{toc}{\contentsline {subsection}{\numberline {5.4}Overfitting and Underfitting}{4}{subsection.5.4}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {5.5}Feature Importance}{4}{subsection.5.5}\protected@file@percent }
\@writefile{toc}{\contentsline {section}{\numberline {6}Summary}{4}{section.6}\protected@file@percent }
\newlabel{fig:featureImportanceDT}{{2(a)}{5}{\relax }{figure.caption.6}{}}
\newlabel{fig:featureImportanceDT@cref}{{[subfigure][1][2]2(a)}{[1][4][]5}}
\newlabel{sub@fig:featureImportanceDT}{{(a)}{5}{\relax }{figure.caption.6}{}}
@@ -69,6 +68,7 @@
\@writefile{lof}{\contentsline {figure}{\numberline {2}{\ignorespaces The feature importance graphs for the Decision Tree model and the Random Forest model based on the validation data.\relax }}{5}{figure.caption.6}\protected@file@percent }
\newlabel{fig:}{{2}{5}{The feature importance graphs for the Decision Tree model and the Random Forest model based on the validation data.\relax }{figure.caption.6}{}}
\newlabel{fig:@cref}{{[figure][2][]2}{[1][4][]5}}
\@writefile{toc}{\contentsline {section}{\numberline {6}Summary}{5}{section.6}\protected@file@percent }
\ttl@finishall
\newlabel{LastPage}{{}{5}{}{page.5}{}}
\xdef\lastpage@lastpage{5}
+6 -6
View File
@@ -1,6 +1,6 @@
# Fdb version 4
["pdflatex"] 1761920867.71702 "/home/petrus/Documents/MLP/Projects/MLPproject/Report/MLPproject.tex" "MLPproject.pdf" "MLPproject" 1761920868.83079 0
"/home/petrus/Documents/MLP/Projects/MLPproject/Report/MLPproject.tex" 1761920867.50658 24533 58032bad0234d994ba6556d7acc5212e ""
["pdflatex"] 1761921952.93435 "/home/petrus/Documents/MLP/Projects/MLPproject/Report/MLPproject.tex" "MLPproject.pdf" "MLPproject" 1761921953.99247 0
"/home/petrus/Documents/MLP/Projects/MLPproject/Report/MLPproject.tex" 1761921952.70534 24812 36992a9467feb6ff9f9f97a89afe5aee ""
"/usr/share/texlive/texmf-dist/fonts/enc/dvips/base/8r.enc" 1737590400 4850 80dc9bab7f31fb78a000ccfed0e27cab ""
"/usr/share/texlive/texmf-dist/fonts/map/fontname/texfonts.map" 1577235249 3524 cb3e574dea2d1052e39280babc910dc8 ""
"/usr/share/texlive/texmf-dist/fonts/tfm/adobe/helvetic/phvb7t.tfm" 1136768653 2240 eb56c13537f4d8a0bd3fafc25572b1bd ""
@@ -131,10 +131,10 @@
"/var/lib/texmf/web2c/pdftex/pdflatex.fmt" 1761127067 7753793 c9f4d2c19ab997188c605d7179b0cdc0 ""
"CM_dt.png" 1761920482.34887 97023 ce9f07bdb4551ffd7f80782b99a54328 ""
"CM_rf.png" 1761920484.96582 98726 a24b8d53317f0e7e65e41ed83ef8fae5 ""
"MLPproject.aux" 1761920868.72356 6698 e699ab45a2056e84f281588212bdf2ec "pdflatex"
"MLPproject.out" 1761920868.72456 3113 d57c5f2b0e6699323b0a2645b9706cce "pdflatex"
"MLPproject.tex" 1761920867.50658 24533 58032bad0234d994ba6556d7acc5212e ""
"MLPproject.toc" 1761920868.72456 1587 d275c5e85ba45c005c3baf7931c510a7 "pdflatex"
"MLPproject.aux" 1761921953.8967 6698 d2e044226fe88697053e22eec695a818 "pdflatex"
"MLPproject.out" 1761921953.8997 3113 d57c5f2b0e6699323b0a2645b9706cce "pdflatex"
"MLPproject.tex" 1761921952.70534 24812 36992a9467feb6ff9f9f97a89afe5aee ""
"MLPproject.toc" 1761921953.8997 1587 6a7d8c5cbfca28921bcd78f124e2ec7a "pdflatex"
"SelfArx.cls" 1761125830.98333 7316 506603b27aab6da8087bc0f1ee693041 ""
"featureImportanceDT.png" 1761403205.10917 60078 4a2e56e2a45ae2ae5e41b9830c1bbcea ""
"featureImportanceRF.png" 1761403205.11075 61794 6b3eefc625dd3da8a3dbf302174c614c ""
+3 -3
View File
@@ -1,4 +1,4 @@
This is pdfTeX, Version 3.141592653-2.6-1.40.25 (TeX Live 2023) (preloaded format=pdflatex 2025.10.22) 31 OCT 2025 15:27
This is pdfTeX, Version 3.141592653-2.6-1.40.25 (TeX Live 2023) (preloaded format=pdflatex 2025.10.22) 31 OCT 2025 15:45
entering extended mode
restricted \write18 enabled.
file:line:error style messages enabled.
@@ -726,9 +726,9 @@ Here is how much of TeX's memory you used:
38909 multiletter control sequences out of 15000+600000
569401 words of font info for 297 fonts, out of 8000000 for 9000
1137 hyphenation exceptions out of 8191
75i,12n,77p,1656b,605s stack positions out of 10000i,1000n,20000p,200000b,200000s
75i,12n,77p,1812b,605s stack positions out of 10000i,1000n,20000p,200000b,200000s
</usr/share/texlive/texmf-dist/fonts/type1/urw/helvetic/uhvb8a.pfb></usr/share/texlive/texmf-dist/fonts/type1/urw/helvetic/uhvr8a.pfb></usr/share/texlive/texmf-dist/fonts/type1/urw/helvetic/uhvro8a.pfb></usr/share/texlive/texmf-dist/fonts/type1/urw/times/utmr8a.pfb>
Output written on MLPproject.pdf (5 pages, 305630 bytes).
Output written on MLPproject.pdf (5 pages, 305913 bytes).
PDF statistics:
191 PDF objects out of 1000 (max. 8388607)
148 compressed objects within 2 object streams
Binary file not shown.
Binary file not shown.
+1 -1
View File
@@ -197,7 +197,7 @@ Table (\ref{dt_metrics}) and (\ref{rf_metrics}) shows the class-wise metrics of
At a first glance at both the confusion matricies and the performance metrics the models do not look to be that good. But what has to be considered is the data that we are analyzing. We are looking at what possible indicators there are for a person to earn more than a certain amount of money. This is real world data and in the real world there is a lot of unique ways of earning money. While there certainly are some indicators that will clearly tell that somebody is earning a lot of money, there are other factors that are not as telling. This means that some features are less important than others. This can be seen in our models in the feature importance graphs in figure(\ref{fig:featureImportanceDT}) and (\ref{fig:featureImportanceRF}). This also means that there will be plenty of outliers in the data. No matter how good the model is, it cannot possibly catch all of these outliers. If it did it would be overfitted. We simply cannot expect a model to have very good accuracy on this type of data set.
An important thing to touch on is the poor fit on higher-earning people by our model. We see that both models produce a precision of 77\% on the lower-earning individuals, which is quite bad compared to the precision of 87\% and 89\% on the higher-earning individuals. This means that out of all individuals predicted as higher-earning, only 77\% are correctly predicted. Even more notably, there is a very big discrepancy on the recall between the two classes. Recalls of 56\% and 63\% for the higher-earning class compared to 95\% and 94\% shows that out of all the higher-earning individuals, the models are not good at correctly detecting them as higher-earning. As we talked about above there may be many reasons for this poor fit. Of note is that we have optimized this model to find the best accuracy on all data point. We therefore stride to classify as many total data points correctly as possible and not on getting the best average for the classes separetly. Since there are more lower-earning people in our dataset it is very reasonable for the model to have optimised for that as well since it gives the best weighted accuracy. As previosly stated, the scoring metrics used for training the models should be adapted based on the problem at hand. If the problem requires similiar metrics across the classes, one should instead consider using scoring metrics such as balanced accuracy score, which are adapted to produce such results.
An important thing to touch on is the poor fit on higher-earning people by our model. We see that both models produce a precision of 77\% on the lower-earning individuals, which is quite bad compared to the precision of 87\% and 89\% on the higher-earning individuals. This means that out of all individuals predicted as higher-earning, only 77\% are correctly predicted. Even more notably, there is a very big discrepancy on the recall between the two classes. Recalls of 56\% and 63\% for the higher-earning class compared to 95\% and 94\% shows that out of all the higher-earning individuals, the models are not good at correctly detecting them as higher-earning. Additionally, the F1-score of both classes demonstrates the discrepancy of the overall performances across the classes. It shows that the harmonic average of precision and recall is significantly lower for the lower-earning individuals than for the higher earning individuals. As we talked about above there may be many reasons for this poor fit. Of note is that we have optimized this model to find the best accuracy on all data point. We therefore stride to classify as many total data points correctly as possible and not on getting the best average for the classes separetly. Since there are more lower-earning people in our dataset it is very reasonable for the model to have optimised for that as well since it gives the best weighted accuracy. As previosly stated, the scoring metrics used for training the models should be adapted based on the problem at hand. If the problem requires similiar metrics across the classes, one should instead consider using scoring metrics such as balanced accuracy score, which are adapted to produce such results.
\subsection{Overfitting and Underfitting}
We spent some time tuning the hyperparameters to ensure that we did not overfit. If we compare the validation results with the test results we see that the performance metrics do not change much at all. This is what we want to see as this means that we have avoidede overfitting the model. This means that our model could be used on other similar datasets and hopefully give similar perfomances. We also do not want our model to be underfit. This is a bit harder to validate as we want the errors to be as small as possible for both training and testing and as we stated before I believe that this is a difficult dataaset to get a great fit to. Therefore we believe that we have found a model that has a decent enough balance between bias and variance.
+1 -1
View File
@@ -16,5 +16,5 @@
\contentsline {subsection}{\numberline {5.3}Analyzing the Performance}{4}{subsection.5.3}%
\contentsline {subsection}{\numberline {5.4}Overfitting and Underfitting}{4}{subsection.5.4}%
\contentsline {subsection}{\numberline {5.5}Feature Importance}{4}{subsection.5.5}%
\contentsline {section}{\numberline {6}Summary}{4}{section.6}%
\contentsline {section}{\numberline {6}Summary}{5}{section.6}%
\contentsfinish
BIN
View File
Binary file not shown.