Skip to content

SmartDataAnalytics/AutoChef

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AutoChef

An Evolutionary Algortihm to create new cooking recipes

requirements

  • an envrironment with python3.7.
  • For python3.8 or newer the adjacency matrices have to be created manually from the 1M Recipe Dataset as described in the package details below

installation

  • clone this directory: https://github.com/SmartDataAnalytics/AutoChef.git
  • inside the cloned project, extract the pregenerated compressed adjacency matrices with
cd src/autochef/RecipeAnalysis && tar -xf adjacency_matrices.tar.xz
  • install the cloned package with pip:
pip install wheel
pip install ./AutoChef

Example Usage:

just perform the following in a jupyter notebook (same as Example.ipynb)

Import autochef's Evolutionary Algorithm

import autochef
from autochef.EvolutionaryAlgorithm import EvolutionaryAlgorithm as EA

Setup parameters

# define the set of input ingredients and it's subset of main ingredients

all_ingredients = ["bread", "butter"]
main_ingredients = ["bread"]

# define range of additional ingredients
min_add = 4
max_add = 13

# population size:
n_pop = 50

# mutations rate (given in number of node mutations for each tree)
mutations = 2

# if pairwise competition is false, just the best n_pop/2 individuals survive
pairwise_competition = True

build initial population

p = EA.Population(
    all_ingredients,
    main_ingredients,
    min_additional=min_add,
    max_additional=max_add,
    n_population = n_pop,
    mutations=mutations,
    pairwise_competition=pairwise_competition
)

run over a given number of generations

# run over 10 cycles
fitness_logs = p.run(10)

plot best 3 individuals

p.plot_population(n_best=3)

Package Details

if you want to modify package data, retrain models or recreate adjacency matrices: here are some notes about the structure of this package (in /src/autochef/):

./data

the ./data folder contains data files used in this thesis.

NOTE: due to the 1M_recipes licensing, i am not allowed to redistribute it's data. Because of this the data has to be downloaded manually and put indside the folder ./data/1M_recipes.

./db

Tools to create a mariadb recipe database from the 1M_recipes dataset and working with it. Necessary if you want to recreate adjacency matrices. To create a docker image with a database containing the 1M_recipe dataset execute the following Notebooks:

./Tagging

(needs the 1M_recipe dataset placed inside the data folder, see above)

Tools to retrain the crf classifier. The package ships already a trained one.

To generate a train dataset for the crf classifier run the python script:

it will generate enumerated *.conllu files which can then used to train the classifier with

./RecipeAnalysis

(needs the maria database set up and filled with data)

tools to generate adjacency Matrices. To generate them run the Notebooks

and

the matrices are then serialized and saved with [dill](dill · PyPI) and can be loaded with dill again (which is done in the Evolutionary algorithm)

./EvolutionaryAlgorithm

needs adjaceny matrices set up in the recipe analysis folder. The package already ships with pregenerated ones, so that you can try the evolutionary algorithm without setting up the 1M recipe database if you only want to run this part. Core Part is the EvolutionaryAlgorithm.py module.

About

Automated recipe generator

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published