I converted this notebook to a Python script and run it natively inside an Azure Compute VM.
import mlflow
import mlflow.sklearn
import azureml.core
from azureml.core import Workspace
import matplotlib.pyplot as plt
# Check core SDK version number
print("SDK version:", azureml.core.VERSION)
ws = Workspace.from_config()
mlflow.set_tracking_uri(ws.get_mlflow_tracking_uri())
experiment_name = "LocalTrain-with-mlflow-sample"
mlflow.set_experiment(experiment_name)
import numpy as np
from sklearn.datasets import load_diabetes
from sklearn.linear_model import Ridge
from sklearn.metrics import mean_squared_error
from sklearn.model_selection import train_test_split
X, y = load_diabetes(return_X_y = True)
columns = ['age', 'gender', 'bmi', 'bp', 's1', 's2', 's3', 's4', 's5', 's6']
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=0)
data = {
"train":{"X": X_train, "y": y_train},
"test":{"X": X_test, "y": y_test}
}
print ("Data contains", len(data['train']['X']), "training samples and",len(data['test']['X']), "test samples")
# Create a run object in the experiment
model_save_path = "model"
with mlflow.start_run() as run:
# Log the algorithm parameter alpha to the run
mlflow.log_metric('alpha', 0.03)
# Create, fit, and test the scikit-learn Ridge regression model
regression_model = Ridge(alpha=0.03)
regression_model.fit(data['train']['X'], data['train']['y'])
preds = regression_model.predict(data['test']['X'])
# Log mean squared error
print('Mean Squared Error is', mean_squared_error(data['test']['y'], preds))
mlflow.log_metric('mse', mean_squared_error(data['test']['y'], preds))
# Save the model to the outputs directory for capture
mlflow.sklearn.log_model(regression_model,model_save_path)
# Plot actuals vs predictions and save the plot within the run
fig = plt.figure(1)
idx = np.argsort(data['test']['y'])
plt.plot(data['test']['y'][idx],preds[idx])
fig.savefig("actuals_vs_predictions.png")
mlflow.log_artifact("actuals_vs_predictions.png")
ws.experiments[experiment_name]
Here's the result of running the notebook:
Where in Azure Portal I can access the results? Can you please share a link?
I converted this notebook to a Python script and run it natively inside an Azure Compute VM.
Here's the result of running the notebook:![Screenshot from 2022-12-21 14-33-25](https://user-images.githubusercontent.com/1892917/208988607-dee0ab5a-a964-4b80-9912-d3aa280d674c.png)
Where in Azure Portal I can access the results? Can you please share a link?