Skip to content

Instantly share code, notes, and snippets.

@juliuskittler
Created November 3, 2022 12:16
Show Gist options
  • Select an option

  • Save juliuskittler/fa9ae0e41e3db797718ff628f6fef746 to your computer and use it in GitHub Desktop.

Select an option

Save juliuskittler/fa9ae0e41e3db797718ff628f6fef746 to your computer and use it in GitHub Desktop.
"""
This is an adjusted version of the following file: https://github.com/outerbounds/dsbook/blob/main/chapter-3/classifier_predict.py
"""
from metaflow import FlowSpec, step, Flow, Parameter, JSONType, project, conda_base
@project(name="dummy_example")
@conda_base(python="3.8.13", libraries={"pandas": "1.5", "scikit-learn": "1.1.2"})
class ClassifierPredictFlow(FlowSpec):
vector = Parameter("vector", type=JSONType, required=True)
@step
def start(self):
run = Flow("ClassifierTrainFlow").latest_run
self.train_run_id = run.pathspec
self.model = run["end"].task.data.model
print("Input vector", self.vector)
self.next(self.end)
@step
def end(self):
print("Predicted class", self.model.predict([self.vector])[0])
if __name__ == "__main__":
ClassifierPredictFlow()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment