AdilZouitine / outfit

:dress: Tidy up your machine learning experiments

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

πŸ‘— Outfit

Outfit is a lightweight library to tidy up your machine learning experiments in a simple way.

The idea of Outfit is to store in your Wardrobe your parameters, output file, scores and features in order to be able to make a request and find out which are your best experimentation according to a given criterion.

How install outfit ?

PyPI:

pip install outfit

Dev version:

git clone https://github.com/AdilZouitine/outfit
cd outfit
pip install -r requirements.txt
pip install -e .

How outfit works ?

  • Tutorial 1: Build a simple model management pipeline with outfit for a CNN with Pytorch on MNIST dataset Open In Colab
import datetime

# Here import all the libraries you need for your experiment

from outfit import Wardrobe, getlog

wardrobe = Wardrobe(db_path='foo/bar/mnist.db')

exp = {
    'experiment_name': 'ResNet18',
    'comment': 'Use differential learning rate',
    'date_experiment': datetime.datetime.now()
}

wardrobe.add_experiment(**exp)

param = {
    'dropout': 0.20,
    'kernel_size': '3x3',
    'conv_block_1_lr': 0.01,
    'conv_block_2_lr': 0.001
   }

# Create the instance of your model here with your parameters
wardrobe.add_dict_parameter(param)


# Do your training phase here.
output = {'training log': '/result/training_log_resnet18.txt'}

@getlog(filepath=output['training log'])
def train_model(model, loaders, loss, lr_scheduler, n_epoch):
    ...

output.update({
    'tensorboard': '/result/event.tb',
    'model': 'diff_lr_resnet18.pth'
})

wardrobe.add_dict_output(output)

score = {
    'train acc': 0.96,
    'train loss': 0.430,
    'val acc': 0.94,
    'val loss': 0.460
     }
wardrobe.add_dict_score(score)


wardrobe.tidy() # commit your experiment in database
# If you want to get the best experiments 

for exp in wardrobe.get_best_scores(mode='max',on_score='val acc'):
    '''
    Verbose is true by default and will print on the console 
    at each iteration the parameters, output file, 
    features and scores in a table format.

    Also returns in dictionary the parameters, output file, features and scores.
    '''
    ...

Output:

════════════════════
β”‚ TOP 1 EXPERIMENT β”‚
════════════════════



Table : Experiment 

╒════╀═════════════════╀═══════════════════╀════════════════════════════════╀════════════════════╕
β”‚    β”‚   id_experiment β”‚ experiment_name   β”‚ comment                        β”‚ date_experiement   β”‚
β•žβ•β•β•β•β•ͺ═════════════════β•ͺ═══════════════════β•ͺ════════════════════════════════β•ͺ════════════════════║
β”‚  0 β”‚               1 β”‚ ResNet18          β”‚ Use differential learning rate β”‚                    β”‚
β•˜β•β•β•β•β•§β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•§β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•§β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•§β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•›


Table : Parameter 

╒════╀════════════════╀══════════════════╀═════════════╀══════════════╕
β”‚    β”‚   id_parameter β”‚ parameter_name   β”‚ parameter   β”‚   experiment β”‚
β•žβ•β•β•β•β•ͺ════════════════β•ͺ══════════════════β•ͺ═════════════β•ͺ══════════════║
β”‚  0 β”‚              1 β”‚ dropout          β”‚ 0.2         β”‚            1 β”‚
β”œβ”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  1 β”‚              2 β”‚ kernel_size      β”‚ 3x3         β”‚            1 β”‚
β”œβ”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  2 β”‚              3 β”‚ conv_block_1_lr  β”‚ 0.01        β”‚            1 β”‚
β”œβ”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  3 β”‚              4 β”‚ conv_block_2_lr  β”‚ 0.001       β”‚            1 β”‚
β•˜β•β•β•β•β•§β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•§β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•§β•β•β•β•β•β•β•β•β•β•β•β•β•β•§β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•›


Table : Output 

╒════╀═════════════╀═══════════════╀═══════════════════════════════════╀══════════════╕
β”‚    β”‚   id_output β”‚ type_output   β”‚ path_output                       β”‚   experiment β”‚
β•žβ•β•β•β•β•ͺ═════════════β•ͺ═══════════════β•ͺ═══════════════════════════════════β•ͺ══════════════║
β”‚  0 β”‚           1 β”‚ training log  β”‚ /result/training_log_resnet18.txt β”‚            1 β”‚
β”œβ”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  1 β”‚           2 β”‚ tensorboard   β”‚ /result/event.tb                  β”‚            1 β”‚
β”œβ”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  2 β”‚           3 β”‚ model         β”‚ diff_lr_resnet18.pth              β”‚            1 β”‚
β•˜β•β•β•β•β•§β•β•β•β•β•β•β•β•β•β•β•β•β•β•§β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•§β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•§β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•›


Table : Score 

╒════╀════════════╀══════════════╀═════════╀══════════════╕
β”‚    β”‚   id_score β”‚ type_score   β”‚   score β”‚   experiment β”‚
β•žβ•β•β•β•β•ͺ════════════β•ͺ══════════════β•ͺ═════════β•ͺ══════════════║
β”‚  0 β”‚          1 β”‚ train acc    β”‚    0.96 β”‚            1 β”‚
β”œβ”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  1 β”‚          2 β”‚ train loss   β”‚    0.43 β”‚            1 β”‚
β”œβ”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  2 β”‚          3 β”‚ val acc      β”‚    0.94 β”‚            1 β”‚
β”œβ”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  3 β”‚          4 β”‚ val loss     β”‚    0.46 β”‚            1 β”‚
β•˜β•β•β•β•β•§β•β•β•β•β•β•β•β•β•β•β•β•β•§β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•§β•β•β•β•β•β•β•β•β•β•§β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•›


Table : Feature 

Other solution:

mlflow & dvc.

These solutions are great, they also offer a user interface and have many more options than my library however for a simple use where you only want to organize your experimentation and make a simple query. Both solutions seem to be overkill.

About

:dress: Tidy up your machine learning experiments


Languages

Language:Jupyter Notebook 60.7%Language:Python 39.3%