Writing an AI to suggest what to make everyday for meals(common problem in Asian-households).
Writing an AI to suggest what to make everyday for meals(common problem in Asian-households).
I am an Indian. Usually my mom cooks for me sometimes I cook too and the common discussion we have everyday is “what should I make today?” and then after hours of discussion we come to the conclusion an still not satisfied with it. As you can already tell its a big problem. So, I made and AI to automate this for me.
And trust me weather is a big decider on what should be made on that day.
First lets look at how this would work:
So firstly lets start with the weather detection model. Lets import the libraries:
Lets get the open source dataset now:
For knowing your city’s weather use pandas:
Now let's clean the dataset and get it ready for the model.
Lets see the data of Kolkata from 1743–2020, and lets identify the NaN and non NaN values and plot them in a pie chart:
As they are not a consistent part of the dataset, Let’s fill the missing values with the previous ones:
The ‘dt’ column identifies the year and the month. For the next operations, it is handier to convert this column into a datetime object and to explicitly identify the year and the month in two different columns. We can do that by using the following lines:
Using this clean dataset lets make a point graph just for fun:
Now lets make 3 functions to make plotting better:
- get_timeseries(start_year,end_year) extract the portion of the dataset between the two years
- plot_timeseries(start_year,end_year) plots the timeseries extracted in get_timeseries in a readable way
- plot_from_data(data, time, display_options) plots the data (AverageTemperature) wrt the time (dt) in a readable way. The display options permit to display the ticks, change the colors, set the label .
Now we can make plots like this:
When we use ARIMA models, we should be considering stationary time series. In order to check if the timeseries we are considering is stationary, we can check the correlation and autocorrelation plots:
Now let's get started with the machine learning algorithm.
Performing the training:
Plotting the split:
Implementing the ARIMA models:
Getting the best model:
Now that we have the best model trained.Lets get started with the forecasting:
Now finally we have the forecast of our area that too it can work offline. Now let's get started with the main part the food suggestion part.
For that first we have to make our own dataset as there is no data set for food list in India and for making that we have to webscrape tables from wikipedia and turn them into datasets. It can be done by the following web-scraping code:
By the code the following dataset is obtained:
Now this point on its just if and elif .
Lets do the code:
And the code is done and just like that we have a food suggester which works on predicted weather.
Lets see the output:
Thanks for reading😁
A follow is appreciated.
Check out my GitHub for more code stuff:
You can't perform that action at this time. You signed in with another tab or window. You signed out in another tab or…github.com
For my day to day updates on my AIML research follow me on twitter:
See ya guys next week 😁.