Icon

Heart Disease - Machine Learning Case - LightGBM Hyper Parameter Optimization

use KNIME / Python and LightGBM to build a model - Hyperparameter tuning with BayesSearchCV and Optuna - also preparing data with vtreat

use KNIME / Python and LightGBM to build a model - Hyperparameter tuning with BayesSearchCV and Optuna - also preparing data with vtreat
some parameters have been discussed with ChatGPT ...

MEDIUM Blog: Hyperparameter optimization for LightGBM — wrapped in KNIME nodes
https://medium.com/p/ddb7ae1d7e2

GitHub Repository - binary classification
https://github.com/ml-score/knime_meets_python/tree/main/machine_learning/binary

------------
Heart Failure Prediction Dataset (Kaggle)
11 clinical features for predicting heart disease events.

https://www.kaggle.com/datasets/fedesoriano/heart-failure-prediction?resource=download

URL: Data preparation for Machine Learning with KNIME and the Python “vtreat” package https://medium.com/low-code-for-advanced-data-science/data-preparation-for-machine-learning-with-knime-and-the-python-vtreat-package-efcaf58fa783
URL: sklearn.ensemble.ExtraTreesClassifier https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.ExtraTreesClassifier.html
URL: HUB: use KNIME / Python and LightGBM to build a model - also preparing data with vtreat https://hub.knime.com/-/spaces/-/latest/~GABT_OgeoWxWJW9P/
URL: ChatGPT and KNIME on LinkedIn https://www.linkedin.com/posts/mlauber71_chatgpt-optimizing-language-models-for-dialogue-activity-7011229002291888128-JgJL/?utm_source=share&utm_medium=member_desktop
URL: MEDIUM: Hyperparameter optimization for LightGBM — wrapped in KNIME nodes https://medium.com/p/ddb7ae1d7e2
URL: GitHub Repository - binary classification https://github.com/ml-score/knime_meets_python/tree/main/machine_learning/binary
URL: Medium Blog: KNIME — Machine Learning and Artificial Intelligence— A Collection https://medium.com/p/12e0f7d83b50
URL: Medium Blog: About Machine-Learning — How it Fails and Succeeds https://medium.com/p/9f3ab7cb9b00
URL: Medium Blog: KNIME, XGBoost and Optuna for Hyper Parameter Optimization https://medium.com/p/dcf0efdc8ddf

use KNIME / Python and LightGBM to build a model - Hyperparameter tuning with BayesSearchCV and Optuna - also preparing data with vtreat
some parameters have been discussed with ChatGPT ...

BayesSearchCV LightGBM - there is a Jupyter notebook in the /data/notebook/ subfolder to toy around with
"kn_example_python_lightgbm_hyper_parameter_bayes_search_cv.ipynb"

# conda env create -f="/Users/m_lauber/Dropbox/knime-workspace/Machine_Learning/ml_binary/kn_example_ml_binary_lightgbm_hyper_parameter_opt/data/py3_knime_lightgbm.yml"
# conda env create -f="C:\\Users\\x123456\\knime-workspace\\Machine_learning\\ml_binary\\kn_example_ml_binary_lightgbm_hyper_parameter_opt\\data\\py3_knime_lightgbm.yml"

# conda activate py3_knime_lightgbm
# conda update -n py3_knime_lightgbm --all

# conda env update --name py3_knime_lightgbm --file "/Users/m_lauber/Dropbox/knime-workspace/Machine_Learning/ml_binary/kn_example_ml_binary_lightgbm_hyper_parameter_opt/data/py3_knime_lightgbm.yml" --prune
# conda env update --name py3_knime_lightgbm --file "C:\\Users\\x123456\\knime-workspace\\Machine_learning\\ml_binary\\kn_example_ml_binary_lightgbm_hyper_parameter_opt\\data\\py3_knime_lightgbm.yml" --prune

# conda env update --name py3_knime_lightgbm --file "/Users/m_lauber/Dropbox/knime-workspace/Machine_Learning/ml_binary/kn_example_ml_binary_lightgbm_hyper_parameter_opt/data/py3_knime_lightgbm.yml"
# conda env update --name py3_knime_lightgbm --file "C:\\Users\\x123456\\knime-workspace\\Machine_learning\\ml_binary\\kn_example_ml_binary_lightgbm_hyper_parameter_opt\\data\\py3_knime_lightgbm.yml"
# conda update -n base conda

# KNIME official Python integration guide
# https://docs.knime.com/latest/python_installation_guide/index.html#_introduction

# KNIME and Python - Setting up and managing Conda environments
# https://medium.com/p/2ac217792539

# Hyperparameter optimization for LightGBM - wrapped in KNIME nodes
# https://medium.com/p/ddb7ae1d7e2

# conda activate py3_knime_lightgbm

# file: py3_knime_lightgbm.yml with some modifications
# THX Carsten Haubold (https://hub.knime.com/carstenhaubold) for hints
name: py3_knime_lightgbm # Name of the created environment
channels: # Repositories to search for packages
# - defaults # edit: removed to just use conda-forge
# - anaconda # edit: removed to just use conda-forge
- conda-forge
# https://anaconda.org/knime
- knime # conda search knime-python-base -c knime --info # to see what is in the package
dependencies: # List of packages that should be installed
- python=3.9 # Python
- knime-python-base # dependencies of KNIME - Python integration
# - knime-python-scripting # everything you need to also build Python packages for KNIME
- cairo # SVG support
- pillow # Image inputs/outputs
- matplotlib # Plotting
- IPython # Notebook support
- nbformat # Notebook support
- scipy # Notebook support
- jpype1 # A Python to Java bridge
# Jupyter Notebook support
- jupyter # Jupyter Notebook
- pandas-profiling # create overview of your data
- sweetviz # In-depth EDA (target analysis, comparison, feature analysis, correlation) in two lines of code!
- plotly # An interactive, browser-based graphing library for Python
- python-kaleido # Fast static image export for web-based visualization libraries
# Machine Learning Modules
- lightgbm
- xgboost
- hyperopt
- scikit-optimize # skopt
- optuna # A hyperparameter optimization framework
- pip # Python installer
- pip:
# - JPype1 # Databases
- vtreat # https://medium.com/low-code-for-advanced-data-science/data-preparation-for-machine-learning-with-knime-and-the-python-vtreat-package-efcaf58fa783
- h2o>=3.38
- boruta # Python Implementation of Boruta Feature Selection

MEDIUM Blog: Hyperparameter optimization for LightGBM — wrapped in KNIME nodes
https://medium.com/p/ddb7ae1d7e2

GitHub Repository
https://github.com/ml-score/knime_meets_python/tree/main/machine_learning/binary

OPTUNA LightGBM - here is a Jupyter notebook in the /data/notebook/ subfolder to toy around with
"kn_example_python_lightgbm_hyper_parameter_optuna.ipynb"

OPTUNA XGBoost - here is a Jupyter notebook in the /data/notebook/ subfolder to toy around with
"kn_example_python_xgboost_hyper_parameter_optuna.ipynb"

collect the performance statistics from experiements from the Jupyter notebooks for the four approaches from JSON files collecting the measurements

H2O.ai AutoML - here is a Jupyter notebook in the /data/notebook/ subfolder to toy around with
"kn_example_python_h2o_automl.ipynb"

About Machine-Learning — How it Fails and Succeeds

https://medium.com/p/9f3ab7cb9b00

KNIME — Machine Learning and Artificial Intelligence— A Collection

https://medium.com/p/12e0f7d83b50

Python Predictoralso apply some transformations
Python Script
ml_model_lightgbm_jupyter.pkl=> the model producedin the Jupyter Notebook/data/notebooks/kn_example_python_lightgbm_hyper_parameter_bayes_search_cv.ipynb
Python Script
Column Filter
ml_model_lightgbm_jupyter_variable_list.json
Python Script
Py_LightGBM
Py_LightGBM
Py_LightGBM
H2O Binomial Scorer
Py_LightGBM
Table to H2O
Py_LightGBM
Constant Value Column
Py_vtreat_LightGBM
Constant Value Column
H2O Local Context
removerow_id
Column Filter
Test
Reference Column Filter
locate and create /data/ folder with absolute paths
Collect Local Metadata
ml_model_lightgbm_jupyter_feature_importance.parquet
Parquet Reader
Prepare Heart Failure Prediction Dataset (Kaggle)https://www.kaggle.com/datasets/fedesoriano/heart-failure-prediction/
Component
Jupyter_LightGBM
H2O Binomial Scorer
Jupyter_LightGBM
Table to H2O
Jupyter_LightGBMPr (AUC) 0.823500 iterations
Constant Value Column
ROC Curve (JavaScript)
ml_model_xgboost_optuna_jupyter_feature_importance.parquet
Parquet Reader
lightgbm_vtreat_model_parameters.txt
CSV Writer
ml_model_xgboost_optuna_jupyter.json=> the model producedin the Jupyter Notebook/data/notebooks/kn_example_python_xgboost_hyper_parameter_optuna.ipynb
Python Script
Py_vtreat_LightGBM
Py_vtreat_LightGBM
lightgbm_model_parameters.txt
CSV Writer
Column Filter
Column Filter
Pr (AUC)DESCENDING
Sorter
RowID
Concatenate
lightgbm_vtreat_feature_importance.parquet
Parquet Writer
lightgbm_feature_importance.parquet
Parquet Writer
train.parquet
Parquet Reader
H2O Local Context
var_h2o_mojo_file
Java Edit Variable (simple)
H2O MOJO Predictor (Classification)
load the winningH2O.ai model
H2O MOJO Reader
H2O_AutoML_Classification
Table Row to Variable
H2O_AutoML_Classification
H2O Binomial Scorer
Column Filter
var_h2o_mojo_file
String to Path (Variable)
select themodels with the best AUCPR
Duplicate Row Filter
extract theinformation aboutthe model runs
JSON Path
.json*variable_list*=> collect all models runfrom the Jupyter Notebooksin the subfolder
JSON Reader
Pr (AUC)DESCENDING
Sorter
LightGBM_BayesSearchCV_Classification
Table Row to Variable
H2O Local Context
XGBoost_Optuna_Classification
Row Filter (deprecated)
H2O_AutoML_Classification
Constant Value Column
LightGBM_BayesSearchCV_Classification
Row Filter (deprecated)
H2O_AutoML_Classification
Table to H2O
Normalizer (PMML)
Jupyter_LightGBM_optuna
Constant Value Column
model_results.xlsx
Excel Writer
var_importance_path
String to Path (Variable)
Binary Classification Inspector
ROC Curve (JavaScript)
Binary Classification Inspector
var_importance_path
Java Edit Variable (simple)
Jupyter_XGBoost_optuna
H2O Binomial Scorer
ml_model_xgboost_optuna_jupyter_variable_list.json
Python Script
Jupyter_XGBoost_optuna
Table to H2O
Python Predictoralso apply some transformations
Python Script
Python Predictoralso apply some transformations
Python Script
Binary Classification Inspector
ROC Curve (JavaScript)
Column Filter
H2O_AutoML_Classification
Row Filter (deprecated)
Jupyter_LightGBM_optuna
H2O Binomial Scorer
XGBoost_Optuna_Classification
Table Row to Variable
ml_model_lightgbm_optuna_jupyter_variable_list.json
Python Script
Column Filter
Jupyter_LightGBM_optuna
Table to H2O
ml_model_lightgbm_optuna_jupyter.pkl=> the model producedin the Jupyter Notebook/data/notebooks/kn_example_python_lightgbm_hyper_parameter_optuna.ipynb
Python Script
H2O Local Context
Py_vtreat_LightGBM
H2O Binomial Scorer
Py_vtreat_LightGBM
Table to H2O
Select Parameters for Models
model_results_jupyter.xlsx
Excel Writer
Concatenate
RowID
Merge Variables
Target is target"row_id" will not be usedhttps://medium.com/p/efcaf58fa783
vtreat prepare binary data
Merge Variables
Merge Variables
Jupyter_XGBoost_optuna
Constant Value Column
var_importance_path
String to Path (Variable)
var_importance_path
Java Edit Variable (simple)
ml_model_lightgbm_optuna_jupyter_feature_importance.parquet
Parquet Reader
to deal with negative score values
Normalizer (PMML)
Activate Conda Environmentbased on Operating SystemWindows or macOS
conda_environment_lightgbm
test.parquet
Parquet Reader
H2O Local Context
LightGBM_Optuna_Classification
Table Row to Variable
LightGBM_Optuna_Classification
Row Filter (deprecated)
var_importance_path
String to Path (Variable)
var_importance_path
Java Edit Variable (simple)

Nodes

Extensions

Links