File size: 744 Bytes
f7db77c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from sklearn.linear_model import LogisticRegression
import joblib
from commons.Configs import configs
from commons.File import file


class Model:
    def __init__(self, debug=False):
        self.debug = debug

    def train(self, x, y):
        return LogisticRegression(solver='lbfgs', random_state=42).fit(x, y)

    def save(self, clf):
        # save model
        joblib.dump(clf, configs.generatedModelPath)
        print("Model saved to: ", configs.generatedModelPath)

    def load(self):
        if not file.exists(configs.generatedModelPath):
            print("Model not found at: ", configs.generatedModelPath)
            exit(1)
        return joblib.load(configs.generatedModelPath)


model = Model()