model_raw_results.py 2 KB
Newer Older
1
2
from bolsonaro.utils import save_obj_to_pickle, load_obj_from_pickle

3
4
5
6
7
8
import os
import datetime


class ModelRawResults(object):

9
    def __init__(self, model_weights, training_time,
10
        datetime, train_score, dev_score, test_score,
11
12
        train_score_base, dev_score_base,
        test_score_base, score_metric, base_score_metric):
13

14
        self._model_weights = model_weights
15
16
17
18
19
        self._training_time = training_time
        self._datetime = datetime
        self._train_score = train_score
        self._dev_score = dev_score
        self._test_score = test_score
20
21
22
        self._train_score_base = train_score_base
        self._dev_score_base = dev_score_base
        self._test_score_base = test_score_base
23
24
        self._score_metric = score_metric
        self._base_score_metric = base_score_metric
Léo Bouscarrat's avatar
Léo Bouscarrat committed
25

26
    @property
27
    def model_weights(self):
28
        return self._model_weights
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50

    @property
    def training_time(self):
        return self._training_time

    @property
    def datetime(self):
        return self._datetime

    @property
    def train_score(self):
        return self._train_score

    @property
    def dev_score(self):
        return self._dev_score

    @property
    def test_score(self):
        return self._test_score

    @property
51
52
    def train_score_base(self):
        return self._train_score_base
53
54

    @property
55
56
    def dev_score_base(self):
        return self._dev_score_base
57
58

    @property
59
60
    def test_score_base(self):
        return self._test_score_base
61

62
63
64
65
66
67
68
69
    @property
    def score_metric(self):
        return self._score_metric

    @property
    def base_score_metric(self):
        return self._base_score_metric

70
    def save(self, models_dir):
Léo Bouscarrat's avatar
Léo Bouscarrat committed
71
72
        if not os.path.exists(models_dir):
            os.mkdir(models_dir)
73
74
        save_obj_to_pickle(models_dir + os.sep + 'model_raw_results.pickle',
            self.__dict__)
75
76

    @staticmethod
Léo Bouscarrat's avatar
Léo Bouscarrat committed
77
    def load(models_dir):
78
79
        return load_obj_from_pickle(models_dir + os.sep + 'model_raw_results.pickle',
            ModelRawResults)