Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "imperial-rebound",
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"import numpy as np\n",
"import warnings\n",
"warnings.filterwarnings('ignore')\n",
"\n",
"#train_df = pd.read_csv(\"C:\\\\Users\\\\USER\\\\Desktop\\\\recipes.csv\")\n",
"newDf = pd.read_csv(\"C:\\\\Users\\\\USER\\\\Desktop\\\\recipes.csv\")\n",
"reviewDf = pd.read_csv(\"C:\\\\Users\\\\USER\\\\Desktop\\\\reviews.csv\")\n",
"\n",
"\n",
"\n",
"train_df = pd.read_csv(\"C:\\\\Users\\\\USER\\\\Desktop\\\\recipes.csv\")\n",
"# train_df.dropna(how = 'all', inplace = True)\n",
"newDf2 = train_df.dropna()"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "healthy-senator",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(522517, 28)"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"newDf.shape"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "royal-glory",
"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>RecipeId</th>\n",
" <th>Name</th>\n",
" <th>AuthorId</th>\n",
" <th>AuthorName</th>\n",
" <th>CookTime</th>\n",
" <th>PrepTime</th>\n",
" <th>TotalTime</th>\n",
" <th>DatePublished</th>\n",
" <th>Description</th>\n",
" <th>Images</th>\n",
" <th>...</th>\n",
" <th>SaturatedFatContent</th>\n",
" <th>CholesterolContent</th>\n",
" <th>SodiumContent</th>\n",
" <th>CarbohydrateContent</th>\n",
" <th>FiberContent</th>\n",
" <th>SugarContent</th>\n",
" <th>ProteinContent</th>\n",
" <th>RecipeServings</th>\n",
" <th>RecipeYield</th>\n",
" <th>RecipeInstructions</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>522512</th>\n",
" <td>541379</td>\n",
" <td>Meg's Fresh Ginger Gingerbread</td>\n",
" <td>2002090414</td>\n",
" <td>rdsxc</td>\n",
" <td>PT35M</td>\n",
" <td>PT1H</td>\n",
" <td>PT1H35M</td>\n",
" <td>2020-12-22T15:27:00Z</td>\n",
" <td>Make and share this Meg's Fresh Ginger Gingerb...</td>\n",
" <td>character(0)</td>\n",
" <td>...</td>\n",
" <td>7.6</td>\n",
" <td>54.4</td>\n",
" <td>278.2</td>\n",
" <td>48.5</td>\n",
" <td>0.8</td>\n",
" <td>22.8</td>\n",
" <td>3.9</td>\n",
" <td>8.0</td>\n",
" <td>1 8x8 cake pan</td>\n",
" <td>c(\"Preheat oven to 350&amp;deg;F Grease an 8x8 cak...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>522513</th>\n",
" <td>541380</td>\n",
" <td>Roast Prime Rib au Poivre with Mixed Peppercorns</td>\n",
" <td>211566</td>\n",
" <td>Denver cooks</td>\n",
" <td>PT3H</td>\n",
" <td>PT30M</td>\n",
" <td>PT3H30M</td>\n",
" <td>2020-12-22T15:32:00Z</td>\n",
" <td>White, black, green, and pink peppercorns add ...</td>\n",
" <td>\"https://img.sndimg.com/food/image/upload/w_55...</td>\n",
" <td>...</td>\n",
" <td>71.4</td>\n",
" <td>433.8</td>\n",
" <td>766.3</td>\n",
" <td>3.2</td>\n",
" <td>0.7</td>\n",
" <td>0.1</td>\n",
" <td>117.0</td>\n",
" <td>8.0</td>\n",
" <td>1 Roast</td>\n",
" <td>c(\"Position rack in center of oven and preheat...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>522514</th>\n",
" <td>541381</td>\n",
" <td>Kirshwasser Ice Cream</td>\n",
" <td>2001131545</td>\n",
" <td>Jonathan F.</td>\n",
" <td>PT3H</td>\n",
" <td>PT1H</td>\n",
" <td>PT4H</td>\n",
" <td>2020-12-22T15:33:00Z</td>\n",
" <td>Make and share this Kirshwasser Ice Cream reci...</td>\n",
" <td>character(0)</td>\n",
" <td>...</td>\n",
" <td>72.6</td>\n",
" <td>470.9</td>\n",
" <td>192.5</td>\n",
" <td>33.9</td>\n",
" <td>0.0</td>\n",
" <td>17.3</td>\n",
" <td>12.8</td>\n",
" <td>6.0</td>\n",
" <td>NaN</td>\n",
" <td>c(\"heat half and half and heavy cream to a sim...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>522515</th>\n",
" <td>541382</td>\n",
" <td>Quick &amp; Easy Asian Cucumber Salmon Rolls</td>\n",
" <td>2001004241</td>\n",
" <td>CLUBFOODY</td>\n",
" <td>NaN</td>\n",
" <td>PT15M</td>\n",
" <td>PT15M</td>\n",
" <td>2020-12-22T22:11:00Z</td>\n",
" <td>Extremely quick and easy to make, these are gr...</td>\n",
" <td>\"https://img.sndimg.com/food/image/upload/w_55...</td>\n",
" <td>...</td>\n",
" <td>0.1</td>\n",
" <td>2.9</td>\n",
" <td>100.5</td>\n",
" <td>0.3</td>\n",
" <td>0.0</td>\n",
" <td>0.1</td>\n",
" <td>2.4</td>\n",
" <td>NaN</td>\n",
" <td>20 rolls</td>\n",
" <td>c(\"In a small bowl, combine mayo and wasabi pa...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>522516</th>\n",
" <td>541383</td>\n",
" <td>Spicy Baked Scotch Eggs</td>\n",
" <td>188099</td>\n",
" <td>Chef LauraMD</td>\n",
" <td>PT25M</td>\n",
" <td>PT15M</td>\n",
" <td>PT40M</td>\n",
" <td>2020-12-22T22:12:00Z</td>\n",
" <td>Great way to have hard boiled eggs and crispy,...</td>\n",
" <td>character(0)</td>\n",
" <td>...</td>\n",
" <td>22.2</td>\n",
" <td>1769.7</td>\n",
" <td>1318.6</td>\n",
" <td>29.7</td>\n",
" <td>1.3</td>\n",
" <td>6.7</td>\n",
" <td>76.4</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>c(\"Mix sausage, panko, egg yolk and Wocestersh...</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>5 rows × 28 columns</p>\n",
"</div>"
],
"text/plain": [
" RecipeId Name \\\n",
"522512 541379 Meg's Fresh Ginger Gingerbread \n",
"522513 541380 Roast Prime Rib au Poivre with Mixed Peppercorns \n",
"522514 541381 Kirshwasser Ice Cream \n",
"522515 541382 Quick & Easy Asian Cucumber Salmon Rolls \n",
"522516 541383 Spicy Baked Scotch Eggs \n",
"\n",
" AuthorId AuthorName CookTime PrepTime TotalTime \\\n",
"522512 2002090414 rdsxc PT35M PT1H PT1H35M \n",
"522513 211566 Denver cooks PT3H PT30M PT3H30M \n",
"522514 2001131545 Jonathan F. PT3H PT1H PT4H \n",
"522515 2001004241 CLUBFOODY NaN PT15M PT15M \n",
"522516 188099 Chef LauraMD PT25M PT15M PT40M \n",
"\n",
" DatePublished \\\n",
"522512 2020-12-22T15:27:00Z \n",
"522513 2020-12-22T15:32:00Z \n",
"522514 2020-12-22T15:33:00Z \n",
"522515 2020-12-22T22:11:00Z \n",
"522516 2020-12-22T22:12:00Z \n",
"\n",
" Description \\\n",
"522512 Make and share this Meg's Fresh Ginger Gingerb... \n",
"522513 White, black, green, and pink peppercorns add ... \n",
"522514 Make and share this Kirshwasser Ice Cream reci... \n",
"522515 Extremely quick and easy to make, these are gr... \n",
"522516 Great way to have hard boiled eggs and crispy,... \n",
"\n",
" Images ... \\\n",
"522512 character(0) ... \n",
"522513 \"https://img.sndimg.com/food/image/upload/w_55... ... \n",
"522514 character(0) ... \n",
"522515 \"https://img.sndimg.com/food/image/upload/w_55... ... \n",
"522516 character(0) ... \n",
"\n",
" SaturatedFatContent CholesterolContent SodiumContent \\\n",
"522512 7.6 54.4 278.2 \n",
"522513 71.4 433.8 766.3 \n",
"522514 72.6 470.9 192.5 \n",
"522515 0.1 2.9 100.5 \n",
"522516 22.2 1769.7 1318.6 \n",
"\n",
" CarbohydrateContent FiberContent SugarContent ProteinContent \\\n",
"522512 48.5 0.8 22.8 3.9 \n",
"522513 3.2 0.7 0.1 117.0 \n",
"522514 33.9 0.0 17.3 12.8 \n",
"522515 0.3 0.0 0.1 2.4 \n",
"522516 29.7 1.3 6.7 76.4 \n",
"\n",
" RecipeServings RecipeYield \\\n",
"522512 8.0 1 8x8 cake pan \n",
"522513 8.0 1 Roast \n",
"522514 6.0 NaN \n",
"522515 NaN 20 rolls \n",
"522516 NaN NaN \n",
"\n",
" RecipeInstructions \n",
"522512 c(\"Preheat oven to 350&deg;F Grease an 8x8 cak... \n",
"522513 c(\"Position rack in center of oven and preheat... \n",
"522514 c(\"heat half and half and heavy cream to a sim... \n",
"522515 c(\"In a small bowl, combine mayo and wasabi pa... \n",
"522516 c(\"Mix sausage, panko, egg yolk and Wocestersh... \n",
"\n",
"[5 rows x 28 columns]"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"newDf.tail()"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "caring-sharing",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" RecipeId Name\n",
"0 38 Low-Fat Berry Blue Frozen Dessert\n",
"1 39 Biryani\n",
"2 40 Best Lemonade\n",
"3 41 Carina's Tofu-Vegetable Kebabs\n",
"4 42 Cabbage Soup\n",
"... ... ...\n",
"522512 541379 Meg's Fresh Ginger Gingerbread\n",
"522513 541380 Roast Prime Rib au Poivre with Mixed Peppercorns\n",
"522514 541381 Kirshwasser Ice Cream\n",
"522515 541382 Quick & Easy Asian Cucumber Salmon Rolls\n",
"522516 541383 Spicy Baked Scotch Eggs\n",
"\n",
"[522517 rows x 2 columns]\n",
"[[39 'Biryani']\n",
" [40 'Best Lemonade']\n",
" [41 \"Carina's Tofu-Vegetable Kebabs\"]\n",
" [42 'Cabbage Soup']]\n",
"<class 'numpy.ndarray'>\n"
]
}
],
"source": [
"#newDf = newDf[['Name','AggregatedRating','ReviewCount']]\n",
"newDf = newDf[['RecipeId','Name']]\n",
"#newDf = newDf.rename(columns={'AggregatedRating': 'rating'})\n",
"\n",
"print(newDf)\n",
"\n",
"print(newDf.values[1:5])\n",
"print(type(newDf.values))"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "falling-tribune",
"metadata": {},
"outputs": [],
"source": [
"#Y = newDf.iloc[:,1].values\n",
"#x2 = newDf.iloc[:,2:12].values"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "destroyed-value",
"metadata": {},
"outputs": [],
"source": [
"#newDf.sort_values('ReviewCount', ascending=False).head(10)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "coordinated-speaker",
"metadata": {},
"outputs": [],
"source": [
"reviewDf = reviewDf[['AuthorId','RecipeId','Rating']]\n",
"\n",
"#reviewDf = reviewDf.rename(columns={'AuthorId': 'UserId'})\n",
"#newDf = newDf.rename(columns={'AggregatedRating': 'rating'})"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "under-services",
"metadata": {},
"outputs": [],
"source": [
"\n",
"mergeDf= pd.merge(newDf,reviewDf, on='RecipeId')"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "hollywood-stock",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" RecipeId Name \\\n",
"0 38 Low-Fat Berry Blue Frozen Dessert \n",
"1 38 Low-Fat Berry Blue Frozen Dessert \n",
"2 38 Low-Fat Berry Blue Frozen Dessert \n",
"3 38 Low-Fat Berry Blue Frozen Dessert \n",
"4 39 Biryani \n",
"... ... ... \n",
"1401958 540899 Butter Pecan Banana Muffins \n",
"1401959 541001 Homemade Adobo Seasoning \n",
"1401960 541030 Everything but the Bagel Seasoning (Trader Joe... \n",
"1401961 541195 The Most Refreshing Lemonade \n",
"1401962 541298 Homemade Ketchup \n",
"\n",
" AuthorId Rating \n",
"0 596506 5 \n",
"1 1060485 4 \n",
"2 1802956262 4 \n",
"3 2123645 4 \n",
"4 393254 3 \n",
"... ... ... \n",
"1401958 2002811014 5 \n",
"1401959 2000325639 0 \n",
"1401960 266635 5 \n",
"1401961 2002851186 5 \n",
"1401962 2002851186 5 \n",
"\n",
"[1401963 rows x 4 columns]\n"
]
}
],
"source": [
"print(mergeDf)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "billion-happiness",
"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>Name</th>\n",
" <th>&amp;quot;21&amp;quot; Apple Pie</th>\n",
" <th>A Jad - Cucumber Pickle</th>\n",
" <th>A New Spaghetti with Clams</th>\n",
" <th>Abby's Pecan Apple Cake</th>\n",
" <th>Alfredo Sauce</th>\n",
" <th>All Purpose Quick Mix With 28 Variations</th>\n",
" <th>All-Purpose Crock Pot Chicken</th>\n",
" <th>Almond Fudge Banana Cake</th>\n",
" <th>Almond Joy Cake</th>\n",
" <th>Almond Paste</th>\n",
" <th>...</th>\n",
" <th>Chicken on Sunday (Or Whenever)</th>\n",
" <th>Coconut Shrimp With Orange Mustard Sauce</th>\n",
" <th>Cold Celery</th>\n",
" <th>Commissary Carrot Cake</th>\n",
" <th>Jimmy G's Carrot Cake</th>\n",
" <th>Light Cucumber Soup</th>\n",
" <th>Lou's Fabulous Bruschetta</th>\n",
" <th>Low-Fat Berry Blue Frozen Dessert</th>\n",
" <th>Low-Fat Burgundy Beef &amp; Vegetable Stew</th>\n",
" <th>Warm Chicken A La King</th>\n",
" </tr>\n",
" <tr>\n",
" <th>AuthorId</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>1535</th>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>...</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2085</th>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>...</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>5.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2156</th>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>...</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2312</th>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>...</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2369</th>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>...</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>5 rows × 101 columns</p>\n",
"</div>"
],
"text/plain": [
"Name &quot;21&quot; Apple Pie A Jad - Cucumber Pickle \\\n",
"AuthorId \n",
"1535 0.0 0.0 \n",
"2085 0.0 0.0 \n",
"2156 0.0 0.0 \n",
"2312 0.0 0.0 \n",
"2369 0.0 0.0 \n",
"\n",
"Name A New Spaghetti with Clams Abby's Pecan Apple Cake Alfredo Sauce \\\n",
"AuthorId \n",
"1535 0.0 0.0 0.0 \n",
"2085 0.0 0.0 0.0 \n",
"2156 0.0 0.0 0.0 \n",
"2312 0.0 0.0 0.0 \n",
"2369 0.0 0.0 0.0 \n",
"\n",
"Name All Purpose Quick Mix With 28 Variations \\\n",
"AuthorId \n",
"1535 0.0 \n",
"2085 0.0 \n",
"2156 0.0 \n",
"2312 0.0 \n",
"2369 0.0 \n",
"\n",
"Name All-Purpose Crock Pot Chicken Almond Fudge Banana Cake \\\n",
"AuthorId \n",
"1535 0.0 0.0 \n",
"2085 0.0 0.0 \n",
"2156 0.0 0.0 \n",
"2312 0.0 0.0 \n",
"2369 0.0 0.0 \n",
"\n",
"Name Almond Joy Cake Almond Paste ... \\\n",
"AuthorId ... \n",
"1535 0.0 0.0 ... \n",
"2085 0.0 0.0 ... \n",
"2156 0.0 0.0 ... \n",
"2312 0.0 0.0 ... \n",
"2369 0.0 0.0 ... \n",
"\n",
"Name Chicken on Sunday (Or Whenever) \\\n",
"AuthorId \n",
"1535 0.0 \n",
"2085 0.0 \n",
"2156 0.0 \n",
"2312 0.0 \n",
"2369 0.0 \n",
"\n",
"Name Coconut Shrimp With Orange Mustard Sauce Cold Celery \\\n",
"AuthorId \n",
"1535 0.0 0.0 \n",
"2085 0.0 0.0 \n",
"2156 0.0 0.0 \n",
"2312 0.0 0.0 \n",
"2369 0.0 0.0 \n",
"\n",
"Name Commissary Carrot Cake Jimmy G's Carrot Cake Light Cucumber Soup \\\n",
"AuthorId \n",
"1535 0.0 0.0 0.0 \n",
"2085 0.0 0.0 0.0 \n",
"2156 0.0 0.0 0.0 \n",
"2312 0.0 0.0 0.0 \n",
"2369 0.0 0.0 0.0 \n",
"\n",
"Name Lou's Fabulous Bruschetta Low-Fat Berry Blue Frozen Dessert \\\n",
"AuthorId \n",
"1535 0.0 0.0 \n",
"2085 0.0 0.0 \n",
"2156 0.0 0.0 \n",
"2312 0.0 0.0 \n",
"2369 0.0 0.0 \n",
"\n",
"Name Low-Fat Burgundy Beef & Vegetable Stew Warm Chicken A La King \n",
"AuthorId \n",
"1535 0.0 0.0 \n",
"2085 0.0 5.0 \n",
"2156 0.0 0.0 \n",
"2312 0.0 0.0 \n",
"2369 0.0 0.0 \n",
"\n",
"[5 rows x 101 columns]"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#reviewDfcut=reviewDf.head(15000)\n",
"#reviewDf_UII= reviewDfcut.pivot_table(index='ReviewId',columns='RecipeId',values='Rating')\n",
"#reviewDf_UII.head(1000)\n",
"\n",
"mergeDf=mergeDf.head(1000)\n",
"\n",
"mergeDf_UII=mergeDf.pivot_table(index='AuthorId',columns='Name',values='Rating').fillna(0)\n",
"mergeDf_UII.head()"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "referenced-blond",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"AuthorId\n",
"1535 0.0\n",
"2085 5.0\n",
"2156 0.0\n",
"2312 0.0\n",
"2369 0.0\n",
" ... \n",
"2002276917 0.0\n",
"2002278504 0.0\n",
"2002350599 0.0\n",
"2002420555 0.0\n",
"2002628678 0.0\n",
"Name: Warm Chicken A La King, Length: 919, dtype: float64"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#fecthing ratings for Biryani\n",
"#biryani_user_rating=reviewDf['539304']\n",
"#reviewDfcut.tail()\n",
"#reviewDfcut = reviewDfcut.rename(columns={'Rating': 'rating'})\n",
"\n",
"recipe_rating= mergeDf_UII['Warm Chicken A La King']\n",
"\n",
"recipe_rating"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "aggregate-school",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(919, 101)"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"mergeDf_UII.shape"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "textile-chrome",
"metadata": {},
"outputs": [],
"source": [
"#fetching briani\n",
"#briani = reviewDf_UII.loc[reviewDf_UII['RecipeId']==44\n",
"\n",
"#print(reviewDf_UII[reviewDf_UII['RecipeId']==44]\n",
" \n",
"#briani = reviewDfcut.loc[reviewDfcut['RecipeId']==44]\n",
"\n",
"#briani = briani[['rating']]\n",
"\n",
"#print(briani)\n",
"\n",
"same_as_recipe=mergeDf_UII.corrwith(recipe_rating)"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "selected-insured",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Name\n",
"&quot;21&quot; Apple Pie -0.005016\n",
"A Jad - Cucumber Pickle -0.007098\n",
"A New Spaghetti with Clams -0.005016\n",
"Abby's Pecan Apple Cake -0.006885\n",
"Alfredo Sauce -0.057802\n",
"dtype: float64"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"same_as_recipe.head()"
]
},
{
"cell_type": "markdown",
"id": "outdoor-leonard",
"metadata": {},
"source": [
"### Minimum threshold for minimum number of ratings"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "expanded-newfoundland",
"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>Correlation</th>\n",
" </tr>\n",
" <tr>\n",
" <th>Name</th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>&amp;quot;21&amp;quot; Apple Pie</th>\n",
" <td>-0.005016</td>\n",
" </tr>\n",
" <tr>\n",
" <th>A Jad - Cucumber Pickle</th>\n",
" <td>-0.007098</td>\n",
" </tr>\n",
" <tr>\n",
" <th>A New Spaghetti with Clams</th>\n",
" <td>-0.005016</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Abby's Pecan Apple Cake</th>\n",
" <td>-0.006885</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Alfredo Sauce</th>\n",
" <td>-0.057802</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Correlation\n",
"Name \n",
"&quot;21&quot; Apple Pie -0.005016\n",
"A Jad - Cucumber Pickle -0.007098\n",
"A New Spaghetti with Clams -0.005016\n",
"Abby's Pecan Apple Cake -0.006885\n",
"Alfredo Sauce -0.057802"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#crating dataframe to bring in #of rating\n",
"corr_recipe = pd.DataFrame(same_as_recipe, columns= ['Correlation'])\n",
"corr_recipe.dropna(inplace=True)\n",
"corr_recipe.head()"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "obvious-voice",
"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>Rating</th>\n",
" </tr>\n",
" <tr>\n",
" <th>Name</th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>&amp;quot;21&amp;quot; Apple Pie</th>\n",
" <td>3.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>A Jad - Cucumber Pickle</th>\n",
" <td>5.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>A New Spaghetti with Clams</th>\n",
" <td>5.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Abby's Pecan Apple Cake</th>\n",
" <td>4.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Alfredo Sauce</th>\n",
" <td>4.55</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Rating\n",
"Name \n",
"&quot;21&quot; Apple Pie 3.00\n",
"A Jad - Cucumber Pickle 5.00\n",
"A New Spaghetti with Clams 5.00\n",
"Abby's Pecan Apple Cake 4.00\n",
"Alfredo Sauce 4.55"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#mean rating\n",
"recipe_mean_ratings= pd.DataFrame(mergeDf.groupby('Name')['Rating'].mean())\n",
"recipe_mean_ratings.head()"
]
},
{
"cell_type": "code",
"execution_count": 17,
"id": "bright-commerce",
"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>Rating</th>\n",
" <th>number_of_ratings</th>\n",
" </tr>\n",
" <tr>\n",
" <th>Name</th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>&amp;quot;21&amp;quot; Apple Pie</th>\n",
" <td>3.00</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>A Jad - Cucumber Pickle</th>\n",
" <td>5.00</td>\n",
" <td>2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>A New Spaghetti with Clams</th>\n",
" <td>5.00</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Abby's Pecan Apple Cake</th>\n",
" <td>4.00</td>\n",
" <td>2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Alfredo Sauce</th>\n",
" <td>4.55</td>\n",
" <td>200</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Rating number_of_ratings\n",
"Name \n",
"&quot;21&quot; Apple Pie 3.00 1\n",
"A Jad - Cucumber Pickle 5.00 2\n",
"A New Spaghetti with Clams 5.00 1\n",
"Abby's Pecan Apple Cake 4.00 2\n",
"Alfredo Sauce 4.55 200"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#createing number of rating data\n",
"recipe_mean_ratings['number_of_ratings'] = mergeDf.groupby('Name')['Rating'].count()\n",
"recipe_mean_ratings.head()\n"
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "elder-chair",
"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>Correlation</th>\n",
" <th>number_of_ratings</th>\n",
" </tr>\n",
" <tr>\n",
" <th>Name</th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>&amp;quot;21&amp;quot; Apple Pie</th>\n",
" <td>-0.005016</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>A Jad - Cucumber Pickle</th>\n",
" <td>-0.007098</td>\n",
" <td>2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>A New Spaghetti with Clams</th>\n",
" <td>-0.005016</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Abby's Pecan Apple Cake</th>\n",
" <td>-0.006885</td>\n",
" <td>2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Alfredo Sauce</th>\n",
" <td>-0.057802</td>\n",
" <td>200</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Correlation number_of_ratings\n",
"Name \n",
"&quot;21&quot; Apple Pie -0.005016 1\n",
"A Jad - Cucumber Pickle -0.007098 2\n",
"A New Spaghetti with Clams -0.005016 1\n",
"Abby's Pecan Apple Cake -0.006885 2\n",
"Alfredo Sauce -0.057802 200"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#Bring the mean rating\n",
"\n",
"corr_recipe = corr_recipe.join(recipe_mean_ratings['number_of_ratings'])\n",
"\n",
"corr_recipe.head()"
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "sunset-coordination",
"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>Correlation</th>\n",
" <th>number_of_ratings</th>\n",
" </tr>\n",
" <tr>\n",
" <th>Name</th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>Warm Chicken A La King</th>\n",
" <td>1.000000</td>\n",
" <td>22</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Betty Crocker's Southwestern Guacamole Dip</th>\n",
" <td>0.231998</td>\n",
" <td>4</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Lou's Fabulous Bruschetta</th>\n",
" <td>0.220813</td>\n",
" <td>4</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Best Lemonade</th>\n",
" <td>0.156543</td>\n",
" <td>9</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Almond Joy Cake</th>\n",
" <td>0.155968</td>\n",
" <td>2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Biscotti Di Prato</th>\n",
" <td>0.137005</td>\n",
" <td>2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Carina's Tofu-Vegetable Kebabs</th>\n",
" <td>0.137005</td>\n",
" <td>2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Buttermilk Pie With Gingersnap Crumb Crust</th>\n",
" <td>0.111755</td>\n",
" <td>3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Cabbage Soup</th>\n",
" <td>0.101451</td>\n",
" <td>9</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Low-Fat Berry Blue Frozen Dessert</th>\n",
" <td>0.098082</td>\n",
" <td>4</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Correlation number_of_ratings\n",
"Name \n",
"Warm Chicken A La King 1.000000 22\n",
"Betty Crocker's Southwestern Guacamole Dip 0.231998 4\n",
"Lou's Fabulous Bruschetta 0.220813 4\n",
"Best Lemonade 0.156543 9\n",
"Almond Joy Cake 0.155968 2\n",
"Biscotti Di Prato 0.137005 2\n",
"Carina's Tofu-Vegetable Kebabs 0.137005 2\n",
"Buttermilk Pie With Gingersnap Crumb Crust 0.111755 3\n",
"Cabbage Soup 0.101451 9\n",
"Low-Fat Berry Blue Frozen Dessert 0.098082 4"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"corr_recipe[corr_recipe['number_of_ratings'] > 1].sort_values(by='Correlation', ascending=False).head(10)"
]
},
{
"cell_type": "markdown",
"id": "neural-plaintiff",
"metadata": {},
"source": [
"### Neural Network"
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "genuine-leadership",
"metadata": {},
"outputs": [],
"source": [
"import tensorflow as tf\n",
"from tensorflow import keras"
]
},
{
"cell_type": "code",
"execution_count": 21,
"id": "organizational-vegetable",
"metadata": {},
"outputs": [],
"source": [
"model = keras.Sequential([\n",
" keras.layers.Dense(60,input_shape=(10,), activation = 'relu'),keras.layers.Dense(9, activation='sigmoid' )\n",
"])\n",
"\n",
"model.compile(optimizer='adam',\n",
" loss= keras.losses.SparseCategoricalCrossentropy(from_logits=True),\n",
" metrics=['accuracy'])"
]
},
{
"cell_type": "code",
"execution_count": 22,
"id": "specific-deployment",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[[43 'Best Blackbottom Pie' 34879 'Barefoot Beachcomber' 'PT2H' 'PT20M'\n",
" 'PT2H20M' '1999-08-21T10:35:00Z'\n",
" 'Make and share this Best Blackbottom Pie recipe from Food.com.'\n",
" 'character(0)' 'Pie'\n",
" 'c(\"Dessert\", \"Weeknight\", \"Stove Top\", \"< 4 Hours\")'\n",
" 'c(\"1 1/4\", \"1/4\", \"6\", \"1/3\", \"1/4\", \"1/4\", \"2\", \"3\", \"1\", \"1\", \"1/4\", \"1\", \"2\", \"3\", \"1/4\", \"1/2\", NA)'\n",
" 'c(\"graham cracker crumbs\", \"sugar\", \"butter\", \"sugar\", \"cornstarch\", \"salt\", \"milk\", \"vanilla extract\", \"water\", \"gelatin\", \"rum\", \"cream of tartar\", \"sugar\")'\n",
" 1.0 1.0 437.9 19.3 10.9 94.3 267.6 58.0 1.8 42.5 7.0 8.0 '1 9-inch pie'\n",
" 'c(\"Graham Cracker Crust: In small bowl, combine graham cracker crumbs, sugar and butter. Press evenly on bottom and sides of 9-inch pie plate. Chill until firm (about 1 hour).\", \"Chocolate Layer: In medium saucepan, combine sugar, cornstarch and salt. Gradually stir in milk. Cook over medium heat, stirring constantly, until mixture boils. Remove from heat. In small bowl, beat egg yolks. Gradually stir in small amount of hot mixture; return to saucepan. Cook over low heat, stirring constantly, for 2 minutes. Remove from heat.\", \\n\"Remove 1-1/2 cups custard to medium bowl; add semi-sweet chocolate morsels and vanilla extract. Stir until morsels are melted and mixture is smooth.\", \"Pour into prepared Graham Cracker Crust; chill until set (about 30 minutes).\", \"While Chocolate Layer is chilling, prepare Vanilla Layer.\", \"Vanilla Layer: In large bowl, combine cold water and gelatin; let stand 5 minutes. Add remaining warm custard; stir until gelatin dissolves. Cool 15 minutes. Stir in rum; beat with wire whisk until smooth. Set aside.\", \\n\"In 1-1/2 quart bowl, combine egg whites and cream of tartar; beat until foamy. Gradually add sugar; beat until stiff peaks form. Fold egg whites into custard; pour over chocolate layer.\", \"Chill until set (about 2 hours).\", \"Garnish with whipped cream and chocolate shavings, if desired.\", \"Makes one 9-inch pie.\")']\n",
" [54 'Carrot Cake' 1535 'Marg CaymanDesigns' 'PT50M' 'PT45M' 'PT1H35M'\n",
" '1999-09-13T15:20:00Z'\n",
" 'This is one of the few recipes my husband every requested from a coworker and brought home for me to make.'\n",
" 'c(\"https://img.sndimg.com/food/image/upload/w_555,h_416,c_fit,fl_progressive,q_95/v1/img/recipes/54/picQ2X4D8.jpg\", \"https://img.sndimg.com/food/image/upload/w_555,h_416,c_fit,fl_progressive,q_95/v1/img/recipes/54/pic3oloIV.jpg\", \"https://img.sndimg.com/food/image/upload/w_555,h_416,c_fit,fl_progressive,q_95/v1/img/recipes/54/picf0dw0o.jpg\")'\n",
" 'Dessert' 'c(\"Vegetable\", \"Weeknight\", \"Oven\", \"< 4 Hours\")'\n",
" 'c(\"3\", \"4\", \"1 1/4\", \"2\", \"2\", \"2\", \"2\", \"1\", \"1\", \"1/2\", \"1\", \"1 1/4\", \"1\", \"1\", \"1/2\")'\n",
" 'c(\"carrots\", \"eggs\", \"white sugar\", \"all-purpose flour\", \"baking powder\", \"baking soda\", \"cinnamon\", \"salt\", \"nutmeg\", \"golden raisin\", \"confectioners\\' sugar\", \"cream cheese\", \"light corn syrup\", \"vanilla extract\")'\n",
" 5.0 17.0 522.6 27.1 4.9 69.8 534.8 67.0 1.6 47.9 5.0 12.0 '1 bundt'\n",
" 'c(\"Beat together the eggs, oil, and white sugar. Blend mixture for thirty seconds.\", \"Sift together flour, baking powder, baking soda, salt and spices. Add the carrots and raisins.\", \"Pour egg mixture into dry ingredients, and mix well. Pour batter into well greased 10 inch tube or Bundt pan.\", \"Bake at 350 degrees F (175 degrees C) oven for 45 to 50 minutes. Cool cake on wire rack, and then refrigerate until completely cooled.\", \"To make Cream Cheese Glaze: Blend together confectioners\\' sugar, cream cheese, corn syrup, and vanilla. Spread over cooled cake.\"\\n)']\n",
" [64 'Almond Pound Cake' 125579 'GrandmaIsCooking' 'PT1H' 'PT15M'\n",
" 'PT1H15M' '1999-08-07T16:33:00Z'\n",
" 'Make and share this Almond Pound Cake recipe from Food.com.'\n",
" 'character(0)' 'Dessert'\n",
" 'c(\"Fruit\", \"Nuts\", \"Weeknight\", \"Oven\", \"< 4 Hours\")'\n",
" 'c(\"2/3\", \"3 1/2\", \"1 1/4\", \"4\", \"2 1/4\", \"5\", \"1\", \"1/2\")'\n",
" 'c(\"butter\", \"almond paste\", \"sugar\", \"eggs\", \"flour\", \"cornstarch\", \"baking powder\", \"milk\")'\n",
" 4.5 3.0 408.5 17.9 9.0 118.9 159.4 56.0 1.3 29.0 6.9 10.0 '1 cake'\n",
" 'c(\"Preheat oven to 350 degrees Fahrenheit.\", \"Cream butter and almond paste until fluffy.\", \"Add sugar, gradually add eggs, one at a time. Mix together flour, cornstarch and baking powder, then add flour mixture and milk alternately.\", \"Bake in greased 9x5 loaf pan for 1 hour.\", \"Double recipe for a bundt pan and bake 75 minute.\", \"Cool 10 min in pan, then turn out and cool completely.\", \"Serve with powdered sugar, orange glaze or chocolate glaze.\")']\n",
" [94 'Blueberry Buttertarts' 1556 'Strawberry Girl' 'PT25M' 'PT15M'\n",
" 'PT40M' '1999-09-12T05:46:00Z'\n",
" 'Make and share this Blueberry Buttertarts recipe from Food.com.'\n",
" 'character(0)' 'Dessert' 'c(\"Berries\", \"Fruit\", \"< 60 Mins\", \"Oven\")'\n",
" 'c(\"12\", \"1\", \"1/2\", \"1\", \"3/4\", \"1/3\", \"1\", \"1 1/2\")'\n",
" 'c(\"egg\", \"corn syrup\", \"lemon juice\", \"vanilla\", \"brown sugar\", \"all-purpose flour\", \"blueberries\")'\n",
" 5.0 4.0 337.9 18.4 4.7 17.6 125.7 40.2 1.2 11.5 4.2 12.0 '12 tarts'\n",
" 'c(\"Preheat oven to 375F.\", \"Leave shells in foil cups and place on a baking sheet. In large bowl, whisk egg with syrup, juice and vanilla.\", \"In another bowl, stir sugar with flour.\", \"Divide berries among shells.\", \"Pour in egg mixture, filling each shell right to top.\", \"Bake on bottom rack at 375F oven until bubbly and top is a bit crusty, from 18-23 minutes.Tarts will firm up when cool and can be refrigerated 2 days.\")']]\n",
"<class 'numpy.ndarray'>\n"
]
}
],
"source": [
"print(newDf2.values[1:5])\n",
"print(type(newDf2.values))\n",
"\n",
"newDf2 = newDf2[['RecipeId','AggregatedRating','ReviewCount','Calories','FatContent','SaturatedFatContent','CholesterolContent','SodiumContent','CarbohydrateContent','FiberContent','SugarContent','ProteinContent','RecipeServings']]\n",
"\n",
"x2 = newDf2.iloc[:,2:12].values\n",
"Y = newDf2.iloc[:,1].values"
]
},
{
"cell_type": "code",
"execution_count": 23,
"id": "documented-spine",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1751/1751 [==============================] - 2s 1ms/step - loss: 1.6009 - accuracy: 0.1866\n"
]
},
{
"data": {
"text/plain": [
"<tensorflow.python.keras.callbacks.History at 0x22114ef2160>"
]
},
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"model.fit(x2,Y, batch_size=16)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
}
},
"nbformat": 4,
"nbformat_minor": 5
}