forked from smith478/ModelTools
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathModel.py
31 lines (26 loc) · 1019 Bytes
/
Model.py
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
28
29
30
31
import pandas as pd
import numpy as np
from scipy import stats
import importlib
import matplotlib.pyplot as plt
import importlib
class Model(object):
def __init__(self, heuristic, transformation, score, params, label="Unlabelled", copy=True):
self.heuristic = heuristic
self.transformation = transformation
self.score_func = score
if copy:
# TODO Generalize the copy function somehow
self.params = params.deepcopy()
else:
self.params = params
self.label = label
def transform(self, X):
return self.transformation(self.params, X)
def fit(self, X, Y, hyperparams):
self.params = self.heuristic(hyperparams, self.score_func)(X, Y)
def score(self, X, Y):
return self.score_func(self.transform(X), Y)
def copy(self):
# TODO Change the label name.
to_return = Model(self.heuristic, self.transformation, self.score_func, self.params, self.label)