pyenv install 3.7.0
pyenv global 3.7.0 # Use Python 3.7
mkvirtualenv mlflow # Create a Virtual Env with Python 3.7
workon mlflow
Install required libraries.
pip install mlflow==0.7.0 \
044865cb6f588c41fbcaad474ae636f2a57e8dcb4e514eb9ac93cc8f063016c167814032c2461b2050878e5d9b867722fe93ceeb85c873cec8d0f01fd40bde81b8;rogererill |
pyenv install 3.7.0
pyenv global 3.7.0 # Use Python 3.7
mkvirtualenv mlflow # Create a Virtual Env with Python 3.7
workon mlflow
Install required libraries.
pip install mlflow==0.7.0 \
# Running a Tracking Server | |
mlflow server \ | |
--file-store /tmp/mlflow/fileStore \ | |
--default-artifact-root s3://<bucket>/mlflow/artifacts/ \ | |
--host localhost | |
--port 5000 |
MLFLOW_TRACKING_URI=http://localhost:5000 python wine_quality.py \ | |
--alpha 0.9 | |
--l1_ration 0.5 | |
--wine_file ./data/winequality-red.csv |
with mlflow.start_run(): | |
... model ... | |
mlflow.log_param("source", wine_path) | |
mlflow.log_param("alpha", alpha) | |
mlflow.log_param("l1_ratio", l1_ratio) | |
mlflow.log_metric("rmse", rmse) | |
mlflow.log_metric("r2", r2) |
# Query Tracking Server Endpoint | |
curl -X POST \ | |
http://127.0.0.1:5005/invocations \ | |
-H 'Content-Type: application/json' \ | |
-d '[ | |
{ | |
"fixed acidity": 3.42, | |
"volatile acidity": 1.66, | |
"citric acid": 0.48, | |
"residual sugar": 4.2, |
(mlflow) afranzi:~$ pyspark | |
[I 19:05:01.572 NotebookApp] sparkmagic extension enabled! | |
[I 19:05:01.573 NotebookApp] Serving notebooks from local directory: /Users/afranzi/Projects/notebooks | |
[I 19:05:01.573 NotebookApp] The Jupyter Notebook is running at: | |
[I 19:05:01.573 NotebookApp] http://localhost:8888/?token=c06252daa6a12cfdd33c1d2e96c8d3b19d90e9f6fc171745 | |
[I 19:05:01.573 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation). | |
[C 19:05:01.574 NotebookApp] | |
Copy/paste this URL into your browser when you connect for the first time, | |
to login with a token: |
import mlflow.pyfunc | |
model_path = 's3://<bucket>/mlflow/artifacts/1/0f8691808e914d1087cf097a08730f17/artifacts/model' | |
wine_path = '/Users/afranzi/Projects/data/winequality-red.csv' | |
wine_udf = mlflow.pyfunc.spark_udf(spark, model_path) | |
df = spark.read.format("csv").option("header", "true").option('delimiter', ';').load(wine_path) | |
columns = [ "fixed acidity", "volatile acidity", "citric acid", | |
"residual sugar", "chlorides", "free sulfur dioxide", | |
"total sulfur dioxide", "density", "pH", |
# Serve a sklearn model through 127.0.0.0:5005 | |
MLFLOW_TRACKING_URI=http://0.0.0.0:5000 mlflow sklearn serve \ | |
--port 5005 \ | |
--run_id 0f8691808e914d1087cf097a08730f17 \ | |
--model-path model |