added f1 score
parent
06b862b1a1
commit
2f89518bbf
File diff suppressed because one or more lines are too long
|
@ -9,7 +9,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 36,
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
|
@ -20,10 +20,9 @@
|
|||
"import matplotlib.pyplot as plt\n",
|
||||
"import xgboost as xgb\n",
|
||||
"from sklearn.model_selection import GridSearchCV\n",
|
||||
"from sklearn.metrics import confusion_matrix\n",
|
||||
"from sklearn.impute import SimpleImputer\n",
|
||||
"from sklearn.preprocessing import MinMaxScaler\n",
|
||||
"import seaborn as sns"
|
||||
"from sklearn.metrics import confusion_matrix, f1_score\n",
|
||||
"import seaborn as sns\n",
|
||||
"import numpy as np"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -35,7 +34,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"execution_count": 7,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
|
@ -59,7 +58,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 42,
|
||||
"execution_count": 8,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
|
@ -337,7 +336,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 43,
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
|
@ -362,14 +361,14 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 44,
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"[20:16:51] WARNING: C:/Users/administrator/workspace/xgboost-win64_release_1.6.0/src/learner.cc:627: \n",
|
||||
"[16:58:49] WARNING: C:/Users/administrator/workspace/xgboost-win64_release_1.6.0/src/learner.cc:627: \n",
|
||||
"Parameters: { \"best_iteration\", \"best_ntree_limit\", \"scikit_learn\" } might not be used.\n",
|
||||
"\n",
|
||||
" This could be a false alarm, with some parameters getting used by language bindings but\n",
|
||||
|
@ -377,13 +376,7 @@
|
|||
" but getting flagged wrongly here. Please open an issue if you find any such cases.\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"[0]\ttrain-merror:0.16762\teval-merror:0.22603\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"[0]\ttrain-merror:0.16762\teval-merror:0.22603\n",
|
||||
"[1]\ttrain-merror:0.15220\teval-merror:0.22374\n",
|
||||
"[2]\ttrain-merror:0.13849\teval-merror:0.21461\n",
|
||||
"[3]\ttrain-merror:0.13535\teval-merror:0.20776\n",
|
||||
|
@ -483,8 +476,8 @@
|
|||
"[97]\ttrain-merror:0.00029\teval-merror:0.18265\n",
|
||||
"[98]\ttrain-merror:0.00029\teval-merror:0.18265\n",
|
||||
"[99]\ttrain-merror:0.00029\teval-merror:0.18265\n",
|
||||
"CPU times: total: 17.6 s\n",
|
||||
"Wall time: 1.36 s\n"
|
||||
"CPU times: total: 14.3 s\n",
|
||||
"Wall time: 1.22 s\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
@ -506,7 +499,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 45,
|
||||
"execution_count": 10,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
|
@ -546,7 +539,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 46,
|
||||
"execution_count": 11,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
|
@ -577,7 +570,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 31,
|
||||
"execution_count": 12,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
|
@ -609,7 +602,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 19,
|
||||
"execution_count": 13,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
|
@ -618,7 +611,7 @@
|
|||
"<AxesSubplot:title={'center':'Feature importance'}, xlabel='F score', ylabel='Features'>"
|
||||
]
|
||||
},
|
||||
"execution_count": 19,
|
||||
"execution_count": 13,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
},
|
||||
|
@ -640,7 +633,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 27,
|
||||
"execution_count": 14,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
|
@ -679,6 +672,26 @@
|
|||
"plt.tight_layout()\n",
|
||||
"plt.show()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 29,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"F1 Score: 0.8157211953487169\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# Calculate F1 Score for multiclass classification\n",
|
||||
"f1 = f1_score(test_y, preds, average='macro')\n",
|
||||
"\n",
|
||||
"print('F1 Score:', f1)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
|
|
Loading…
Reference in New Issue