Skip to main content

153 posts tagged with "Python"

Python Programming Language

View All Tags

How to Log Text to a File in MLflow with log_text

· 5 min read
Jagdish Kumawat
Founder @ Dewiride

Notes about a run, a text report, a summary someone else will read: when the content is already a string, mlflow.log_text() saves it with the run as a file in one call, without creating anything on your disk. This guide logs a Markdown note and a plain text file and looks at both in the MLflow UI, with real output from MLflow 3.18.0.

How to Log a Dictionary to MLflow as a JSON or YAML File

· 6 min read
Jagdish Kumawat
Founder @ Dewiride

A run's settings, a model's full configuration or a summary of results often already sit in a Python dictionary. mlflow.log_dict() saves one with the run as a JSON or YAML file in a single line, without writing anything to disk yourself. This guide logs the same dictionary in both formats and compares the files, with real output from MLflow 3.18.0.

How to Load a Logged Table from MLflow with load_table

· 5 min read
Jagdish Kumawat
Founder @ Dewiride

A table logged with mlflow.log_table() can be read straight back into a pandas DataFrame with mlflow.load_table(). Its best trick is reading the same table from many runs at once, stacked into one DataFrame with a column that says which run each row came from. This guide loads a predictions table from two runs, with real output from MLflow 3.18.0.

How to Log a Table in MLflow with log_table

· 6 min read
Jagdish Kumawat
Founder @ Dewiride

Some results of a run are tables: predictions next to the real values, scores per group, the importance of each feature. mlflow.log_table() saves a pandas DataFrame or a dictionary with the run as a table that the MLflow UI shows as rows and columns and can compare across runs. This guide logs a small predictions table from two models, with real output from MLflow 3.18.0.

How to Make an MLflow Dataset Digest Cover Every Row

· 8 min read
Jagdish Kumawat
Founder @ Dewiride

An MLflow dataset's digest is meant to tell you when data changes, but for a pandas DataFrame it only looks at part of it: the first 10,000 rows, and only the columns that hold text or numbers. Change a value further down, or a date anywhere, and the digest stays the same. This guide shows both gaps happening, finds the reason in MLflow's code, and passes a digest of every row and column instead, with real output from MLflow 3.18.0.

How to Check Whether Two MLflow Runs Used the Same Data

· 7 min read
Jagdish Kumawat
Founder @ Dewiride

When two runs give different results, the first question is whether they learned from the same data. If both logged their data with mlflow.log_input(), MLflow already knows: each dataset has a digest, a short fingerprint of its contents, and equal digests mean equal data. This guide compares three runs in the UI and in Python, with real screens and output from MLflow 3.18.0.

How to See Which Datasets an MLflow Run Used

· 8 min read
Jagdish Kumawat
Founder @ Dewiride

When a run logs its data with mlflow.log_input(), MLflow keeps each dataset's name, digest, source, schema and row count with the run. You can find them in the MLflow UI, from the command line and from Python. This guide looks at one run that used a training set and a test set, in all four places, with real screens and output from MLflow 3.18.0.

How to Log a Dataset in MLflow

· 8 min read
Jagdish Kumawat
Founder @ Dewiride

A model is only as good as the data it learned from, so a run should record which data that was. MLflow does it in two calls: mlflow.data.from_pandas() describes a pandas DataFrame as a dataset, and mlflow.log_input() attaches that description to the run. This guide logs a small CSV file of houses, with real output from MLflow 3.18.0.

How to See Every Setting of a scikit-learn Model with get_params

· 5 min read
Jagdish Kumawat
Founder @ Dewiride

You usually set two or three of a model's settings and leave the rest at their defaults, so the code doesn't show the full picture. get_params() does: it returns every setting of a scikit-learn model, chosen or default, as a dictionary you can print, check or save. This guide lists all 18 settings of a random forest, with real output from scikit-learn 1.9.1.

How to Get Feature Importances from a Random Forest in scikit-learn

· 6 min read
Jagdish Kumawat
Founder @ Dewiride

A trained random forest can tell you which inputs it leaned on most. feature_importances_ holds one number per input, and feature_names_in_ holds the inputs' names in the same order. This guide trains a forest on scikit-learn's California Housing data, reads both, and turns them into a sorted table, with real output from scikit-learn 1.9.1.