Learn AI Engineering Rent GPUs By The Hour Docker VPS Hosting Automate 3000+ Apps No Code AI Agents Proxies For Your Agents
Learn AI Engineering Rent GPUs By The Hour
Websites To LLM Data Proxies For Scraping AI Support Chatbot AI Data Analyst AI Agent Workspace Hire AI Builders

Machine Learning Models: 18 Types and When to Use Each

Updated November 2026 19 articles in this topic
A machine learning model is a small program that learns a pattern from example rows and then answers one narrow question about new rows, in milliseconds and at no cost per answer once it is trained. There are only 4 kinds of answers a model can give, a label, a number, a group, or a normal or weird flag, and the 18 model types in this guide are just different ways of getting to one of those 4 answers.

What a Machine Learning Model Actually Is

The word "model" gets used for everything now, so first it helps to separate the 2 things people mean by it. A large language model like Claude or GPT has billions of parameters, was trained on a huge slice of the internet, and can talk about anything. The models in this guide are tiny by comparison, a KNN model is basically your table of examples plus a rule for comparing them, and a ridge model is a short list of numbers, one weight per column. They can not chat, they can not write, and they know nothing about the world, they answer 1 question, the one your rows taught them.

So why use something that limited? Because inside that 1 question it beats a language model on almost everything that matters in production. The answer comes back in a few milliseconds, it costs nothing per call, it runs on the same box as your app, and the same input gets the same answer every time. So basically a language model means "I can reason about anything, slowly, for a fee" and a machine learning model means "I know this 1 thing from your data, instantly, forever". Most real systems want both, which is covered further down.

From the outside every model here works the same way. You collect rows, where a row is an input and usually the answer you wanted for it, like the message "refund my order" with the label billing, or the numbers 1500, 3, 0.7 with the value 420. You train, which means the model reads all the rows and builds whatever internal structure its type uses. Then you predict, you send a new input and it sends back its answer. The 18 types differ only in what happens in the middle, and that middle is what decides which one fits your data.

The 4 Kinds of Answers

Before any model type matters, there is the question of what shape of answer you want back, and there are only 4 shapes. This is the decision that can not be fixed later with tuning, a regressor will never give you a category no matter what you set its parameters to, so get this one right and the rest is small adjustments.

You wantFamilyExample questionRows need the answer?
A category labelClassifier"Is this ticket billing, technical, or sales?"Yes
A numberRegressor"What will this lead be worth?"Yes
Natural groupsClusterer"What themes are in this feedback?"No
A normal or weird flagAnomaly detector"Does this transaction look wrong?"No

The last column is the practical split. Classifiers and regressors learn from labeled rows, meaning somebody or something already supplied the right answer for each example. Clusterers and anomaly detectors train on inputs alone, which makes them the tools for when labels are the thing you wish you had. Now if you have no labels and still want a classifier, the usual path is to cluster first, look at what the groups are, name them, and those names become your labels.

Classifiers: 7 Ways to Pick a Label

A classifier takes an input and returns one label from the set it saw in training. All 7 below do that job, the difference is how they draw the line between labels, and that decides how much data they want and how well you can explain a prediction afterward. The names in code style are the class names used by the engine in the step by step section.

K Nearest Neighbors (knn) does not really learn anything, it keeps your rows, and at predict time it finds the 5 most similar ones and lets them vote. It is the easiest model to explain, "here are the 5 past cases most like this one", and a good first classifier on small data. It slows down as rows pile up and gets confused when most of your columns have nothing to do with the answer.

Naive Bayes (naiveBayes) counts how often each word or value shows up with each label and multiplies the odds together, treating every feature as if it had nothing to do with the others, which is the naive part. It has no parameters to set, trains almost instantly, and is the classic pick for spam and intent detection on text.

Logistic Regression (logisticRegression) learns one weight per feature, adds them up, and turns the total into a label. It is the sturdy linear baseline, strong on text and hard to break, and when a fancier model can not beat it by much you keep it.

Decision Tree (tree) learns a chain of if then questions, "is the amount over 500, is the account under 30 days old", until it reaches a label. You can read the whole thing like a flowchart, which is its real value, and its weakness is that a deep tree memorizes your rows instead of learning from them.

Random Forest (randomForest) trains 100 trees, each on a random sample of the rows and columns, and takes the majority vote. One tree is jumpy, 100 of them averaged are steady, and this is one of the best default answers for messy table data with mixed columns.

AdaBoost (adaBoost) also builds 100 small trees but one after another, each new one paying extra attention to the rows the earlier ones got wrong. It squeezes accuracy out of clean data, and it suffers on data with mislabeled rows because it keeps trying harder to fit the mistakes.

Deep Neural Network (dnn) is a multilayer perceptron, layers of small units that each learn a piece of the pattern. It finds shapes the simpler types miss, and it pays for that by wanting thousands of rows, taking the longest to train, and giving you no readable reason for any answer.

Regressors: 5 Ways to Predict a Number

A regressor returns a number instead of a label: a price, a score, a count, days until something happens. The label on each training row is the number you wanted back.

Ridge Regression (ridge) fits a straight line relationship, one weight per column, with a penalty that keeps the weights from getting wild when columns overlap. It is the first pick when more of X roughly means more of Y, like a lead score from engagement counts.

KNN Regressor (knnRegressor) finds the 5 most similar rows and averages their numbers. It handles local patterns that a straight line smooths over, "houses on this street go for more", and it can never predict a number outside the range it has seen.

Support Vector Regression (svr) fits a curve with a tolerance band around it, errors inside the band are ignored and only the rows outside it shape the curve. That makes it steady on small and medium data with some noise in the numbers.

Gradient Boost (gradientBoost) builds 100 small trees in sequence, each one predicting what is still wrong after the ones before it. On table data it is usually the accuracy leader once you have a few hundred rows.

MLP Regressor (mlpRegressor) is the neural network version for numbers, the pick when the relationship bends in ways the others can not follow and you have the rows to feed it.

Clusterers: 3 Ways to Find Groups

A clusterer gets inputs with no labels and returns a group number for each one. Nobody tells it what the groups mean, it only finds rows that sit close together, and naming the groups is your job afterward.

K-Means (kmeans) splits the data into exactly the number of groups you ask for, 4 by default, by placing a center for each group and pulling the centers toward their rows until they stop moving. It is the pick for "sort my feedback into 5 themes".

DBSCAN (dbscan) works out the number of groups itself from how densely the rows are packed, and answers -1 for a row that belongs to no group. So it is the clusterer that can also say "this one is noise", which K-Means can never do because it must put every row somewhere.

Gaussian Mixture (gaussianMixture) also takes a group count, but it fits soft, overlapping groups shaped like stretched clouds instead of round balls, which fits better when your categories blend into each other at the edges.

Anomaly Detectors: 3 Ways to Flag the Weird One

An anomaly detector learns what normal looks like and answers 1 when a new row does not fit and 0 when it does. You train these on normal data, ordinary days, real customers, healthy readings, so anything different stands out.

Isolation Forest (isolationForest) builds random trees and measures how few cuts it takes to separate a row from all the others, a weird row gets isolated fast and a normal one takes many cuts. It is the general pick and holds up with many columns at once.

Local Outlier Factor (localOutlierFactor) compares how crowded a row's neighborhood is to how crowded its neighbors' neighborhoods are. That catches a row that is only strange for its own area, a 900 dollar order is normal for one kind of customer and very odd for another.

Robust Z Score (robustZScore) is plain statistics on numbers, it measures how far a value sits from the median and flags anything past a threshold of 3.5. It is the one you can explain in a single sentence, which matters when someone asks why an alert fired.

How to Pick One Without Overthinking It

Start with the simplest type in the family and only move up when your own test predictions tell you to. That sounds like generic advice, but the reason is specific: on a few hundred rows the gap between the simplest and the fanciest type is usually a few points of accuracy, while the gap between 50 rows and 500 good rows is often 20 or more. So the hours go into rows first and model types second.

  • Text into labels: start with naiveBayes, move to logisticRegression as rows build up, and try dnn once you are in the thousands.
  • Table columns into labels: start with randomForest, use knn or tree when you need to show a person why.
  • Columns into a number: start with ridge, move to gradientBoost when the data is messy and you have a few hundred rows.
  • Groups: kmeans when you know how many you want, dbscan when you want the data to tell you.
  • Weird or normal: isolationForest first, robustZScore when the rule has to be explainable.

The model cheat sheet puts all 18 side by side with the pros, the cons, and the data each one wants, for when you need the answer in 1 minute.

How Training Works, Step by Step

The examples across this topic use ML Prediction Engine, a free open source tool that wraps all 18 types behind one small API. It is a PHP app plus a one file Python worker running scikit-learn, it stores everything in one SQLite file and one data folder, and the code is on GitHub. The steps are the same for every model type, which is the point, you can swap types without redoing any of the work around them.

1. Install and start it

Copy config.sample.php to config.php, set apiKey and adminPassword to long random strings, and run docker compose up --build. That starts the PHP app and the Python worker together, with the admin at http://localhost:8080/admin.php. The getting started guide covers running it without Docker.

2. Create a pipeline and pick a class

A pipeline holds one or more model steps and most jobs want exactly one. Pick the family, pick the class by its name, knn, randomForest, ridge and so on, choose text or numeric input, and set the parameters as a small JSON object like {"k": 5}. Leaving it empty uses the defaults.

3. Add rows

Each row is an input and, for classifiers and regressors, its label. Add them in the admin, or push them through the API one at a time as real events happen:

curl -X POST http://localhost:8080/api.php/dataset/add \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_KEY" \
  -d '{"pipelineID": 1, "modelIndex": 0, "input": "refund my order", "label": "billing"}'

4. Train

Click Train or call api.php/train. The engine rebuilds the model from the complete dataset every time and answers with the row count, {"message": "Model trained from 120 rows.", "samples": 120}. Text is turned into numbers with tf-idf automatically, so you send plain strings.

5. Test, then predict from your app

Type inputs into the test box and look at real answers before trusting it. Then your app calls one endpoint:

curl -X POST http://localhost:8080/api.php/predict \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_KEY" \
  -d '{"pipelineID": 1, "input": "why was i charged twice"}'

The answer is {"output": "billing", ...}. Classifiers return the label, regressors a number, clusterers a group number, and anomaly detectors 1 or 0.

How Much Data You Need

Less than most people expect to start, and more than they expect to get good. A first classifier works with 20 to 30 rows per label, that is enough for naiveBayes or knn to be right most of the time on clear cases. The ensemble types, randomForest, adaBoost, gradientBoost, start earning their keep at a few hundred rows. The neural types, dnn and mlpRegressor, want thousands, and below that a simpler type will usually beat them. Anomaly detectors want a few hundred rows of normal behavior, and clusterers want at least a few dozen rows per group you expect to find.

Two things matter more than the raw count. Balance, because a classifier fed 500 billing rows and 20 technical rows learns that "billing" is almost always the safe guess. And where the rows came from, because rows written by hand to look like real inputs never match what really arrives. The best row you can add is a real input the model just got wrong, with the right label attached, so every mistake becomes training data.

Where These Models Fit Next to AI Agents

An agent built on a language model can already classify a ticket or judge if a number looks off, so it is fair to ask why it would need any of this. The answer is volume and cost. Say an agent handles 10,000 inbound messages a day and each one needs a category before anything else happens. Asking the language model for that label means 10,000 calls, each taking a second or 2 and each one billed, for a question that has the same 6 possible answers every time. A trained classifier labels all 10,000 in a few seconds on the same server for nothing, and the language model only gets called for the messages that actually need reasoning.

So the pattern that works is the small model in front and the big model behind it. The classifier routes, the anomaly detector decides what is worth looking at, the regressor scores, and the agent spends its tokens on the cases those flag. It also runs the other direction, the language model is a good teacher, it can label the first few hundred rows so the small model has something to train on, and after that the small model does the job on its own. That is the same idea behind the machine learning layer in Auto Learning Agents, and agent cost planning covers the token side of the math.

The Mistakes That Cost the Most

  • Picking the wrong family. If you want "high, medium, low" that is a classifier even though it sounds like a number, and if you want an actual dollar amount it is a regressor.
  • Testing on the rows it trained on. Of course it gets those right, it has seen the answers. Hold some rows back or test with fresh inputs.
  • Training an anomaly detector on data that includes the anomalies. It learns that the weird stuff is part of normal and stops flagging it.
  • Swapping model types to fix a data problem. If 3 different types all get the same rows wrong, the rows are the problem.
  • Expecting it to know what is not in the input. If the thing that decides the answer is not in a column or in the text, no model type can find it.
  • Junk columns on distance based types. knn, kmeans, and dbscan measure distance across every column you send, and each column counts the same, so one that has nothing to do with the answer pulls rows together for the wrong reason. Send only the columns that matter.
Key Takeaway

Decide the shape of the answer first, a label, a number, a group, or a flag, then start with the simplest type in that family and put your time into real, balanced rows. Move to a heavier type only when your own test predictions ask for it, and since the rows stay the same, switching costs one retrain.

Explore This Topic

Classifiers

Regressors

Clusterers

Anomaly Detectors

Reference