Skip to main content

219 posts tagged with "Python"

Python Programming Language

View All Tags

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.

How to Plot Predicted vs Actual Values with Matplotlib

· 7 min read
Jagdish Kumawat
Founder @ Dewiride

A single error score tells you how much a regression model misses on average. A predicted vs actual chart shows where it misses: which values it gets right, which it underestimates, and where the data itself is odd. This guide draws the chart with Matplotlib, saves it as a PNG, and reads a real one from a scikit-learn model.

How to Calculate MAE, RMSE and R² in scikit-learn

· 6 min read
Jagdish Kumawat
Founder @ Dewiride

A regression model predicts numbers, so you measure it by how far its numbers are from the real ones. Three scores do most of the work: MAE, RMSE and R². This guide calculates all three with scikit-learn for a real house price model, compares them against a model that always guesses the average, and explains what each number says in plain words.

How to Train a Random Forest Regression Model with scikit-learn

· 6 min read
Jagdish Kumawat
Founder @ Dewiride

A random forest is one of the most dependable models for tables of numbers. It trains many decision trees on random slices of the data and averages their answers, so one odd tree can't throw it off. This guide trains scikit-learn's RandomForestRegressor to predict house values, explains its main settings, and shows which features it relied on, with real output.

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

· 6 min read
Jagdish Kumawat
Founder @ Dewiride

A model always looks good on the data it learned from. To know how it does on new data, you hold some rows back and never show them to it during training: the test set. scikit-learn's train_test_split does that in one line. This guide splits the California Housing data, and shows what test_size and random_state really control, with real output.

How to Load the California Housing Dataset in Python with scikit-learn

· 7 min read
Jagdish Kumawat
Founder @ Dewiride

The California Housing dataset is the classic dataset for learning regression: 20,640 districts, 8 numbers about each, and a house value to predict. scikit-learn downloads it for you with one function. This guide loads it as a pandas table, explains every column, shows where the download is kept, and points out the $500,000 cap that surprises people.

How to Add Tags to an MLflow Run

· 5 min read
Jagdish Kumawat
Founder @ Dewiride

Tags are labels on a run: the model type, the dataset, who owns it. Unlike parameters, you can change them later, and unlike metrics, they're text. MLflow also adds its own tags to every run, such as who ran it and which Git commit the code was at. This guide sets tags, overwrites one, adds a run description, and lists everything MLflow recorded, with real output from MLflow 3.18.0.