mirror of
https://github.com/RYDE-WORK/lnp_ml.git
synced 2026-01-19 11:53:13 +08:00
109 lines
2.8 KiB
Makefile
109 lines
2.8 KiB
Makefile
#################################################################################
|
|
# GLOBALS #
|
|
#################################################################################
|
|
|
|
PROJECT_NAME = lnp-ml
|
|
PYTHON_VERSION = 3.8
|
|
PYTHON_INTERPRETER = python
|
|
|
|
#################################################################################
|
|
# COMMANDS #
|
|
#################################################################################
|
|
|
|
|
|
## Install Python dependencies
|
|
.PHONY: requirements
|
|
requirements:
|
|
pixi install
|
|
|
|
|
|
|
|
|
|
## Delete all compiled Python files
|
|
.PHONY: clean
|
|
clean:
|
|
find . -type f -name "*.py[co]" -delete
|
|
find . -type d -name "__pycache__" -delete
|
|
|
|
|
|
## Lint using ruff (use `make format` to do formatting)
|
|
.PHONY: lint
|
|
lint:
|
|
ruff format --check
|
|
ruff check
|
|
|
|
## Format source code with ruff
|
|
.PHONY: format
|
|
format:
|
|
ruff check --fix
|
|
ruff format
|
|
|
|
|
|
|
|
|
|
|
|
## Set up Python interpreter environment
|
|
.PHONY: create_environment
|
|
create_environment:
|
|
|
|
@echo ">>> Pixi environment will be created when running 'make requirements'"
|
|
|
|
@echo ">>> Activate with:\npixi shell"
|
|
|
|
|
|
|
|
|
|
#################################################################################
|
|
# PROJECT RULES #
|
|
#################################################################################
|
|
|
|
|
|
## Clean raw data (raw -> interim)
|
|
.PHONY: clean_data
|
|
clean_data: requirements
|
|
$(PYTHON_INTERPRETER) scripts/data_cleaning.py
|
|
|
|
## Process dataset (interim -> processed)
|
|
.PHONY: data
|
|
data: requirements
|
|
$(PYTHON_INTERPRETER) scripts/process_data.py
|
|
|
|
## Train model
|
|
.PHONY: train
|
|
train: requirements
|
|
$(PYTHON_INTERPRETER) -m lnp_ml.modeling.train
|
|
|
|
## Train with hyperparameter tuning
|
|
.PHONY: tune
|
|
tune: requirements
|
|
$(PYTHON_INTERPRETER) -m lnp_ml.modeling.train --tune
|
|
|
|
## Run predictions
|
|
.PHONY: predict
|
|
predict: requirements
|
|
$(PYTHON_INTERPRETER) -m lnp_ml.modeling.predict
|
|
|
|
## Test model on test set (with detailed metrics)
|
|
.PHONY: test
|
|
test: requirements
|
|
$(PYTHON_INTERPRETER) -m lnp_ml.modeling.predict test
|
|
|
|
|
|
#################################################################################
|
|
# Self Documenting Commands #
|
|
#################################################################################
|
|
|
|
.DEFAULT_GOAL := help
|
|
|
|
define PRINT_HELP_PYSCRIPT
|
|
import re, sys; \
|
|
lines = '\n'.join([line for line in sys.stdin]); \
|
|
matches = re.findall(r'\n## (.*)\n[\s\S]+?\n([a-zA-Z_-]+):', lines); \
|
|
print('Available rules:\n'); \
|
|
print('\n'.join(['{:25}{}'.format(*reversed(match)) for match in matches]))
|
|
endef
|
|
export PRINT_HELP_PYSCRIPT
|
|
|
|
help:
|
|
@$(PYTHON_INTERPRETER) -c "${PRINT_HELP_PYSCRIPT}" < $(MAKEFILE_LIST)
|