class Predictor(BaseEstimator): '''Predictor: modify this class to create a predictor of your choice. This could be your own algorithm, of one for the scikit-learn models, for which you choose the hyper-parameters.''' def __init__(self): '''This method initializes the predictor.''' self.mod = MLPClassifier((256, 128), activation="tanh", max_iter=20, solver="adam", alpha=1e-6, batch_size=128, verbose=True) print("PREDICTOR=" + self.mod.__str__()) """ def augment_data(self, X): new_x = np.zeros((X.shape[0], X.shape[1]+768)) new_x[:,:256] = X new_x[:,256:] = X[:,self.pairs[:,0]] * X[:,self.pairs[:,1]] return new_x """ def fit(self, X, y): ''' This is the training method: parameters are adjusted with training data.''' self.mod = self.mod.fit(X, y) return self def predict(self, X): #X = self.augment_data(X) ''' This is called to make predictions on test data. Predicted classes are output.''' return self.mod.predict(X) def save(self, path="./"): pickle.dump(self, open(path + '_model.pickle', "w")) def load(self, path="./"): self = pickle.load(open(path + '_model.pickle')) return self