MLflow परिचय
Weston Bassler
Senior MLOps Engineer
NLP - Tokenizer(s)
Classification - Label encoder
प्री/पोस्ट प्रोसेसिंग
बिल्ट-इन फ्लेवर नहीं

बिल्ट-इन फ्लेवर - python_function
mlflow.pyfunc
save_model()log_model()load_model()कस्टम मॉडल क्लास
MyClass(mlflow.pyfunc.PythonModel)PythonModel क्लास
load_context() - जब mlflow.pyfunc.load_model() कॉल होता है तो आर्टिफैक्ट्स लोड करता हैpredict() - मॉडल इनपुट लेता है और यूज़र-डिफाइंड इवैल्युएशन करता है# Class class MyPythonClass:# Function जो Hello! प्रिंट करता है def my_func(): print("Hello!")
# नया Object बनाएँ x = MyPythonClass()# my_func फंक्शन चलाएँ x.my_func()
"Hello!"
import mlflow.pyfunc # मॉडल क्लास परिभाषित करें class CustomPredict(mlflow.pyfunc.PythonModel):# आर्टिफैक्ट्स लोड करें def load_context(self, context): self.model = mlflow.sklearn.load_model(context.artifacts["custom_model"])# custom_function() से इनपुट का मूल्यांकन करें def predict(self, context, model_input): prediction = self.model.predict(model_input) return custom_function(prediction)
# मॉडल को लोकल फ़ाइलसिस्टम में सेव करें
mlflow.pyfunc.save_model(path="custom_model", python_model=CustomPredict())
# मॉडल को MLflow Tracking पर लॉग करें
mlflow.pyfunc.log_model(artifact_path="custom_model", python_model=CustomPredict())
# लोकल फ़ाइलसिस्टम से मॉडल लोड करें
mlflow.pyfunc.load_model("local")
# MLflow Tracking से मॉडल लोड करें
mlflow.pyfunc.load_model("runs:/run_id/tracking_path")
mlflow.evaluate() - किसी डेटासेट पर परफॉर्मेंस
रिग्रेशन और क्लासिफिकेशन मॉडल्स
# Training Data X_train, X_test, y_train, y_test = \ train_test_split(X, y, train_size=0.7,random_state=0)# Linear Regression मॉडल lr = LinearRegression() lr.fit(X_train, y_train)
# Dataset eval_data = X_test eval_data["test_label"] = y_test# डेटासेट के साथ मॉडल इवैल्युएट करें mlflow.evaluate( "runs:/run_id/model", eval_data, targets="test_label", model_type="regressor" )


MLflow परिचय