SachaIZADI / DisruptHogwarts_API

Home Page:

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Disrupt Hogwarts - API

Project description

From the Disrupt Hogwarts project (which consisted in developing from scratch a python library for logistic regression), I built a Flask API.

The API offers three functionalities:

  1. train: to train the model based on the initial data provided by 42.
  2. transfer: to train a new model for another school using "transfer learning". What it actually does, is initializing a new model with the one previously trained on the Hogwarts dataset, and updates the model to fit the data of the new school with a smaller learning rate. Transfer learning can help algorithms learn much quicker.
  3. predict: to make a prediction, i.e. compute P(y=house|X=x_i) for a given school.

Clone the repo

Run git clone in your shell.

Then mkvirtualenv --python=`which python3` hogwarts_api (You can escape the virtualenv by running `deactivate)

Then finally run `pip3 install requirements.txt. And You're up to play with the project.

How to use it


Launch the local server, by running



Server is now accessible on

The API can be run directly in the browser:

Or by using scripts such as

NB: Make sure that the BASE_URL variable is set upt to

On the cloud

I chosed to deploy the API on Heroku, mostly for time and money constraints. It is accessible on

You can play with the model and make a couple predictions by running.

Alternatively, you can write scripts that directly query the API. Just change the BASE_URL value in for instance.


Note to myself: Useful heroku guidelines and commands

A good article, and the classic commands

git push heroku master
heroku ps:scale web=1
heroku open
heroku logs



Language:Python 96.6%Language:C 2.1%Language:C++ 1.1%Language:Fortran 0.1%Language:CSS 0.1%Language:JavaScript 0.1%Language:Shell 0.0%