@ -16,7 +16,7 @@
},
{
"cell_type": "code",
"execution_count": 6 ,
"execution_count": 1 ,
"metadata": {},
"outputs": [
{
@ -214,7 +214,7 @@
"[5 rows x 382 columns]"
]
},
"execution_count": 6 ,
"execution_count": 1 ,
"metadata": {},
"output_type": "execute_result"
}
@ -227,7 +227,7 @@
},
{
"cell_type": "code",
"execution_count": 7 ,
"execution_count": 2 ,
"metadata": {},
"outputs": [],
"source": [
@ -240,7 +240,7 @@
},
{
"cell_type": "code",
"execution_count": 9 ,
"execution_count": 3 ,
"metadata": {},
"outputs": [
{
@ -254,7 +254,7 @@
"Name: cuisine, dtype: object"
]
},
"execution_count": 9 ,
"execution_count": 3 ,
"metadata": {},
"output_type": "execute_result"
}
@ -266,7 +266,7 @@
},
{
"cell_type": "code",
"execution_count": 11 ,
"execution_count": 4 ,
"metadata": {},
"outputs": [
{
@ -464,7 +464,7 @@
"[5 rows x 380 columns]"
]
},
"execution_count": 11 ,
"execution_count": 4 ,
"metadata": {},
"output_type": "execute_result"
}
@ -476,7 +476,7 @@
},
{
"cell_type": "code",
"execution_count": 12 ,
"execution_count": 5 ,
"metadata": {},
"outputs": [],
"source": [
@ -485,7 +485,7 @@
},
{
"cell_type": "code",
"execution_count": 15 ,
"execution_count": 6 ,
"metadata": {},
"outputs": [
{
@ -513,7 +513,7 @@
},
{
"cell_type": "code",
"execution_count": 18 ,
"execution_count": 7 ,
"metadata": {},
"outputs": [
{
@ -529,6 +529,121 @@
"print(f'ingredients: {X_test.iloc[50][X_test.iloc[50]!=0].keys()}')\n",
"print(f'cuisine: {y_test.iloc[50]}')"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/workspaces/ML-For-Beginners/.venv/lib/python3.11/site-packages/sklearn/utils/validation.py:2739: UserWarning: X does not have valid feature names, but LogisticRegression was fitted with feature names\n",
" warnings.warn(\n"
]
},
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>0</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>thai</th>\n",
" <td>0.839568</td>\n",
" </tr>\n",
" <tr>\n",
" <th>japanese</th>\n",
" <td>0.134624</td>\n",
" </tr>\n",
" <tr>\n",
" <th>chinese</th>\n",
" <td>0.014531</td>\n",
" </tr>\n",
" <tr>\n",
" <th>korean</th>\n",
" <td>0.008383</td>\n",
" </tr>\n",
" <tr>\n",
" <th>indian</th>\n",
" <td>0.002894</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" 0\n",
"thai 0.839568\n",
"japanese 0.134624\n",
"chinese 0.014531\n",
"korean 0.008383\n",
"indian 0.002894"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"test= X_test.iloc[50].values.reshape(-1, 1).T\n",
"proba = model.predict_proba(test)\n",
"classes = model.classes_\n",
"resultdf = pd.DataFrame(data=proba, columns=classes)\n",
"\n",
"topPrediction = resultdf.T.sort_values(by=[0], ascending = [False])\n",
"topPrediction.head()"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" precision recall f1-score support\n",
"\n",
" chinese 0.69 0.69 0.69 236\n",
" indian 0.91 0.91 0.91 245\n",
" japanese 0.73 0.72 0.73 231\n",
" korean 0.81 0.76 0.78 242\n",
" thai 0.78 0.84 0.81 245\n",
"\n",
" accuracy 0.79 1199\n",
" macro avg 0.79 0.78 0.78 1199\n",
"weighted avg 0.79 0.79 0.79 1199\n",
"\n"
]
}
],
"source": [
"y_pred = model.predict(X_test)\n",
"print(classification_report(y_test, y_pred))"
]
}
],
"metadata": {