Skip to main content

375 posts tagged with "Python"

Python Programming Language

View All Tags

Fixed: Pandas4Warning "For backward compatibility, 'str' dtypes are included by select_dtypes when 'object' dtype is specified" in MLflow log_table

· 9 min read
Jagdish Kumawat
Founder @ Dewiride

pytest passed all 31 tests of a project that logs tables to MLflow, then printed a warnings summary: Pandas4Warning: For backward compatibility, 'str' dtypes are included by select_dtypes when 'object' dtype is specified. It comes from one line inside mlflow.log_table() meeting pandas 3's new text type, and it changes nothing about the tables you log. One filterwarnings line hides exactly this warning until an MLflow release stops raising it.

MLflow Tutorial for Machine Learning in Python — Part 2: Log Metrics Over Time and System Metrics

· 39 min read
Jagdish Kumawat
Founder @ Dewiride

Part 1 logged each score once, after training was over. That hides the question every model raises: was more training still helping? In this part the forest grows in stages, MLflow records its score after every stage, and the curves show where extra trees stop paying off. MLflow also records how hard the computer worked while it trained.

How to Get the History of a Metric in MLflow

· 6 min read
Jagdish Kumawat
Founder @ Dewiride

When a run logs a metric many times, such as a loss after every round of training, MLflow keeps every value. The run's summary shows only the latest one, though. MlflowClient.get_metric_history returns them all, each with its step and the moment it was logged. This guide reads a short curve back and finds its best step, with real output from MLflow 3.18.0.

How to Add Command-Line Options to a Python Script with argparse

· 7 min read
Jagdish Kumawat
Founder @ Dewiride

A script that reads its settings from the command line can be run in many ways without editing it. argparse, part of Python's standard library, turns a few lines of description into options, type checks, error messages and a --help page. This guide builds a small greeting script with an argument, an option and a flag, with real output from Python 3.15.2.

How to Use warm_start to Add Trees to a Random Forest in scikit-learn

· 7 min read
Jagdish Kumawat
Founder @ Dewiride

A random forest normally grows all its trees in one call to fit. With warm_start=True, it keeps the trees it already has, and the next fit adds only the ones you asked for on top. That lets you score the forest at 25, 50, 75 and 100 trees without starting over each time. This guide shows how, with real output from scikit-learn 1.9.1.

How to Split Data into Training, Validation and Test Sets with scikit-learn

· 7 min read
Jagdish Kumawat
Founder @ Dewiride

A test set tells you how good a finished model is, but only if you never use it while building the model. To check the model while you build it, you need a third part of the data, a validation set. scikit-learn has no single function for that, so you call train_test_split twice. This guide shows how, with real output from scikit-learn 1.9.1.

Fixed: scikit-learn Random Forest Predictions Change Slightly Between Calls with n_jobs=-1

· 7 min read
Jagdish Kumawat
Founder @ Dewiride

A check that two random forests predict the same values printed False, although both forests had exactly the same trees. Even one forest, asked twice for the same predictions, gave values that differed in the 15th decimal place. With n_jobs=-1, scikit-learn adds up the trees' predictions in whatever order its threads finish, and decimal rounding makes the order show. Compare predictions with np.allclose, or predict with n_jobs=1 when you need identical numbers.

MLflow Tutorial for Machine Learning in Python — Part 1: Install MLflow and Track Your First Experiment

· 42 min read
Jagdish Kumawat
Founder @ Dewiride

Every time you train a model, you change something: the number of trees, a setting, the data. A week later nobody remembers which change gave the best result. MLflow remembers it for you. In this first part you install MLflow, start your own tracking server, and log your first machine learning experiment from Python.