README
MIT License
2 min read · a year ago
Movie Recommender API
Repository- AIPythonAPIUnit
This API was created for studying principles of genetic algorithm for a movies recommendation system. Based on a ratings database, it executes the algorithm and recommends a list with 10 movies for a given user.
Genetic Algorithm
Genetic Algorithms (GAs) are search heuristics inspired by the process of natural selection. They belong to the class of evolutionary algorithms and are commonly used to generate high-quality solutions for optimization and search problems.
Basic Principles
- Population: A set of potential solutions (individuals) to the problem.
- Chromosomes: Representation of an individual solution, typically as a string of binary values or other structures.
- Fitness Function: A function that evaluates and assigns a fitness score to each individual, reflecting how well it solves the problem.
- Selection: The process of choosing individuals based on their fitness scores to create offspring for the next generation.
- Crossover (Recombination): Combining parts of two or more parents’ chromosomes to produce new offspring.
- Mutation: Introducing small random changes to an individual’s chromosome to maintain genetic diversity.
How It Works
- Initialization: Start with a randomly generated population of individuals.
- Evaluation: Compute the fitness of each individual using the fitness function.
- Selection: Select individuals for reproduction based on their fitness. Common methods include roulette wheel selection and tournament selection.
- Crossover: Perform crossover operations on selected individuals to produce new offspring.
- Mutation: Apply mutation operations to some offspring to introduce variability.
- Replacement: Form a new generation by replacing some or all of the old population with the new offspring.
- Termination: Repeat the evaluation, selection, crossover, mutation, and replacement steps until a stopping criterion is met, such as reaching a maximum number of generations or achieving a satisfactory fitness level.
Genetic Algorithms are powerful tools for solving complex optimization problems by mimicking the natural evolutionary process.
Stack
- Python;
- SQLite;
- FastAPI;
- Uvicorn;
- Deap;
Routes
/api/movies
: returns all movies;/api/movies/{id}
: returns a movie by ID;/api/users
: returns all users;/api/users/{id}
: returns a user by ID;/api/movies_by_user/{user_id}
: returns all movies rated by a user ID./api/users_by_movie/{movie_id}
: returns all users who rated a movie ID./api/recommender
: executes the evolution process and returns a recommendation for a given user.
Documentation and details
All informations about this API can be found here, at the original repository from @adolfoguimaraes.