Skip to content

Instantly share code, notes, and snippets.

@pabloalcain
Created October 1, 2022 20:49
Show Gist options
  • Save pabloalcain/49266d30928da163c918a6db5902533b to your computer and use it in GitHub Desktop.
Save pabloalcain/49266d30928da163c918a6db5902533b to your computer and use it in GitHub Desktop.
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