ML experiment giving error - RESOURCE_DOES_NOT_EXIST

dbuser24
Contributor

Followed the below documentation to create a ML experiment - 
https://docs.databricks.com/aws/en/mlflow/experiments

I created an experiment using the databricks console, then tried running the below code but getting error - getting error - RESOURCE_DOES_NOT_EXIST: Parent directory /Users/<username> does not exist

import mlflow
import os
import numpy as np
from sklearn.linear_model import LinearRegression

experiment_name = "/Users/<username>/my_ml_experiment"
mlflow.set_experiment(experiment_name)

with mlflow.start_run():
mlflow.log_param("alpha", 0.01)
mlflow.log_param("fit_intercept", True)

mlflow.log_metric("rmse", 0.25)
mlflow.log_metric("r2", 0.95)

artifact_dir = "/dbfs/FileStore/mlflow_artifacts"
os.makedirs(artifact_dir, exist_ok=True)

artifact_path = os.path.join(artifact_dir, "info.txt")
with open(artifact_path, "w") as f:
f.write("This is a sample artifact for MLflow logging in Databricks.")

mlflow.log_artifact(artifact_path)

X = np.array([[1], [2], [3], [4]])
y = np.array([2, 4, 6, 8])
model = LinearRegression(fit_intercept=True)
model.fit(X, y)

mlflow.sklearn.log_model(model, "linear_model")

experiment = mlflow.get_experiment_by_name(experiment_name)
print(f"Experiment ID: {experiment.experiment_id}")
print(f"Artifact Location: {experiment.artifact_location}")