Homework for RS School Machine Learning course.
This work uses Forest Cover Type Prediction dataset.
This package allows you to train model to predict the forest cover type (the predominant kind of tree cover) from strictly cartographic variables.
- Clone this repository to your machine.
- Download Forest Cover Type Prediction dataset, save csv locally (default path is data/train.csv in repository's root).
- Make sure Python 3.8 and Poetry are installed on your machine (I use Poetry 1.1.13).
- Install the project dependencies (run this and following commands in a terminal, from the root of a cloned repository):
poetry install --no-dev
- Run train with the following command:
poetry run train -d <path to csv with data> -s <path to save trained model>
Additional options:
Command | Type | Description |
---|---|---|
-d, --dataset-path | FILE | [default: data/train.csv] |
-s, --save-model-path | FILE | [default: data/model.joblib] |
--random-state | INTEGER | [default: 42] |
--clf-type | TEXT | [default: ExtraTreesClassifier] |
--use-scaler | BOOLEAN | [default: True] |
-f, --use-feat-engineering | BOOLEAN | [default: False] |
-param, --model-param | TEXT | Model parameters set in the form of a dict like: -param "'n_estimators': 5, 'max_depth': 10" |
--help | Show full list of options in CLI. |
You can configure additional options (such as hyperparameters) in the CLI. To get a full list of them, use help:
poetry run train --help
- Run MLflow UI to see the information about experiments you conducted:
poetry run mlflow ui
You can see the results of your experiments in the MLFlow UI. For example, my experimental results obtained during the execution of the work:
- Run EDA with the following command:
poetry run eda -d <path to csv with data> -s <path to save pandas-profiling file>
You can check options in the CLI. To get a full list of them, use help:
poetry run eda --help
- Run hyperparameter tuning with the following command:
poetry run tuning -d <path to csv with data> -s <path to save trained model>
Additional options:
Command | Type | Description |
---|---|---|
-d, --dataset-path | FILE | [default: data/train.csv] |
-s, --save-model-path | FILE | [default: data/model.joblib] |
--random-state | INTEGER | [default: 42] |
--clf-type | TEXT | [default: ExtraTreesClassifier] |
--use-scaler | BOOLEAN | [default: True] |
-f, --use-feat-engineering | BOOLEAN | [default: False] |
--help | Show full list of options in CLI. |
You can change default grid search parameters in ml_forest\grid_param_config.ini
- Run MLflow UI to see the information about experiments you conducted:
poetry run mlflow ui
The code in this repository can be tested before being commited to the repository.
Install all requirements (including dev requirements) to poetry environment:
poetry install
Now you can use developer instruments, e.g. pytest:
poetry run pytest
Format your code with black by using poetry:
poetry run black ml_forest tests
Format your code with flake8 by using poetry:
poetry run flake8 ml_forest tests