Skip to content

Commit

Permalink
Fix improve allergy discrimination
Browse files Browse the repository at this point in the history
  • Loading branch information
victorc365 committed Oct 9, 2023
1 parent 23bf6e4 commit 0dda6cb
Show file tree
Hide file tree
Showing 5 changed files with 17,208 additions and 22,042 deletions.
319 changes: 319 additions & 0 deletions src/generator_notebook.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -130570,6 +130570,325 @@
"source": [
"simulation_results"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
"recipes = pd.read_csv(\"recipes/processed_recipes_dataset.csv\", sep='|')"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0 False\n",
"1 False\n",
"2 False\n",
"3 False\n",
"4 False\n",
" ... \n",
"10195 False\n",
"10196 False\n",
"10197 False\n",
"10198 False\n",
"10199 False\n",
"Name: title, Length: 10200, dtype: bool"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"recipes['title'].duplicated()"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
"recipes = recipes.drop_duplicates(subset=['title'], keep='first')"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(8451, 6)"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"recipes.shape"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [],
"source": [
"recipes.reset_index(drop=True, inplace=True)"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [],
"source": [
"recipes.loc[:, \"recipeId\"] = [f\"food_{i}\" for i in range(0, len(recipes))]"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [],
"source": [
"recipes.to_csv(\"recipes/processed_recipes_dataset_id.csv\", sep='|')"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'a': 1, 'b': 2}"
]
},
"execution_count": 25,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"{x:y for x, y in {'a': 1, 'b': 2}.items()}"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [
{
"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>title</th>\n",
" <th>raw_text</th>\n",
" <th>meal_type</th>\n",
" <th>cultural_restriction</th>\n",
" <th>calories</th>\n",
" <th>allergies</th>\n",
" <th>recipeId</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Fruit Salad</td>\n",
" <td>1. Fruit Salad: 70 calories per portion, 4 por...</td>\n",
" <td>breakfast</td>\n",
" <td>vegan</td>\n",
" <td>70.0</td>\n",
" <td>contains fruits only</td>\n",
" <td>food_0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>Vegan Pancakes</td>\n",
" <td>2. Vegan Pancakes: 150 calories per portion, 4...</td>\n",
" <td>breakfast</td>\n",
" <td>vegan</td>\n",
" <td>150.0</td>\n",
" <td>NaN</td>\n",
" <td>food_1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>Overnight Chia Pudding</td>\n",
" <td>3. Overnight Chia Pudding: 200 calories per po...</td>\n",
" <td>breakfast</td>\n",
" <td>vegan</td>\n",
" <td>200.0</td>\n",
" <td>contains nuts (almonds)</td>\n",
" <td>food_2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>Avocado Toast</td>\n",
" <td>4. Avocado Toast: 250 calories per portion, 2 ...</td>\n",
" <td>breakfast</td>\n",
" <td>vegan</td>\n",
" <td>250.0</td>\n",
" <td>NaN</td>\n",
" <td>food_3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>Vegan Omelette</td>\n",
" <td>5. Vegan Omelette: 300 calories per portion, 1...</td>\n",
" <td>breakfast</td>\n",
" <td>vegan</td>\n",
" <td>300.0</td>\n",
" <td>contains chickpea flour</td>\n",
" <td>food_4</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8446</th>\n",
" <td>Mexican stuffed bell peppers with ground beef...</td>\n",
" <td>96. Mexican stuffed bell peppers with ground b...</td>\n",
" <td>dinner</td>\n",
" <td>NaN</td>\n",
" <td>450.0</td>\n",
" <td>contains lactose</td>\n",
" <td>food_8446</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8447</th>\n",
" <td>Caprese quinoa salad with grilled chicken - 3...</td>\n",
" <td>97. Caprese quinoa salad with grilled chicken ...</td>\n",
" <td>dinner</td>\n",
" <td>NaN</td>\n",
" <td>350.0</td>\n",
" <td>contains lactose</td>\n",
" <td>food_8447</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8448</th>\n",
" <td>Baked coconut shrimp with mango salsa and jas...</td>\n",
" <td>98. Baked coconut shrimp with mango salsa and ...</td>\n",
" <td>dinner</td>\n",
" <td>NaN</td>\n",
" <td>420.0</td>\n",
" <td>contains shellfish</td>\n",
" <td>food_8448</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8449</th>\n",
" <td>One-pot creamy chicken and mushroom pasta - 4...</td>\n",
" <td>99. One-pot creamy chicken and mushroom pasta ...</td>\n",
" <td>dinner</td>\n",
" <td>NaN</td>\n",
" <td>480.0</td>\n",
" <td>contains gluten</td>\n",
" <td>food_8449</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8450</th>\n",
" <td>Stuffed bell peppers with couscous, chickpeas...</td>\n",
" <td>100. Stuffed bell peppers with couscous, chick...</td>\n",
" <td>dinner</td>\n",
" <td>NaN</td>\n",
" <td>350.0</td>\n",
" <td>contains lactose</td>\n",
" <td>food_8450</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>8451 rows × 7 columns</p>\n",
"</div>"
],
"text/plain": [
" title \\\n",
"0 Fruit Salad \n",
"1 Vegan Pancakes \n",
"2 Overnight Chia Pudding \n",
"3 Avocado Toast \n",
"4 Vegan Omelette \n",
"... ... \n",
"8446 Mexican stuffed bell peppers with ground beef... \n",
"8447 Caprese quinoa salad with grilled chicken - 3... \n",
"8448 Baked coconut shrimp with mango salsa and jas... \n",
"8449 One-pot creamy chicken and mushroom pasta - 4... \n",
"8450 Stuffed bell peppers with couscous, chickpeas... \n",
"\n",
" raw_text meal_type \\\n",
"0 1. Fruit Salad: 70 calories per portion, 4 por... breakfast \n",
"1 2. Vegan Pancakes: 150 calories per portion, 4... breakfast \n",
"2 3. Overnight Chia Pudding: 200 calories per po... breakfast \n",
"3 4. Avocado Toast: 250 calories per portion, 2 ... breakfast \n",
"4 5. Vegan Omelette: 300 calories per portion, 1... breakfast \n",
"... ... ... \n",
"8446 96. Mexican stuffed bell peppers with ground b... dinner \n",
"8447 97. Caprese quinoa salad with grilled chicken ... dinner \n",
"8448 98. Baked coconut shrimp with mango salsa and ... dinner \n",
"8449 99. One-pot creamy chicken and mushroom pasta ... dinner \n",
"8450 100. Stuffed bell peppers with couscous, chick... dinner \n",
"\n",
" cultural_restriction calories allergies recipeId \n",
"0 vegan 70.0 contains fruits only food_0 \n",
"1 vegan 150.0 NaN food_1 \n",
"2 vegan 200.0 contains nuts (almonds) food_2 \n",
"3 vegan 250.0 NaN food_3 \n",
"4 vegan 300.0 contains chickpea flour food_4 \n",
"... ... ... ... ... \n",
"8446 NaN 450.0 contains lactose food_8446 \n",
"8447 NaN 350.0 contains lactose food_8447 \n",
"8448 NaN 420.0 contains shellfish food_8448 \n",
"8449 NaN 480.0 contains gluten food_8449 \n",
"8450 NaN 350.0 contains lactose food_8450 \n",
"\n",
"[8451 rows x 7 columns]"
]
},
"execution_count": 26,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"recipes"
]
}
],
"metadata": {
Expand Down
23 changes: 7 additions & 16 deletions src/main_generator_notebook.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,9 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The autoreload extension is already loaded. To reload it, use:\n",
" %reload_ext autoreload\n"
]
}
],
"outputs": [],
"source": [
"%load_ext autoreload\n",
"%autoreload 2\n",
Expand All @@ -48,15 +39,15 @@
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": 2,
"metadata": {
"scrolled": false
},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "c669d7f3d67143ba988ff8ea2b9a9034",
"model_id": "33f29876d0d44dc7b14e1684d50b5c9e",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -70,7 +61,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "339f144c68394d0d9499b718b09f4faa",
"model_id": "d88df22daeba452ea2ab7160133890f4",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -84,7 +75,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "90a6132e8a5f44b7a71a397cab84267b",
"model_id": "dc9afcf07fe94d7cbef03a97256da37b",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -98,7 +89,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "1f638ca7da764cb09cac8e40a99c13a6",
"model_id": "1b1a5aca7f1d4e798b34b5621b8d7138",
"version_major": 2,
"version_minor": 0
},
Expand Down
Loading

0 comments on commit 0dda6cb

Please sign in to comment.