AlexBarbier/mlflow-tracking-server
0
1import mlflow2import mlflow.sklearn3from sklearn.ensemble import RandomForestClassifier4from sklearn.datasets import load_iris5 6# Configurez l'URI de votre serveur Hugging Face7mlflow.set_tracking_uri("https://votre-username-mlflow-tracking-server.hf.space")8 9# Créer une expérience10mlflow.set_experiment("test-hf-deployment")11 12# Entraîner un modèle simple13print("Chargement des données...")14X, y = load_iris(return_X_y=True)15model = RandomForestClassifier(n_estimators=100)16 17print("Entraînement du modèle...")18model.fit(X, y)19 20# Logger sur le serveur distant21print("Envoi vers MLflow...")22with mlflow.start_run(run_name="test-deployment"):23 mlflow.log_param("n_estimators", 100)24 mlflow.log_param("max_depth", 5)25 accuracy = model.score(X, y)26 mlflow.log_metric("accuracy", accuracy)27 mlflow.sklearn.log_model(model, "iris-model")28 29print(f"✅ Modèle sauvegardé avec succès! Accuracy: {accuracy:.2f}")30print(f"🌐 Voir sur: https://votre-username-mlflow-tracking-server.hf.space")