|
|
import mlflow |
|
|
import pandas as pd |
|
|
from sklearn.datasets import load_iris |
|
|
from sklearn.linear_model import LogisticRegression |
|
|
from sklearn.model_selection import train_test_split |
|
|
from dotenv import load_dotenv |
|
|
import os |
|
|
|
|
|
load_dotenv() |
|
|
|
|
|
|
|
|
iris = load_iris() |
|
|
|
|
|
|
|
|
X = pd.DataFrame(data = iris["data"], columns= iris["feature_names"]) |
|
|
y = pd.Series(data = iris["target"], name="target") |
|
|
|
|
|
|
|
|
X_train, X_test, y_train, y_test = train_test_split(X, y) |
|
|
|
|
|
|
|
|
EXPERIMENT_NAME="my-first-mlflow-experiment-iris" |
|
|
|
|
|
|
|
|
mlflow.set_tracking_uri("https://atomik31-mlflow.hf.space") |
|
|
|
|
|
|
|
|
mlflow.set_experiment(EXPERIMENT_NAME) |
|
|
|
|
|
|
|
|
experiment = mlflow.get_experiment_by_name(EXPERIMENT_NAME) |
|
|
|
|
|
|
|
|
mlflow.sklearn.autolog() |
|
|
|
|
|
with mlflow.start_run(experiment_id = experiment.experiment_id): |
|
|
|
|
|
|
|
|
lr = LogisticRegression() |
|
|
lr.fit(X_train.values, y_train.values) |
|
|
|
|
|
|
|
|
predicted_qualities = lr.predict(X_test.values) |
|
|
accuracy = lr.score(X_test.values, y_test.values) |
|
|
|
|
|
|
|
|
print("LogisticRegression model") |
|
|
print("Accuracy: {}".format(accuracy)) |