diff --git a/.github/workflows/ci-cd.yaml b/.github/workflows/ci-cd.yaml index 3edd335..e7c68a9 100644 --- a/.github/workflows/ci-cd.yaml +++ b/.github/workflows/ci-cd.yaml @@ -35,12 +35,12 @@ jobs: - name: Test with pytest run: | pytest -v -# - name: Deploy to Heroku -# env: -# HEROKU_API_TOKEN: ${{ secrets.HEROKU_API_TOKEN }} -# HEROKU_APP_NAME: ${{ secrets.HEROKU_APP_NAME }} -# if: github.ref == 'refs/heads/main' && job.status == 'success' -# run: | -# echo '-----------HEROKU_APP_NAME------------' -# git remote add heroku https://heroku:$HEROKU_API_TOKEN@git.heroku.com/$HEROKU_APP_NAME.git -# git push heroku HEAD:main -f \ No newline at end of file + - name: Deploy to Heroku + env: + HEROKU_API_TOKEN: ${{ secrets.HEROKU_API_TOKEN }} + HEROKU_APP_NAME: ${{ secrets.HEROKU_APP_NAME }} + if: github.ref == 'refs/heads/main' && job.status == 'success' + run: | + echo '-----------HEROKU_APP_NAME------------' + git remote add heroku https://heroku:$HEROKU_API_TOKEN@git.heroku.com/$HEROKU_APP_NAME.git + git push heroku HEAD:main -f \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index beeb3fd..ba15d2c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,4 +15,4 @@ RUN pip install -r requirements.txt # Run the streamlit on container startup # CMD [ "streamlit", "run","--server.enableCORS","false","imgwebapp.py" ] -CMD ["app.py"] \ No newline at end of file +CMD ["python", "app.py"] \ No newline at end of file diff --git a/ElasticNet Regression/0/c62a732627a44abdaea195e7df7365f3/artifacts/model/MLmodel b/ElasticNet Regression/0/c62a732627a44abdaea195e7df7365f3/artifacts/model/MLmodel new file mode 100644 index 0000000..b12e539 --- /dev/null +++ b/ElasticNet Regression/0/c62a732627a44abdaea195e7df7365f3/artifacts/model/MLmodel @@ -0,0 +1,14 @@ +artifact_path: model +flavors: + python_function: + env: conda.yaml + loader_module: mlflow.sklearn + model_path: model.pkl + python_version: 3.9.6 + sklearn: + pickled_model: model.pkl + serialization_format: cloudpickle + sklearn_version: 1.0.1 +model_uuid: fcec9392ebc64cd79ac53c6ea8246889 +run_id: c62a732627a44abdaea195e7df7365f3 +utc_time_created: '2022-04-06 17:43:34.425149' diff --git a/ElasticNet Regression/0/c62a732627a44abdaea195e7df7365f3/artifacts/model/conda.yaml b/ElasticNet Regression/0/c62a732627a44abdaea195e7df7365f3/artifacts/model/conda.yaml new file mode 100644 index 0000000..71b7579 --- /dev/null +++ b/ElasticNet Regression/0/c62a732627a44abdaea195e7df7365f3/artifacts/model/conda.yaml @@ -0,0 +1,11 @@ +channels: +- conda-forge +dependencies: +- python=3.9.6 +- pip +- pip: + - mlflow + - cloudpickle==2.0.0 + - psutil==5.9.0 + - scikit-learn==1.0.1 +name: mlflow-env diff --git a/ElasticNet Regression/0/c62a732627a44abdaea195e7df7365f3/artifacts/model/model.pkl b/ElasticNet Regression/0/c62a732627a44abdaea195e7df7365f3/artifacts/model/model.pkl new file mode 100644 index 0000000..c097a60 Binary files /dev/null and b/ElasticNet Regression/0/c62a732627a44abdaea195e7df7365f3/artifacts/model/model.pkl differ diff --git a/ElasticNet Regression/0/c62a732627a44abdaea195e7df7365f3/artifacts/model/requirements.txt b/ElasticNet Regression/0/c62a732627a44abdaea195e7df7365f3/artifacts/model/requirements.txt new file mode 100644 index 0000000..d81c781 --- /dev/null +++ b/ElasticNet Regression/0/c62a732627a44abdaea195e7df7365f3/artifacts/model/requirements.txt @@ -0,0 +1,4 @@ +mlflow +cloudpickle==2.0.0 +psutil==5.9.0 +scikit-learn==1.0.1 \ No newline at end of file diff --git a/ElasticNet Regression/0/c62a732627a44abdaea195e7df7365f3/meta.yaml b/ElasticNet Regression/0/c62a732627a44abdaea195e7df7365f3/meta.yaml new file mode 100644 index 0000000..4a0577f --- /dev/null +++ b/ElasticNet Regression/0/c62a732627a44abdaea195e7df7365f3/meta.yaml @@ -0,0 +1,15 @@ +artifact_uri: ElasticNet Regression/0/c62a732627a44abdaea195e7df7365f3/artifacts +end_time: 1649267016976 +entry_point_name: '' +experiment_id: '0' +lifecycle_stage: active +name: '' +run_id: c62a732627a44abdaea195e7df7365f3 +run_uuid: c62a732627a44abdaea195e7df7365f3 +source_name: '' +source_type: 4 +source_version: '' +start_time: 1649267014388 +status: 4 +tags: [] +user_id: sanand diff --git a/ElasticNet Regression/0/c62a732627a44abdaea195e7df7365f3/metrics/mae b/ElasticNet Regression/0/c62a732627a44abdaea195e7df7365f3/metrics/mae new file mode 100644 index 0000000..b4d450c --- /dev/null +++ b/ElasticNet Regression/0/c62a732627a44abdaea195e7df7365f3/metrics/mae @@ -0,0 +1 @@ +1649267014416 0.65671588782232 0 diff --git a/ElasticNet Regression/0/c62a732627a44abdaea195e7df7365f3/metrics/r2 b/ElasticNet Regression/0/c62a732627a44abdaea195e7df7365f3/metrics/r2 new file mode 100644 index 0000000..9b2949b --- /dev/null +++ b/ElasticNet Regression/0/c62a732627a44abdaea195e7df7365f3/metrics/r2 @@ -0,0 +1 @@ +1649267014418 0.009995540913424361 0 diff --git a/ElasticNet Regression/0/c62a732627a44abdaea195e7df7365f3/metrics/rmse b/ElasticNet Regression/0/c62a732627a44abdaea195e7df7365f3/metrics/rmse new file mode 100644 index 0000000..3aa8a0b --- /dev/null +++ b/ElasticNet Regression/0/c62a732627a44abdaea195e7df7365f3/metrics/rmse @@ -0,0 +1 @@ +1649267014415 0.804346762796031 0 diff --git a/ElasticNet Regression/0/c62a732627a44abdaea195e7df7365f3/params/alpha b/ElasticNet Regression/0/c62a732627a44abdaea195e7df7365f3/params/alpha new file mode 100644 index 0000000..0e2c939 --- /dev/null +++ b/ElasticNet Regression/0/c62a732627a44abdaea195e7df7365f3/params/alpha @@ -0,0 +1 @@ +0.7 \ No newline at end of file diff --git a/ElasticNet Regression/0/c62a732627a44abdaea195e7df7365f3/params/l1_ratio b/ElasticNet Regression/0/c62a732627a44abdaea195e7df7365f3/params/l1_ratio new file mode 100644 index 0000000..490f510 --- /dev/null +++ b/ElasticNet Regression/0/c62a732627a44abdaea195e7df7365f3/params/l1_ratio @@ -0,0 +1 @@ +0.6 \ No newline at end of file diff --git a/ElasticNet Regression/0/c62a732627a44abdaea195e7df7365f3/params/random_state b/ElasticNet Regression/0/c62a732627a44abdaea195e7df7365f3/params/random_state new file mode 100644 index 0000000..f70d7bb --- /dev/null +++ b/ElasticNet Regression/0/c62a732627a44abdaea195e7df7365f3/params/random_state @@ -0,0 +1 @@ +42 \ No newline at end of file diff --git a/ElasticNet Regression/0/c62a732627a44abdaea195e7df7365f3/tags/mlflow.log-model.history b/ElasticNet Regression/0/c62a732627a44abdaea195e7df7365f3/tags/mlflow.log-model.history new file mode 100644 index 0000000..162bd15 --- /dev/null +++ b/ElasticNet Regression/0/c62a732627a44abdaea195e7df7365f3/tags/mlflow.log-model.history @@ -0,0 +1 @@ +[{"run_id": "c62a732627a44abdaea195e7df7365f3", "artifact_path": "model", "utc_time_created": "2022-04-06 17:43:34.425149", "flavors": {"python_function": {"model_path": "model.pkl", "loader_module": "mlflow.sklearn", "python_version": "3.9.6", "env": "conda.yaml"}, "sklearn": {"pickled_model": "model.pkl", "sklearn_version": "1.0.1", "serialization_format": "cloudpickle"}}, "model_uuid": "fcec9392ebc64cd79ac53c6ea8246889"}] \ No newline at end of file diff --git a/ElasticNet Regression/0/c62a732627a44abdaea195e7df7365f3/tags/mlflow.runName b/ElasticNet Regression/0/c62a732627a44abdaea195e7df7365f3/tags/mlflow.runName new file mode 100644 index 0000000..e923b08 --- /dev/null +++ b/ElasticNet Regression/0/c62a732627a44abdaea195e7df7365f3/tags/mlflow.runName @@ -0,0 +1 @@ +ElasticNetWineModel \ No newline at end of file diff --git a/ElasticNet Regression/0/c62a732627a44abdaea195e7df7365f3/tags/mlflow.source.git.commit b/ElasticNet Regression/0/c62a732627a44abdaea195e7df7365f3/tags/mlflow.source.git.commit new file mode 100644 index 0000000..be5631a --- /dev/null +++ b/ElasticNet Regression/0/c62a732627a44abdaea195e7df7365f3/tags/mlflow.source.git.commit @@ -0,0 +1 @@ +e62a81860e2f9ec863a8867270843e1f5bd5a0c1 \ No newline at end of file diff --git a/ElasticNet Regression/0/c62a732627a44abdaea195e7df7365f3/tags/mlflow.source.name b/ElasticNet Regression/0/c62a732627a44abdaea195e7df7365f3/tags/mlflow.source.name new file mode 100644 index 0000000..fed2581 --- /dev/null +++ b/ElasticNet Regression/0/c62a732627a44abdaea195e7df7365f3/tags/mlflow.source.name @@ -0,0 +1 @@ +src/models/train_and_evaluate.py \ No newline at end of file diff --git a/ElasticNet Regression/0/c62a732627a44abdaea195e7df7365f3/tags/mlflow.source.type b/ElasticNet Regression/0/c62a732627a44abdaea195e7df7365f3/tags/mlflow.source.type new file mode 100644 index 0000000..0c2c1fe --- /dev/null +++ b/ElasticNet Regression/0/c62a732627a44abdaea195e7df7365f3/tags/mlflow.source.type @@ -0,0 +1 @@ +LOCAL \ No newline at end of file diff --git a/ElasticNet Regression/0/c62a732627a44abdaea195e7df7365f3/tags/mlflow.user b/ElasticNet Regression/0/c62a732627a44abdaea195e7df7365f3/tags/mlflow.user new file mode 100644 index 0000000..0a8409c --- /dev/null +++ b/ElasticNet Regression/0/c62a732627a44abdaea195e7df7365f3/tags/mlflow.user @@ -0,0 +1 @@ +sanand \ No newline at end of file diff --git a/ElasticNet Regression/0/c92363bfed564b87910fc53950a43a2e/artifacts/model/MLmodel b/ElasticNet Regression/0/c92363bfed564b87910fc53950a43a2e/artifacts/model/MLmodel new file mode 100644 index 0000000..2f74bf3 --- /dev/null +++ b/ElasticNet Regression/0/c92363bfed564b87910fc53950a43a2e/artifacts/model/MLmodel @@ -0,0 +1,14 @@ +artifact_path: model +flavors: + python_function: + env: conda.yaml + loader_module: mlflow.sklearn + model_path: model.pkl + python_version: 3.9.6 + sklearn: + pickled_model: model.pkl + serialization_format: cloudpickle + sklearn_version: 1.0.1 +model_uuid: c7cb88be9fd348ce81ee7e1f01c131ad +run_id: c92363bfed564b87910fc53950a43a2e +utc_time_created: '2022-04-06 19:29:29.121091' diff --git a/ElasticNet Regression/0/c92363bfed564b87910fc53950a43a2e/artifacts/model/conda.yaml b/ElasticNet Regression/0/c92363bfed564b87910fc53950a43a2e/artifacts/model/conda.yaml new file mode 100644 index 0000000..71b7579 --- /dev/null +++ b/ElasticNet Regression/0/c92363bfed564b87910fc53950a43a2e/artifacts/model/conda.yaml @@ -0,0 +1,11 @@ +channels: +- conda-forge +dependencies: +- python=3.9.6 +- pip +- pip: + - mlflow + - cloudpickle==2.0.0 + - psutil==5.9.0 + - scikit-learn==1.0.1 +name: mlflow-env diff --git a/ElasticNet Regression/0/c92363bfed564b87910fc53950a43a2e/artifacts/model/model.pkl b/ElasticNet Regression/0/c92363bfed564b87910fc53950a43a2e/artifacts/model/model.pkl new file mode 100644 index 0000000..c097a60 Binary files /dev/null and b/ElasticNet Regression/0/c92363bfed564b87910fc53950a43a2e/artifacts/model/model.pkl differ diff --git a/ElasticNet Regression/0/c92363bfed564b87910fc53950a43a2e/artifacts/model/requirements.txt b/ElasticNet Regression/0/c92363bfed564b87910fc53950a43a2e/artifacts/model/requirements.txt new file mode 100644 index 0000000..d81c781 --- /dev/null +++ b/ElasticNet Regression/0/c92363bfed564b87910fc53950a43a2e/artifacts/model/requirements.txt @@ -0,0 +1,4 @@ +mlflow +cloudpickle==2.0.0 +psutil==5.9.0 +scikit-learn==1.0.1 \ No newline at end of file diff --git a/ElasticNet Regression/0/c92363bfed564b87910fc53950a43a2e/meta.yaml b/ElasticNet Regression/0/c92363bfed564b87910fc53950a43a2e/meta.yaml new file mode 100644 index 0000000..66bd389 --- /dev/null +++ b/ElasticNet Regression/0/c92363bfed564b87910fc53950a43a2e/meta.yaml @@ -0,0 +1,15 @@ +artifact_uri: ElasticNet Regression/0/c92363bfed564b87910fc53950a43a2e/artifacts +end_time: 1649273371592 +entry_point_name: '' +experiment_id: '0' +lifecycle_stage: active +name: '' +run_id: c92363bfed564b87910fc53950a43a2e +run_uuid: c92363bfed564b87910fc53950a43a2e +source_name: '' +source_type: 4 +source_version: '' +start_time: 1649273369082 +status: 4 +tags: [] +user_id: sanand diff --git a/ElasticNet Regression/0/c92363bfed564b87910fc53950a43a2e/metrics/mae b/ElasticNet Regression/0/c92363bfed564b87910fc53950a43a2e/metrics/mae new file mode 100644 index 0000000..2dc739f --- /dev/null +++ b/ElasticNet Regression/0/c92363bfed564b87910fc53950a43a2e/metrics/mae @@ -0,0 +1 @@ +1649273369113 0.65671588782232 0 diff --git a/ElasticNet Regression/0/c92363bfed564b87910fc53950a43a2e/metrics/r2 b/ElasticNet Regression/0/c92363bfed564b87910fc53950a43a2e/metrics/r2 new file mode 100644 index 0000000..4d1108b --- /dev/null +++ b/ElasticNet Regression/0/c92363bfed564b87910fc53950a43a2e/metrics/r2 @@ -0,0 +1 @@ +1649273369114 0.009995540913424361 0 diff --git a/ElasticNet Regression/0/c92363bfed564b87910fc53950a43a2e/metrics/rmse b/ElasticNet Regression/0/c92363bfed564b87910fc53950a43a2e/metrics/rmse new file mode 100644 index 0000000..5783419 --- /dev/null +++ b/ElasticNet Regression/0/c92363bfed564b87910fc53950a43a2e/metrics/rmse @@ -0,0 +1 @@ +1649273369111 0.804346762796031 0 diff --git a/ElasticNet Regression/0/c92363bfed564b87910fc53950a43a2e/params/alpha b/ElasticNet Regression/0/c92363bfed564b87910fc53950a43a2e/params/alpha new file mode 100644 index 0000000..0e2c939 --- /dev/null +++ b/ElasticNet Regression/0/c92363bfed564b87910fc53950a43a2e/params/alpha @@ -0,0 +1 @@ +0.7 \ No newline at end of file diff --git a/ElasticNet Regression/0/c92363bfed564b87910fc53950a43a2e/params/l1_ratio b/ElasticNet Regression/0/c92363bfed564b87910fc53950a43a2e/params/l1_ratio new file mode 100644 index 0000000..490f510 --- /dev/null +++ b/ElasticNet Regression/0/c92363bfed564b87910fc53950a43a2e/params/l1_ratio @@ -0,0 +1 @@ +0.6 \ No newline at end of file diff --git a/ElasticNet Regression/0/c92363bfed564b87910fc53950a43a2e/params/random_state b/ElasticNet Regression/0/c92363bfed564b87910fc53950a43a2e/params/random_state new file mode 100644 index 0000000..f70d7bb --- /dev/null +++ b/ElasticNet Regression/0/c92363bfed564b87910fc53950a43a2e/params/random_state @@ -0,0 +1 @@ +42 \ No newline at end of file diff --git a/ElasticNet Regression/0/c92363bfed564b87910fc53950a43a2e/tags/mlflow.log-model.history b/ElasticNet Regression/0/c92363bfed564b87910fc53950a43a2e/tags/mlflow.log-model.history new file mode 100644 index 0000000..f0ce454 --- /dev/null +++ b/ElasticNet Regression/0/c92363bfed564b87910fc53950a43a2e/tags/mlflow.log-model.history @@ -0,0 +1 @@ +[{"run_id": "c92363bfed564b87910fc53950a43a2e", "artifact_path": "model", "utc_time_created": "2022-04-06 19:29:29.121091", "flavors": {"python_function": {"model_path": "model.pkl", "loader_module": "mlflow.sklearn", "python_version": "3.9.6", "env": "conda.yaml"}, "sklearn": {"pickled_model": "model.pkl", "sklearn_version": "1.0.1", "serialization_format": "cloudpickle"}}, "model_uuid": "c7cb88be9fd348ce81ee7e1f01c131ad"}] \ No newline at end of file diff --git a/ElasticNet Regression/0/c92363bfed564b87910fc53950a43a2e/tags/mlflow.runName b/ElasticNet Regression/0/c92363bfed564b87910fc53950a43a2e/tags/mlflow.runName new file mode 100644 index 0000000..e923b08 --- /dev/null +++ b/ElasticNet Regression/0/c92363bfed564b87910fc53950a43a2e/tags/mlflow.runName @@ -0,0 +1 @@ +ElasticNetWineModel \ No newline at end of file diff --git a/ElasticNet Regression/0/c92363bfed564b87910fc53950a43a2e/tags/mlflow.source.git.commit b/ElasticNet Regression/0/c92363bfed564b87910fc53950a43a2e/tags/mlflow.source.git.commit new file mode 100644 index 0000000..be5631a --- /dev/null +++ b/ElasticNet Regression/0/c92363bfed564b87910fc53950a43a2e/tags/mlflow.source.git.commit @@ -0,0 +1 @@ +e62a81860e2f9ec863a8867270843e1f5bd5a0c1 \ No newline at end of file diff --git a/ElasticNet Regression/0/c92363bfed564b87910fc53950a43a2e/tags/mlflow.source.name b/ElasticNet Regression/0/c92363bfed564b87910fc53950a43a2e/tags/mlflow.source.name new file mode 100644 index 0000000..fed2581 --- /dev/null +++ b/ElasticNet Regression/0/c92363bfed564b87910fc53950a43a2e/tags/mlflow.source.name @@ -0,0 +1 @@ +src/models/train_and_evaluate.py \ No newline at end of file diff --git a/ElasticNet Regression/0/c92363bfed564b87910fc53950a43a2e/tags/mlflow.source.type b/ElasticNet Regression/0/c92363bfed564b87910fc53950a43a2e/tags/mlflow.source.type new file mode 100644 index 0000000..0c2c1fe --- /dev/null +++ b/ElasticNet Regression/0/c92363bfed564b87910fc53950a43a2e/tags/mlflow.source.type @@ -0,0 +1 @@ +LOCAL \ No newline at end of file diff --git a/ElasticNet Regression/0/c92363bfed564b87910fc53950a43a2e/tags/mlflow.user b/ElasticNet Regression/0/c92363bfed564b87910fc53950a43a2e/tags/mlflow.user new file mode 100644 index 0000000..0a8409c --- /dev/null +++ b/ElasticNet Regression/0/c92363bfed564b87910fc53950a43a2e/tags/mlflow.user @@ -0,0 +1 @@ +sanand \ No newline at end of file diff --git a/ElasticNet Regression/0/meta.yaml b/ElasticNet Regression/0/meta.yaml new file mode 100644 index 0000000..617fecf --- /dev/null +++ b/ElasticNet Regression/0/meta.yaml @@ -0,0 +1,4 @@ +artifact_location: ElasticNet Regression/0 +experiment_id: '0' +lifecycle_stage: active +name: Default diff --git a/ElasticNetRegression/0/8333c552040b40a19faabc0ef5c77dfc/artifacts/model/MLmodel b/ElasticNetRegression/0/8333c552040b40a19faabc0ef5c77dfc/artifacts/model/MLmodel new file mode 100644 index 0000000..8b338e7 --- /dev/null +++ b/ElasticNetRegression/0/8333c552040b40a19faabc0ef5c77dfc/artifacts/model/MLmodel @@ -0,0 +1,14 @@ +artifact_path: model +flavors: + python_function: + env: conda.yaml + loader_module: mlflow.sklearn + model_path: model.pkl + python_version: 3.9.6 + sklearn: + pickled_model: model.pkl + serialization_format: cloudpickle + sklearn_version: 1.0.1 +model_uuid: 8b7d64fae99e4e18ac42ea03ec6e3d15 +run_id: 8333c552040b40a19faabc0ef5c77dfc +utc_time_created: '2022-04-06 17:49:37.722370' diff --git a/ElasticNetRegression/0/8333c552040b40a19faabc0ef5c77dfc/artifacts/model/conda.yaml b/ElasticNetRegression/0/8333c552040b40a19faabc0ef5c77dfc/artifacts/model/conda.yaml new file mode 100644 index 0000000..71b7579 --- /dev/null +++ b/ElasticNetRegression/0/8333c552040b40a19faabc0ef5c77dfc/artifacts/model/conda.yaml @@ -0,0 +1,11 @@ +channels: +- conda-forge +dependencies: +- python=3.9.6 +- pip +- pip: + - mlflow + - cloudpickle==2.0.0 + - psutil==5.9.0 + - scikit-learn==1.0.1 +name: mlflow-env diff --git a/ElasticNetRegression/0/8333c552040b40a19faabc0ef5c77dfc/artifacts/model/model.pkl b/ElasticNetRegression/0/8333c552040b40a19faabc0ef5c77dfc/artifacts/model/model.pkl new file mode 100644 index 0000000..c097a60 Binary files /dev/null and b/ElasticNetRegression/0/8333c552040b40a19faabc0ef5c77dfc/artifacts/model/model.pkl differ diff --git a/ElasticNetRegression/0/8333c552040b40a19faabc0ef5c77dfc/artifacts/model/requirements.txt b/ElasticNetRegression/0/8333c552040b40a19faabc0ef5c77dfc/artifacts/model/requirements.txt new file mode 100644 index 0000000..d81c781 --- /dev/null +++ b/ElasticNetRegression/0/8333c552040b40a19faabc0ef5c77dfc/artifacts/model/requirements.txt @@ -0,0 +1,4 @@ +mlflow +cloudpickle==2.0.0 +psutil==5.9.0 +scikit-learn==1.0.1 \ No newline at end of file diff --git a/ElasticNetRegression/0/8333c552040b40a19faabc0ef5c77dfc/meta.yaml b/ElasticNetRegression/0/8333c552040b40a19faabc0ef5c77dfc/meta.yaml new file mode 100644 index 0000000..e3dc92b --- /dev/null +++ b/ElasticNetRegression/0/8333c552040b40a19faabc0ef5c77dfc/meta.yaml @@ -0,0 +1,15 @@ +artifact_uri: ElasticNetRegression/0/8333c552040b40a19faabc0ef5c77dfc/artifacts +end_time: 1649267380172 +entry_point_name: '' +experiment_id: '0' +lifecycle_stage: active +name: '' +run_id: 8333c552040b40a19faabc0ef5c77dfc +run_uuid: 8333c552040b40a19faabc0ef5c77dfc +source_name: '' +source_type: 4 +source_version: '' +start_time: 1649267377685 +status: 4 +tags: [] +user_id: sanand diff --git a/ElasticNetRegression/0/8333c552040b40a19faabc0ef5c77dfc/metrics/mae b/ElasticNetRegression/0/8333c552040b40a19faabc0ef5c77dfc/metrics/mae new file mode 100644 index 0000000..f615336 --- /dev/null +++ b/ElasticNetRegression/0/8333c552040b40a19faabc0ef5c77dfc/metrics/mae @@ -0,0 +1 @@ +1649267377713 0.65671588782232 0 diff --git a/ElasticNetRegression/0/8333c552040b40a19faabc0ef5c77dfc/metrics/r2 b/ElasticNetRegression/0/8333c552040b40a19faabc0ef5c77dfc/metrics/r2 new file mode 100644 index 0000000..e02008b --- /dev/null +++ b/ElasticNetRegression/0/8333c552040b40a19faabc0ef5c77dfc/metrics/r2 @@ -0,0 +1 @@ +1649267377714 0.009995540913424361 0 diff --git a/ElasticNetRegression/0/8333c552040b40a19faabc0ef5c77dfc/metrics/rmse b/ElasticNetRegression/0/8333c552040b40a19faabc0ef5c77dfc/metrics/rmse new file mode 100644 index 0000000..501acaa --- /dev/null +++ b/ElasticNetRegression/0/8333c552040b40a19faabc0ef5c77dfc/metrics/rmse @@ -0,0 +1 @@ +1649267377711 0.804346762796031 0 diff --git a/ElasticNetRegression/0/8333c552040b40a19faabc0ef5c77dfc/params/alpha b/ElasticNetRegression/0/8333c552040b40a19faabc0ef5c77dfc/params/alpha new file mode 100644 index 0000000..0e2c939 --- /dev/null +++ b/ElasticNetRegression/0/8333c552040b40a19faabc0ef5c77dfc/params/alpha @@ -0,0 +1 @@ +0.7 \ No newline at end of file diff --git a/ElasticNetRegression/0/8333c552040b40a19faabc0ef5c77dfc/params/l1_ratio b/ElasticNetRegression/0/8333c552040b40a19faabc0ef5c77dfc/params/l1_ratio new file mode 100644 index 0000000..490f510 --- /dev/null +++ b/ElasticNetRegression/0/8333c552040b40a19faabc0ef5c77dfc/params/l1_ratio @@ -0,0 +1 @@ +0.6 \ No newline at end of file diff --git a/ElasticNetRegression/0/8333c552040b40a19faabc0ef5c77dfc/params/random_state b/ElasticNetRegression/0/8333c552040b40a19faabc0ef5c77dfc/params/random_state new file mode 100644 index 0000000..f70d7bb --- /dev/null +++ b/ElasticNetRegression/0/8333c552040b40a19faabc0ef5c77dfc/params/random_state @@ -0,0 +1 @@ +42 \ No newline at end of file diff --git a/ElasticNetRegression/0/8333c552040b40a19faabc0ef5c77dfc/tags/mlflow.log-model.history b/ElasticNetRegression/0/8333c552040b40a19faabc0ef5c77dfc/tags/mlflow.log-model.history new file mode 100644 index 0000000..032c5a2 --- /dev/null +++ b/ElasticNetRegression/0/8333c552040b40a19faabc0ef5c77dfc/tags/mlflow.log-model.history @@ -0,0 +1 @@ +[{"run_id": "8333c552040b40a19faabc0ef5c77dfc", "artifact_path": "model", "utc_time_created": "2022-04-06 17:49:37.722370", "flavors": {"python_function": {"model_path": "model.pkl", "loader_module": "mlflow.sklearn", "python_version": "3.9.6", "env": "conda.yaml"}, "sklearn": {"pickled_model": "model.pkl", "sklearn_version": "1.0.1", "serialization_format": "cloudpickle"}}, "model_uuid": "8b7d64fae99e4e18ac42ea03ec6e3d15"}] \ No newline at end of file diff --git a/ElasticNetRegression/0/8333c552040b40a19faabc0ef5c77dfc/tags/mlflow.runName b/ElasticNetRegression/0/8333c552040b40a19faabc0ef5c77dfc/tags/mlflow.runName new file mode 100644 index 0000000..e923b08 --- /dev/null +++ b/ElasticNetRegression/0/8333c552040b40a19faabc0ef5c77dfc/tags/mlflow.runName @@ -0,0 +1 @@ +ElasticNetWineModel \ No newline at end of file diff --git a/ElasticNetRegression/0/8333c552040b40a19faabc0ef5c77dfc/tags/mlflow.source.git.commit b/ElasticNetRegression/0/8333c552040b40a19faabc0ef5c77dfc/tags/mlflow.source.git.commit new file mode 100644 index 0000000..be5631a --- /dev/null +++ b/ElasticNetRegression/0/8333c552040b40a19faabc0ef5c77dfc/tags/mlflow.source.git.commit @@ -0,0 +1 @@ +e62a81860e2f9ec863a8867270843e1f5bd5a0c1 \ No newline at end of file diff --git a/ElasticNetRegression/0/8333c552040b40a19faabc0ef5c77dfc/tags/mlflow.source.name b/ElasticNetRegression/0/8333c552040b40a19faabc0ef5c77dfc/tags/mlflow.source.name new file mode 100644 index 0000000..fed2581 --- /dev/null +++ b/ElasticNetRegression/0/8333c552040b40a19faabc0ef5c77dfc/tags/mlflow.source.name @@ -0,0 +1 @@ +src/models/train_and_evaluate.py \ No newline at end of file diff --git a/ElasticNetRegression/0/8333c552040b40a19faabc0ef5c77dfc/tags/mlflow.source.type b/ElasticNetRegression/0/8333c552040b40a19faabc0ef5c77dfc/tags/mlflow.source.type new file mode 100644 index 0000000..0c2c1fe --- /dev/null +++ b/ElasticNetRegression/0/8333c552040b40a19faabc0ef5c77dfc/tags/mlflow.source.type @@ -0,0 +1 @@ +LOCAL \ No newline at end of file diff --git a/ElasticNetRegression/0/8333c552040b40a19faabc0ef5c77dfc/tags/mlflow.user b/ElasticNetRegression/0/8333c552040b40a19faabc0ef5c77dfc/tags/mlflow.user new file mode 100644 index 0000000..0a8409c --- /dev/null +++ b/ElasticNetRegression/0/8333c552040b40a19faabc0ef5c77dfc/tags/mlflow.user @@ -0,0 +1 @@ +sanand \ No newline at end of file diff --git a/ElasticNetRegression/0/meta.yaml b/ElasticNetRegression/0/meta.yaml new file mode 100644 index 0000000..9583375 --- /dev/null +++ b/ElasticNetRegression/0/meta.yaml @@ -0,0 +1,4 @@ +artifact_location: ElasticNetRegression/0 +experiment_id: '0' +lifecycle_stage: active +name: Default diff --git a/README.md b/README.md index 7b52abb..8738520 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,17 @@ -mlops_demo -============================== +Model Development and Productionization +======================================= + |-- Project Organization + |  | <- Cookiecutter `https://cookiecutter.readthedocs.io/en/stable/` + |-- Data Version Control + |  | <- DVC `https://dvc.org/` + |-- CI+CD - Github + |-- Model Productionization/Deployment + |  |-- UI <- Flask + |  |-- Scalability and high availability <- k8 + |-- FeedBack and Retrain + + -Mlops demo Project Organization ------------ @@ -73,4 +83,10 @@ Project Organization `6. search for cloud build >> trigger`
```7. gcloud projects add-iam-policy-binding hft-demo-v1 --member=serviceAccount:1009805620509@cloudbuild.gserviceaccount.com --role=roles/container.developer```
`8. k8s deploy`
-`9. k8s failing due to permission issue and time out`
\ No newline at end of file +`9. k8s failing due to permission issue and time out`
+`10. Configure terraform for k8s creation: https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/guides/getting-started` + + +`Ml flow execute--` + +`mlflow server --backend-store-uri sqlite:///mlflow.db --default-artifact-root ./artifact --host 0.0.0.0 -p 123` diff --git a/app.py b/app.py index a5b2801..b26de11 100644 --- a/app.py +++ b/app.py @@ -34,4 +34,4 @@ def index(): if __name__ == "__main__": - app.run(host='0.0.0.0', port=5001, debug=True) + app.run(host='0.0.0.0', port=5000, debug=True) diff --git a/artifact/0/12d1df0e748445e3827d2c5bca9a255b/artifacts/model/MLmodel b/artifact/0/12d1df0e748445e3827d2c5bca9a255b/artifacts/model/MLmodel new file mode 100644 index 0000000..7348159 --- /dev/null +++ b/artifact/0/12d1df0e748445e3827d2c5bca9a255b/artifacts/model/MLmodel @@ -0,0 +1,14 @@ +artifact_path: model +flavors: + python_function: + env: conda.yaml + loader_module: mlflow.sklearn + model_path: model.pkl + python_version: 3.9.6 + sklearn: + pickled_model: model.pkl + serialization_format: cloudpickle + sklearn_version: 1.0.1 +model_uuid: ef2527ce53194b8d97def52f652735a9 +run_id: 12d1df0e748445e3827d2c5bca9a255b +utc_time_created: '2022-04-06 19:51:30.072091' diff --git a/artifact/0/12d1df0e748445e3827d2c5bca9a255b/artifacts/model/conda.yaml b/artifact/0/12d1df0e748445e3827d2c5bca9a255b/artifacts/model/conda.yaml new file mode 100644 index 0000000..71b7579 --- /dev/null +++ b/artifact/0/12d1df0e748445e3827d2c5bca9a255b/artifacts/model/conda.yaml @@ -0,0 +1,11 @@ +channels: +- conda-forge +dependencies: +- python=3.9.6 +- pip +- pip: + - mlflow + - cloudpickle==2.0.0 + - psutil==5.9.0 + - scikit-learn==1.0.1 +name: mlflow-env diff --git a/artifact/0/12d1df0e748445e3827d2c5bca9a255b/artifacts/model/model.pkl b/artifact/0/12d1df0e748445e3827d2c5bca9a255b/artifacts/model/model.pkl new file mode 100644 index 0000000..cc12e1b Binary files /dev/null and b/artifact/0/12d1df0e748445e3827d2c5bca9a255b/artifacts/model/model.pkl differ diff --git a/artifact/0/12d1df0e748445e3827d2c5bca9a255b/artifacts/model/requirements.txt b/artifact/0/12d1df0e748445e3827d2c5bca9a255b/artifacts/model/requirements.txt new file mode 100644 index 0000000..d81c781 --- /dev/null +++ b/artifact/0/12d1df0e748445e3827d2c5bca9a255b/artifacts/model/requirements.txt @@ -0,0 +1,4 @@ +mlflow +cloudpickle==2.0.0 +psutil==5.9.0 +scikit-learn==1.0.1 \ No newline at end of file diff --git a/artifact/0/c97263c68b474462b4a0532fb88c042c/artifacts/model/MLmodel b/artifact/0/c97263c68b474462b4a0532fb88c042c/artifacts/model/MLmodel new file mode 100644 index 0000000..02a4bca --- /dev/null +++ b/artifact/0/c97263c68b474462b4a0532fb88c042c/artifacts/model/MLmodel @@ -0,0 +1,14 @@ +artifact_path: model +flavors: + python_function: + env: conda.yaml + loader_module: mlflow.sklearn + model_path: model.pkl + python_version: 3.9.6 + sklearn: + pickled_model: model.pkl + serialization_format: cloudpickle + sklearn_version: 1.0.1 +model_uuid: 96b3a88e1fc24b838149a9bd8d7c829e +run_id: c97263c68b474462b4a0532fb88c042c +utc_time_created: '2022-04-06 19:50:48.751639' diff --git a/artifact/0/c97263c68b474462b4a0532fb88c042c/artifacts/model/conda.yaml b/artifact/0/c97263c68b474462b4a0532fb88c042c/artifacts/model/conda.yaml new file mode 100644 index 0000000..71b7579 --- /dev/null +++ b/artifact/0/c97263c68b474462b4a0532fb88c042c/artifacts/model/conda.yaml @@ -0,0 +1,11 @@ +channels: +- conda-forge +dependencies: +- python=3.9.6 +- pip +- pip: + - mlflow + - cloudpickle==2.0.0 + - psutil==5.9.0 + - scikit-learn==1.0.1 +name: mlflow-env diff --git a/artifact/0/c97263c68b474462b4a0532fb88c042c/artifacts/model/model.pkl b/artifact/0/c97263c68b474462b4a0532fb88c042c/artifacts/model/model.pkl new file mode 100644 index 0000000..4a673ab Binary files /dev/null and b/artifact/0/c97263c68b474462b4a0532fb88c042c/artifacts/model/model.pkl differ diff --git a/artifact/0/c97263c68b474462b4a0532fb88c042c/artifacts/model/requirements.txt b/artifact/0/c97263c68b474462b4a0532fb88c042c/artifacts/model/requirements.txt new file mode 100644 index 0000000..d81c781 --- /dev/null +++ b/artifact/0/c97263c68b474462b4a0532fb88c042c/artifacts/model/requirements.txt @@ -0,0 +1,4 @@ +mlflow +cloudpickle==2.0.0 +psutil==5.9.0 +scikit-learn==1.0.1 \ No newline at end of file diff --git a/artifact/0/eb44230131a3440184b2eed818a8a29f/artifacts/model/MLmodel b/artifact/0/eb44230131a3440184b2eed818a8a29f/artifacts/model/MLmodel new file mode 100644 index 0000000..b703153 --- /dev/null +++ b/artifact/0/eb44230131a3440184b2eed818a8a29f/artifacts/model/MLmodel @@ -0,0 +1,14 @@ +artifact_path: model +flavors: + python_function: + env: conda.yaml + loader_module: mlflow.sklearn + model_path: model.pkl + python_version: 3.9.6 + sklearn: + pickled_model: model.pkl + serialization_format: cloudpickle + sklearn_version: 1.0.1 +model_uuid: 9babf11a6a334d6385a2b4c4cb550d32 +run_id: eb44230131a3440184b2eed818a8a29f +utc_time_created: '2022-04-06 19:43:52.125540' diff --git a/artifact/0/eb44230131a3440184b2eed818a8a29f/artifacts/model/conda.yaml b/artifact/0/eb44230131a3440184b2eed818a8a29f/artifacts/model/conda.yaml new file mode 100644 index 0000000..71b7579 --- /dev/null +++ b/artifact/0/eb44230131a3440184b2eed818a8a29f/artifacts/model/conda.yaml @@ -0,0 +1,11 @@ +channels: +- conda-forge +dependencies: +- python=3.9.6 +- pip +- pip: + - mlflow + - cloudpickle==2.0.0 + - psutil==5.9.0 + - scikit-learn==1.0.1 +name: mlflow-env diff --git a/artifact/0/eb44230131a3440184b2eed818a8a29f/artifacts/model/model.pkl b/artifact/0/eb44230131a3440184b2eed818a8a29f/artifacts/model/model.pkl new file mode 100644 index 0000000..c097a60 Binary files /dev/null and b/artifact/0/eb44230131a3440184b2eed818a8a29f/artifacts/model/model.pkl differ diff --git a/artifact/0/eb44230131a3440184b2eed818a8a29f/artifacts/model/requirements.txt b/artifact/0/eb44230131a3440184b2eed818a8a29f/artifacts/model/requirements.txt new file mode 100644 index 0000000..d81c781 --- /dev/null +++ b/artifact/0/eb44230131a3440184b2eed818a8a29f/artifacts/model/requirements.txt @@ -0,0 +1,4 @@ +mlflow +cloudpickle==2.0.0 +psutil==5.9.0 +scikit-learn==1.0.1 \ No newline at end of file diff --git a/cloudbuild.yaml b/cloudbuild.yaml index 55747d1..837a590 100644 --- a/cloudbuild.yaml +++ b/cloudbuild.yaml @@ -16,5 +16,5 @@ steps: args: - run - --filename=k8s/ - - --location=us-central1 - - --cluster=project-kube \ No newline at end of file + - --location=us-central1-c + - --cluster=cluster-1 \ No newline at end of file diff --git a/dvc.lock b/dvc.lock index ed367bb..fadaaf7 100644 --- a/dvc.lock +++ b/dvc.lock @@ -42,19 +42,9 @@ stages: md5: 4bccf4d668cdc60115de42ba74d416ab size: 73633 - path: src/models/train_and_evaluate.py - md5: 083a6dec1e88d14ef3d3f6bae884d0f2 - size: 2595 + md5: fec02c33e6a15841483e9e9d3a2644a3 + size: 3743 params: params.yaml: - estimators.ElasticNet.params.alpha: 0.7 - estimators.ElasticNet.params.l1_ratio: 0.6 - outs: - - path: reports/params.json - md5: 9dc2dd9706ecb1c0081606f89ed6c3fd - size: 41 - - path: reports/scores.json - md5: be91abfd048b50107487d84e15650395 - size: 94 - - path: saved_models/model.joblib - md5: 0f57432f71bb31812b01aa1b9b1426b3 - size: 1227 + estimators.ElasticNet.params.alpha: 0.5 + estimators.ElasticNet.params.l1_ratio: 0.5 diff --git a/dvc.yaml b/dvc.yaml index 347a263..af52349 100644 --- a/dvc.yaml +++ b/dvc.yaml @@ -26,10 +26,14 @@ stages: params: - estimators.ElasticNet.params.alpha - estimators.ElasticNet.params.l1_ratio - metrics: - - reports/scores.json: - cache: false - - reports/params.json: - cache: false - outs: - - saved_models/model.joblib \ No newline at end of file +# metrics: +# - reports/scores.json: +# cache: false +# - reports/params.json: +# cache: false +# log_production_model: +# cmd: python src/models/log_production_model.py --config=params.yaml +# deps: +# - src/models/log_production_model.py +# outs: +# - saved_models/model.joblib \ No newline at end of file diff --git a/k8s/deployment.yaml b/k8s/deployment.yaml index 0a296cf..bbabe53 100644 --- a/k8s/deployment.yaml +++ b/k8s/deployment.yaml @@ -14,6 +14,6 @@ spec: spec: containers: - name: wineq - image: gcr.io/mlops-346119/wineq:v1 + image: gcr.io/ppradhan/wineq:v1 ports: - - containerPort: 5001 \ No newline at end of file + - containerPort: 5000 \ No newline at end of file diff --git a/k8s/service.yaml b/k8s/service.yaml index acee503..f165af5 100644 --- a/k8s/service.yaml +++ b/k8s/service.yaml @@ -8,4 +8,4 @@ spec: app: wineq ports: - port: 80 - targetPort: 5001 \ No newline at end of file + targetPort: 5000 \ No newline at end of file diff --git a/mlruns/0/meta.yaml b/mlruns/0/meta.yaml new file mode 100644 index 0000000..b0c0370 --- /dev/null +++ b/mlruns/0/meta.yaml @@ -0,0 +1,4 @@ +artifact_location: ./mlruns/0 +experiment_id: '0' +lifecycle_stage: active +name: Default diff --git a/params.yaml b/params.yaml index 37c3731..fa29049 100644 --- a/params.yaml +++ b/params.yaml @@ -19,12 +19,21 @@ estimators: params: # alpha: 0.88 # l1_ratio: 0.89 - alpha: 0.7 - l1_ratio: 0.6 +# alpha: 0.7 +# l1_ratio: 0.6 + alpha: 0.5 + l1_ratio: 0.5 model_dir: saved_models reports: params: reports/params.json scores: reports/scores.json -webapp_model_dir: prediction_service/model/model.joblib \ No newline at end of file +webapp_model_dir: prediction_service/model/model.joblib + +mlflow_config: + artifcats_dir: artifacts + experiment_name: ElasticNet Regression + run_name: mlops + registered_model_name: ElasticNetWineModel + remote_server_uri: http://0.0.0.0:1234 \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 2ad9e4c..bc0d047 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,4 +10,13 @@ pytest tox flake8 flask -gunicorn \ No newline at end of file +gunicorn +mlflow +flask_sqlalchemy +click +Sphinx +coverage +awscli +hyperopt +python-dotenv>=0.5.1 +jsonschema~=3.0 \ No newline at end of file diff --git a/sqlite/0/669d9c627a624e21a639b85189464b94/artifacts/model/MLmodel b/sqlite/0/669d9c627a624e21a639b85189464b94/artifacts/model/MLmodel new file mode 100644 index 0000000..5ac2951 --- /dev/null +++ b/sqlite/0/669d9c627a624e21a639b85189464b94/artifacts/model/MLmodel @@ -0,0 +1,14 @@ +artifact_path: model +flavors: + python_function: + env: conda.yaml + loader_module: mlflow.sklearn + model_path: model.pkl + python_version: 3.9.6 + sklearn: + pickled_model: model.pkl + serialization_format: cloudpickle + sklearn_version: 1.0.1 +model_uuid: 6a315952d75449129c4de55aa8fbce70 +run_id: 669d9c627a624e21a639b85189464b94 +utc_time_created: '2022-04-06 19:30:23.697220' diff --git a/sqlite/0/669d9c627a624e21a639b85189464b94/artifacts/model/conda.yaml b/sqlite/0/669d9c627a624e21a639b85189464b94/artifacts/model/conda.yaml new file mode 100644 index 0000000..71b7579 --- /dev/null +++ b/sqlite/0/669d9c627a624e21a639b85189464b94/artifacts/model/conda.yaml @@ -0,0 +1,11 @@ +channels: +- conda-forge +dependencies: +- python=3.9.6 +- pip +- pip: + - mlflow + - cloudpickle==2.0.0 + - psutil==5.9.0 + - scikit-learn==1.0.1 +name: mlflow-env diff --git a/sqlite/0/669d9c627a624e21a639b85189464b94/artifacts/model/model.pkl b/sqlite/0/669d9c627a624e21a639b85189464b94/artifacts/model/model.pkl new file mode 100644 index 0000000..c097a60 Binary files /dev/null and b/sqlite/0/669d9c627a624e21a639b85189464b94/artifacts/model/model.pkl differ diff --git a/sqlite/0/669d9c627a624e21a639b85189464b94/artifacts/model/requirements.txt b/sqlite/0/669d9c627a624e21a639b85189464b94/artifacts/model/requirements.txt new file mode 100644 index 0000000..d81c781 --- /dev/null +++ b/sqlite/0/669d9c627a624e21a639b85189464b94/artifacts/model/requirements.txt @@ -0,0 +1,4 @@ +mlflow +cloudpickle==2.0.0 +psutil==5.9.0 +scikit-learn==1.0.1 \ No newline at end of file diff --git a/sqlite/0/669d9c627a624e21a639b85189464b94/meta.yaml b/sqlite/0/669d9c627a624e21a639b85189464b94/meta.yaml new file mode 100644 index 0000000..1601bcc --- /dev/null +++ b/sqlite/0/669d9c627a624e21a639b85189464b94/meta.yaml @@ -0,0 +1,15 @@ +artifact_uri: sqlite/0/669d9c627a624e21a639b85189464b94/artifacts +end_time: 1649273426193 +entry_point_name: '' +experiment_id: '0' +lifecycle_stage: active +name: '' +run_id: 669d9c627a624e21a639b85189464b94 +run_uuid: 669d9c627a624e21a639b85189464b94 +source_name: '' +source_type: 4 +source_version: '' +start_time: 1649273423661 +status: 4 +tags: [] +user_id: sanand diff --git a/sqlite/0/669d9c627a624e21a639b85189464b94/metrics/mae b/sqlite/0/669d9c627a624e21a639b85189464b94/metrics/mae new file mode 100644 index 0000000..2152698 --- /dev/null +++ b/sqlite/0/669d9c627a624e21a639b85189464b94/metrics/mae @@ -0,0 +1 @@ +1649273423689 0.65671588782232 0 diff --git a/sqlite/0/669d9c627a624e21a639b85189464b94/metrics/r2 b/sqlite/0/669d9c627a624e21a639b85189464b94/metrics/r2 new file mode 100644 index 0000000..b6b5a42 --- /dev/null +++ b/sqlite/0/669d9c627a624e21a639b85189464b94/metrics/r2 @@ -0,0 +1 @@ +1649273423690 0.009995540913424361 0 diff --git a/sqlite/0/669d9c627a624e21a639b85189464b94/metrics/rmse b/sqlite/0/669d9c627a624e21a639b85189464b94/metrics/rmse new file mode 100644 index 0000000..69619ff --- /dev/null +++ b/sqlite/0/669d9c627a624e21a639b85189464b94/metrics/rmse @@ -0,0 +1 @@ +1649273423688 0.804346762796031 0 diff --git a/sqlite/0/669d9c627a624e21a639b85189464b94/params/alpha b/sqlite/0/669d9c627a624e21a639b85189464b94/params/alpha new file mode 100644 index 0000000..0e2c939 --- /dev/null +++ b/sqlite/0/669d9c627a624e21a639b85189464b94/params/alpha @@ -0,0 +1 @@ +0.7 \ No newline at end of file diff --git a/sqlite/0/669d9c627a624e21a639b85189464b94/params/l1_ratio b/sqlite/0/669d9c627a624e21a639b85189464b94/params/l1_ratio new file mode 100644 index 0000000..490f510 --- /dev/null +++ b/sqlite/0/669d9c627a624e21a639b85189464b94/params/l1_ratio @@ -0,0 +1 @@ +0.6 \ No newline at end of file diff --git a/sqlite/0/669d9c627a624e21a639b85189464b94/params/random_state b/sqlite/0/669d9c627a624e21a639b85189464b94/params/random_state new file mode 100644 index 0000000..f70d7bb --- /dev/null +++ b/sqlite/0/669d9c627a624e21a639b85189464b94/params/random_state @@ -0,0 +1 @@ +42 \ No newline at end of file diff --git a/sqlite/0/669d9c627a624e21a639b85189464b94/tags/mlflow.log-model.history b/sqlite/0/669d9c627a624e21a639b85189464b94/tags/mlflow.log-model.history new file mode 100644 index 0000000..bfd17c6 --- /dev/null +++ b/sqlite/0/669d9c627a624e21a639b85189464b94/tags/mlflow.log-model.history @@ -0,0 +1 @@ +[{"run_id": "669d9c627a624e21a639b85189464b94", "artifact_path": "model", "utc_time_created": "2022-04-06 19:30:23.697220", "flavors": {"python_function": {"model_path": "model.pkl", "loader_module": "mlflow.sklearn", "python_version": "3.9.6", "env": "conda.yaml"}, "sklearn": {"pickled_model": "model.pkl", "sklearn_version": "1.0.1", "serialization_format": "cloudpickle"}}, "model_uuid": "6a315952d75449129c4de55aa8fbce70"}] \ No newline at end of file diff --git a/sqlite/0/669d9c627a624e21a639b85189464b94/tags/mlflow.runName b/sqlite/0/669d9c627a624e21a639b85189464b94/tags/mlflow.runName new file mode 100644 index 0000000..e923b08 --- /dev/null +++ b/sqlite/0/669d9c627a624e21a639b85189464b94/tags/mlflow.runName @@ -0,0 +1 @@ +ElasticNetWineModel \ No newline at end of file diff --git a/sqlite/0/669d9c627a624e21a639b85189464b94/tags/mlflow.source.git.commit b/sqlite/0/669d9c627a624e21a639b85189464b94/tags/mlflow.source.git.commit new file mode 100644 index 0000000..be5631a --- /dev/null +++ b/sqlite/0/669d9c627a624e21a639b85189464b94/tags/mlflow.source.git.commit @@ -0,0 +1 @@ +e62a81860e2f9ec863a8867270843e1f5bd5a0c1 \ No newline at end of file diff --git a/sqlite/0/669d9c627a624e21a639b85189464b94/tags/mlflow.source.name b/sqlite/0/669d9c627a624e21a639b85189464b94/tags/mlflow.source.name new file mode 100644 index 0000000..fed2581 --- /dev/null +++ b/sqlite/0/669d9c627a624e21a639b85189464b94/tags/mlflow.source.name @@ -0,0 +1 @@ +src/models/train_and_evaluate.py \ No newline at end of file diff --git a/sqlite/0/669d9c627a624e21a639b85189464b94/tags/mlflow.source.type b/sqlite/0/669d9c627a624e21a639b85189464b94/tags/mlflow.source.type new file mode 100644 index 0000000..0c2c1fe --- /dev/null +++ b/sqlite/0/669d9c627a624e21a639b85189464b94/tags/mlflow.source.type @@ -0,0 +1 @@ +LOCAL \ No newline at end of file diff --git a/sqlite/0/669d9c627a624e21a639b85189464b94/tags/mlflow.user b/sqlite/0/669d9c627a624e21a639b85189464b94/tags/mlflow.user new file mode 100644 index 0000000..0a8409c --- /dev/null +++ b/sqlite/0/669d9c627a624e21a639b85189464b94/tags/mlflow.user @@ -0,0 +1 @@ +sanand \ No newline at end of file diff --git a/sqlite/0/meta.yaml b/sqlite/0/meta.yaml new file mode 100644 index 0000000..a1ba4be --- /dev/null +++ b/sqlite/0/meta.yaml @@ -0,0 +1,4 @@ +artifact_location: sqlite/0 +experiment_id: '0' +lifecycle_stage: active +name: Default diff --git a/src/models/log_production_model.py b/src/models/log_production_model.py new file mode 100644 index 0000000..e69de29 diff --git a/src/models/train_and_evaluate.py b/src/models/train_and_evaluate.py index d473254..2bc2254 100644 --- a/src/models/train_and_evaluate.py +++ b/src/models/train_and_evaluate.py @@ -4,11 +4,14 @@ import os import warnings import sys +from urllib.parse import urlparse + import pandas as pd import numpy as np from sklearn.metrics import mean_squared_error, mean_absolute_error, r2_score from sklearn.model_selection import train_test_split from sklearn.linear_model import ElasticNet +import mlflow import argparse import joblib import json @@ -44,49 +47,70 @@ def train_and_evaluate(config_path): train_x = train.drop(target, axis=1) test_x = test.drop(target, axis=1) - lr = ElasticNet( - alpha=alpha, - l1_ratio=l1_ratio, - random_state=random_state) - lr.fit(train_x, train_y) - - predicted_qualities = lr.predict(test_x) - - (rmse, mae, r2) = eval_metrics(test_y, predicted_qualities) - - print("Elasticnet model (alpha=%f, l1_ratio=%f):" % (alpha, l1_ratio)) - print(" RMSE: %s" % rmse) - print(" MAE: %s" % mae) - print(" R2: %s" % r2) - - ##################################################### - scores_file = config["reports"]["scores"] - params_file = config["reports"]["params"] - - with open(scores_file, "w") as f: - scores = { - "rmse": rmse, - "mae": mae, - "r2": r2 - } - json.dump(scores, f, indent=4) - - with open(params_file, "w") as f: - params = { - "alpha": alpha, - "l1_ratio": l1_ratio, - } - json.dump(params, f, indent=4) - ##################################################### - - os.makedirs(model_dir, exist_ok=True) - model_path = os.path.join(model_dir, "model.joblib") - - joblib.dump(lr, model_path) + mlflow_config = config["mlflow_config"] + print("mlflow_config", mlflow_config) + remote_server_uri = mlflow_config["remote_server_uri"] + mlflow.set_tracking_uri(remote_server_uri) + + with mlflow.start_run(run_name=mlflow_config["registered_model_name"]) as mlops_run: + lr = ElasticNet( + alpha=alpha, + l1_ratio=l1_ratio, + random_state=random_state) + lr.fit(train_x, train_y) + + predicted_qualities = lr.predict(test_x) + + (rmse, mae, r2) = eval_metrics(test_y, predicted_qualities) + + # print("Elasticnet model (alpha=%f, l1_ratio=%f):" % (alpha, l1_ratio)) + # print(" RMSE: %s" % rmse) + # print(" MAE: %s" % mae) + # print(" R2: %s" % r2) + + # ##################################################### + # scores_file = config["reports"]["scores"] + # params_file = config["reports"]["params"] + # + # with open(scores_file, "w") as f: + # scores = { + # "rmse": rmse, + # "mae": mae, + # "r2": r2 + # } + # json.dump(scores, f, indent=4) + # + # with open(params_file, "w") as f: + # params = { + # "alpha": alpha, + # "l1_ratio": l1_ratio, + # } + # json.dump(params, f, indent=4) + # ##################################################### + + mlflow.log_param("alpha", alpha) + mlflow.log_param("l1_ratio", l1_ratio) + mlflow.log_param("random_state", random_state) + mlflow.log_metric("rmse", rmse) + mlflow.log_metric("mae", mae) + mlflow.log_metric("r2", r2) + + os.makedirs(model_dir, exist_ok=True) + model_path = os.path.join(model_dir, "model.joblib") + + joblib.dump(lr, model_path) + + tracking_url_type_store = urlparse(mlflow.get_artifact_uri()).scheme + if tracking_url_type_store != "file": + mlflow.sklearn.log_model(lr, + "model", + registered_model_name=mlflow_config["registered_model_name"]) + else: + mlflow.sklearn.log_model(lr, "model") if __name__ == "__main__": args = argparse.ArgumentParser() args.add_argument("--config", default="params.yaml") parsed_args = args.parse_args() - train_and_evaluate(config_path=parsed_args.config) \ No newline at end of file + train_and_evaluate(config_path=parsed_args.config) diff --git a/tests/test.py b/tests/test.py new file mode 100644 index 0000000..833ba38 --- /dev/null +++ b/tests/test.py @@ -0,0 +1,24 @@ +# define an objective function +def objective(args): + case, val = args + if case == 'case 1': + return val + else: + return val ** 2 + +# define a search space +from hyperopt import hp +space = hp.choice('a', + [ + ('case 1', 1 + hp.lognormal('c1', 0, 1)), + ('case 2', hp.uniform('c2', -10, 10)) + ]) + +# minimize the objective over the space +from hyperopt import fmin, tpe, space_eval +best = fmin(objective, space, algo=tpe.suggest, max_evals=100) + +print(best) +# -> {'a': 1, 'c2': 0.01420615366247227} +print(space_eval(space, best)) +# -> ('case 2', 0.01420615366247227} \ No newline at end of file