docs: swap pgmpy for MLflow in Machine Learning intro

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Vinta Chen
2026-11-08 22:13:31 +08:00
co-authored by Claude
parent 594ab2bf8b
commit 86bbbb5d96
@@ -4,7 +4,6 @@ How to choose:
- Classification, regression, and clustering on tabular data: scikit-learn
- Boosted trees with no extra dependency: scikit-learn
- Causal graphs and Bayesian networks: pgmpy
- Feature engineering that keeps your DataFrame's column names: Feature-engine
- Boosted trees trained across a cluster: XGBoost
- Boosted trees on large data, fast and light on memory: LightGBM
@@ -14,11 +13,10 @@ How to choose:
- Forecasting next to classification and other time-series tasks: sktime
- Forecasts with no model to train: TimesFM
- Tuning a model's hyperparameters: Optuna
- Runs, parameters, and metrics of every training job, tracked: MLflow
scikit-learn does [supervised and unsupervised learning](https://scikit-learn.org/stable/getting_started.html), plus the tools around it: preprocessing, model selection, and evaluation. Every estimator learns with `fit`. Put your preprocessing and model in one Pipeline, and run cross-validation and searches on that, since the pipeline [keeps test data out of training](https://scikit-learn.org/stable/common_pitfalls.html#data-leakage). You may not need a separate boosting library: its histogram-based gradient boosting is [inspired by LightGBM](https://scikit-learn.org/stable/modules/ensemble.html) and supports missing values and categorical data natively. Deep learning is another matter: it [doesn't fit scikit-learn's design constraints](https://scikit-learn.org/stable/faq.html#why-is-there-no-support-for-deep-or-reinforcement-learning-will-there-be-such-support-in-the-future), so it's out of scope.
pgmpy does [causal and probabilistic reasoning with graphical models](https://pgmpy.org/). Its [quickstart](https://pgmpy.org/started/quickstart.html) follows the tasks: learn a graph's structure from data, fit the distributions for a graph you know, then query the model for probabilities or causal effects.
Feature-engine is [designed to work with dataframes](https://feature-engine.trainindata.com/en/latest/): a DataFrame goes in, and the same DataFrame comes out, with no column order or name changes. Instead of wrapping transformers in a ColumnTransformer, you tell each one which variables to transform. Its transformers [work just like any scikit-learn transformer](https://feature-engine.trainindata.com/en/latest/quickstart/index.html), so they fit in a Pipeline.
XGBoost is [an optimized distributed gradient boosting library](https://xgboost.readthedocs.io/en/stable/). Its Python package has [a native interface, a scikit-learn interface, and a Dask interface](https://xgboost.readthedocs.io/en/stable/python/python_intro.html).
@@ -37,4 +35,6 @@ TimesFM is [a pretrained foundation model from Google Research](https://github.c
Optuna is [an automatic hyperparameter optimization framework, particularly designed for machine learning](https://optuna.readthedocs.io/en/latest/). Write an `objective` function that takes a `trial`, picks each hyperparameter with methods like `suggest_float`, trains the model, and returns its score. Then [create a study and call `optimize`](https://optuna.readthedocs.io/en/latest/tutorial/10_key_features/001_first.html) with the number of trials. The search space is [plain Python, with conditionals and loops](https://optuna.readthedocs.io/en/latest/tutorial/10_key_features/002_configurations.html), so you can tune an SVM's `C` only in trials that picked an SVM. To stop unpromising trials early, [call `report` after each training step and raise `optuna.TrialPruned()` when `should_prune()` returns true](https://optuna.readthedocs.io/en/latest/tutorial/10_key_features/003_efficient_optimization_algorithms.html#activating-pruners).
MLflow groups [runs and models into experiments](https://mlflow.org/docs/latest/ml/tracking/), one per task. Call [`mlflow.autolog()`](https://mlflow.org/docs/latest/ml/tracking/autolog/) before your training code, and it logs metrics, parameters, and models from libraries like scikit-learn, XGBoost, and PyTorch with no explicit log statements. Log anything else with `mlflow.log_param()` and `mlflow.log_metric()`, then run `mlflow server` to compare runs in its UI.
To evaluate a model on time-series data, test it on observations from after its training data. scikit-learn's [TimeSeriesSplit](https://scikit-learn.org/stable/modules/cross_validation.html#time-series-split) does that in cross-validation. For more, see [awesome-machine-learning](https://github.com/josephmisiti/awesome-machine-learning#python).