Created
October 1, 2022 20:49
-
-
Save pabloalcain/49266d30928da163c918a6db5902533b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Model: | |
def __init__(self): | |
self.classifier = Pipeline( | |
steps=[("select", SelectKBest(k=2)), | |
("clf", LogisticRegression())]) | |
def fit(self, features, target): | |
self.classifier.fit(features, target) | |
def load(self, filename): | |
with open(filename, "rb") as model_file: | |
self.classifier = pickle.load(model_file) | |
def save(self, filename): | |
with open(filename, "wb") as model_file: | |
pickle.dump(self.classifier, model_file) | |
def predict(self, features): | |
return self.classifier.predict(features) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment