Machine learning · Animation

Pick a question and change the example. Use the animations for direct intuition; explanatory pages will be added separately.

Try machine learning

Move a slider and see what changes in the example. Pick a category to find a problem you’d like to try.

7 methods

Logistic regression

Separate two classes with a line, then estimate the probability of belonging to one class. A classic baseline.

What it actually does

Weight and add the features to obtain a score, then use an S-shaped sigmoid to map it to a probability between 0 and 1. Predict the positive class when that probability exceeds a threshold, usually 0.5.

An analogy

Stretch a clothesline through a crowd: one side is high churn risk, the other low risk. Logistic regression can show which features determine the line’s position and angle.

What analysts need to know

  • Coefficients describe changes in log-odds, such as the change associated with one more unit of purchase frequency.
  • Probabilities support risk tiers, such as selecting the top 10% of at-risk users for outreach.
  • It is a linear model; strongly correlated features can make its coefficients unstable.

Typical uses

  • A baseline for churn or conversion prediction and a comparison model for A/B experiments.
  • Explaining why a prediction was made to business stakeholders, rather than relying on a black box.

Interactive demo · live computation

Purchase frequency → · Average order value ↑ Regular · High-value
Training accuracy
73.3%
Misclassified samples
56
Positive region A
High-value 44 / Regular 0
Negative region B
High-value 56 / Regular 110

This button searches angles and positions for the fewest training classification errors, not a maximum-likelihood probability fit.

Try it yourself

Move both sliders and watch the mistakes marked with yellow rings and crosses. Compare merely separating the classes with finding a better boundary; region metrics show their actual class composition.

Decision tree

Like a medical questionnaire: ask about the key indicator first, narrow the possibilities, and reach a conclusion.

What it actually does

Choose a feature and threshold that split the current samples into purer groups. Repeat within each group until it is sufficiently pure or the depth limit is reached. A path from root to leaf is a complete decision rule.

An analogy

A doctor asks, “Have you logged in during the last three months?” If not, churn may be likely. If yes, ask, “Have you paid?” Each question narrows the answer.

What analysts need to know

  • The output is a set of if-else rules that can be used directly for audience selection.
  • Deep trees can memorize the training data. A depth of 3–5 or pruning is a common starting point, but must be validated.
  • Each split considers one feature. Missing-value support depends on the implementation; it is not automatic.

Typical uses

  • Audience rules: active on more than 20 of the last 30 days and average order value above 200 identifies a high-value segment.
  • The building block of random forests and XGBoost, and a tool for explaining more complex models.

Interactive demo · live computation

Purchase frequency → · Average order value ↑ Regular · High-value

Leaf: Purchase frequency ≤ 3.325 ∧ Average order value ≤ 3.095
109 users · Positive-class share: 2.8%

Selected rule: Purchase frequency ≤ 3.325 ∧ Average order value ≤ 3.095

Try it yourself

Select a leaf to highlight its region and matching users. Select an internal node to inspect its split feature and the samples it covers.

Naive Bayes

Counts and probabilities make fast decisions, especially for text classification.

What it does

For each label, count how often feature values occur and estimate the label’s prior probability. For a new sample, Bayes’ rule combines the prior with the feature likelihoods to compare label probabilities, then selects the largest.

What makes it “naive”?

It assumes features are independent given the label. Real features, such as age and income, often remain related. Even with this simplifying assumption, the model can be useful and computationally inexpensive.

What analysts should know

  • A practical baseline for text classification, such as identifying delivery complaints.
  • Useful with many features, such as thousands of words, and relatively few samples.
  • This categorical example bins numeric features; Gaussian Naive Bayes can instead model continuous values directly.

Typical uses

  • Sentiment analysis, ticket routing, and spam filtering.
  • Fast training and prediction on labeled customer-service text; actual runtime depends on data and implementation.

Try it

Age
Income
ConditionP(condition | buy)P(condition | no purchase)
Age = Young75.3%22.4%
Income = High61.2%36.7%
Prior (historical share)63.8%36.2%
Multiply, then normalize90.8%9.2%
Buy
90.8%
Do not buy
9.2%

Prediction: Buy · 90.8%

These are model probabilities under the conditional-independence assumption, not calibrated purchase guarantees. Add-one smoothing is applied to both feature likelihoods.

Your turn

Switch age and income and follow the table from likelihoods and priors to normalized posteriors. In this dataset, high income raises the estimated purchase probability.

Support Vector Machine

Separating classes is not enough: leave a wide margin on both sides.

What it does

Many lines can separate two classes. A maximum-margin SVM seeks a boundary with as much clearance as possible from nearby samples. Support vectors are the samples that constrain the fitted boundary; soft-margin models can allow violations.

An analogy

Imagine building a road between two neighborhoods. You want the widest feasible road, rather than one that brushes against a building. That clearance is the margin.

What analysts should know

  • Standardize features before fitting: their scales can strongly affect the boundary.
  • Linear kernels suit many high-dimensional problems; other kernels can model curved boundaries.
  • Raw scores are not probabilities without calibration, and rules can be difficult to interpret.

Typical uses

  • Binary classification with moderate sample sizes and high-dimensional behavior vectors.
  • Text classification using bag-of-words features.

Try it

Purchase frequency → · Average basket value ↑ · Ordinary · circles · High-value · squares

Points inside the illustrated band
18
Classification accuracy
97.1%
Source support vectors
18
Points in the full illustrated band
18

Source illustration: the line uses the direction between class means and a band derived from the supplied support-vector indices. Changing width does not retrain an SVM or change its predictions; orange rings mark the supplied indices, not every point inside the band.

Your turn

Move the width slider toward 1× and watch the dashed edges expand. Toggle the supplied support-vector markers and compare their locations with the points in the band. This changes the illustration, not the fitted predictions.

K-nearest neighbors

No parameter training: look at the nearest labeled samples and let the neighbors vote.

What it actually does

Treat historical samples as points on a map. For an unknown sample, find its K closest labeled points and take the majority label. The stored data itself is the model.

An analogy

When pricing a house, look at recent sales next door. KNN lets the neighbors determine the answer: classification votes on labels, while regression can average their values.

What analysts need to know

  • A small K is easily swayed by outliers; a large K blurs the boundary.
  • Units strongly affect distances, so consider scaling the features first.
  • A naive prediction compares against every stored record, which can be slow on large datasets.

Typical uses

  • Initial validation of user segments, or filling missing values from similar samples.
  • A quick baseline for a small dataset.

Interactive demo · live computation

Purchase frequency → · Average order value ↑ Regular · High-value

Among 9 neighbors: 9 high-value · 0 regular → predicted high-value user

Tap or drag the query point, use the coordinate sliders below, or focus the plot and move with arrow keys.

Try it yourself

Change K from 1 to 15 and watch the vote flip. Near the boundary, K can determine the result, so choosing it requires experiments.

Random forest

What class do these small trees vote for?

Add votes from small trees fitted on different draws of the same nine fruits, with repeats allowed. This omits random feature selection at each split.

A way to picture it
Like asking several fruit sorters and taking a vote. Each chip is one tree’s answer; adding trees changes the voting panel in this fixed teaching example.
Where it can help
  • Classify labeled records with varied feature interactions.
  • Estimate numeric outcomes from tabular data.

Try this Add trees and count apple and pear votes. More voters may leave the final answer unchanged.

1 · Apple (0)2 · Pear (1)3 · Apple (0)
Preparing controls
Simplified example
What changed

Output: Apple (0)Apple votes: 2Pear votes: 1

XGBoost

How do corrective trees change the chance of a pear?

Refit three depth-one trees to binary logistic gradients and Hessians. Each tree updates the class score with L2-stabilized leaves. This small teaching model omits deeper trees, column sampling and production split regularization.

A way to picture it
Like repairing a rough staircase in several passes: each new tree works on the errors left behind. The learning rate controls how much of each correction is applied.
Where it can help
  • Predict risk from labeled tabular records.
  • Estimate prices from interacting property features.

Try this Change the learning rate and compare the pear probability and logistic loss. This example refits three correction trees.

1 · Sweetness y ≤ 4.5 · 49.6%2 · Sweetness y ≤ 4.5 · 44.7%3 · Sweetness y ≤ 4.5 · 40.6%
Preparing controls
Simplified example
What changed

Estimated chance of pear: 40.6%Training logistic loss: 0.48Sample errors: 1

What to explore next

See how real projects and papers use these methods. Look at the data, evaluation, and results to judge how well each project works.

Choose a learning path

Explore what people are building and researching

Browse frontier applications in open-source projects and follow new research in papers.

Reading guide and evidence

Compare 21 methods by the problem they solve and the evidence their outputs provide. Small numerical demonstrations show selected computations; a diagram or a good training fit is not evidence of generalization. Validate on independent, representative data.

For citation: OpenStarMap’s demonstrations illustrate selected computations on small examples or schematic processes. They are not benchmark results. The references explain the underlying methods; they do not certify this site’s implementation.

Method summaries and references
  1. Logistic regression

    Logistic regression classifies examples by combining features into a score and mapping it to a class probability. Multiclass variants estimate probabilities across several classes.

    What the demonstration does: Computes probabilities from a small fitted logistic model; moving the boundary changes its offset, not a new training run.

    References: scikit-learn: Logistic regression

  2. Decision tree classifier

    Predict a category by following a sequence of feature questions. Training chooses splits that make the labels in each branch more consistent.

    What the demonstration does: Traces splits and leaf class distributions in a small example tree. It is not a validation study.

    References: scikit-learn: Decision trees and minimal cost-complexity pruning

  3. Naive Bayes

    Compare how likely the features are under each class, using the simplifying assumption that features are conditionally independent given that class.

    What the demonstration does: Combines class priors and feature likelihoods in a toy example; independence is an assumption, not an observed fact.

    References: scikit-learn: Naive Bayes variants

  4. Support vector machine (SVM)

    Seek a class boundary with a wide margin while allowing controlled violations. A kernel can represent nonlinear similarities. This entry uses SVC classification, not the separate SVR task.

    What the demonstration does: Shows a small margin/boundary example. Changing visual settings does not establish a full kernel SVC optimization.

    References: scikit-learn: Support vector machines

  5. K-nearest neighbors (KNN)

    Predict a class from the most similar stored labeled examples. Nearby examples vote, optionally giving closer neighbors more weight.

    What the demonstration does: Computes distances and a neighbor vote on stored example points; this is prediction, not iterative training.

    References: scikit-learn: Nearest neighbors

  6. Random forest

    Train many classification trees on varied samples and feature subsets, then combine their class votes. Diversity between trees helps reduce the instability of a single tree.

    What the demonstration does: Combines example tree predictions. The vote illustrates ensembling, not calibrated confidence or a performance benchmark.

    References: scikit-learn: Random forests; Breiman: Random Forests (2001)

  7. XGBoost

    An optimized gradient-boosted-tree system. This lesson uses binary logistic classification: trees sequentially improve a class score with regularized leaf outputs. The library also supports other objectives, but this entry demonstrates classification only.

    What the demonstration does: Computes a small sequence of logistic correction trees; it is not the full XGBoost library or a held-out evaluation.

    References: XGBoost: Parameter documentation; Chen & Guestrin: XGBoost (2016)

  8. Linear regression

    Predict a number as a weighted sum of input features plus an intercept. Fitting chooses coefficients that reduce prediction errors; ridge and lasso add regularization.

    What the demonstration does: Computes a line and squared errors as its slope changes. A manually adjusted line is not a new least-squares fit.

    References: scikit-learn: Ordinary least squares and regularized linear models

  9. Polynomial regression

    Expand numeric inputs into powers, then fit a linear combination of those features.

    What the demonstration does: Fits polynomial coefficients to nine synthetic observations with degree 1–5; training error alone cannot select the degree.

    References: Polynomial features; Ordinary least squares

  10. Regularized regression · Ridge / Lasso

    Penalize coefficient size while fitting numeric targets. Ridge uses L2; Lasso uses L1.

    What the demonstration does: Fits small standardized Ridge/Lasso examples and compares shrinkage. Zero coefficients do not prove causal irrelevance.

    References: Ridge regression; Lasso

  11. Regression tree

    Predict a number by splitting the feature space into regions. A squared-error tree returns the average of the training targets in the leaf reached by the input.

    What the demonstration does: Splits a small numerical example and displays leaf averages; no generalization claim follows from the fit.

    References: scikit-learn: Regression trees and pruning

  12. K-means

    Discover groups in numerical data by fitting k centers to the input features. Each point joins its nearest center, and each center moves to the mean of its assigned points.

    What the demonstration does: Reassigns example points to centers and updates their means. Results depend on initialization and the chosen cluster count.

    References: scikit-learn: K-means

  13. Hierarchical clustering

    Build a tree of nested groups. In the agglomerative version, each point starts alone and the closest groups are merged step by step.

    What the demonstration does: Shows successive single-linkage merges of example points; the merge map is not a dendrogram or a validated taxonomy.

    References: scikit-learn: Hierarchical clustering

  14. DBSCAN

    Grow clusters through density-connected core points and leave sparse observations as noise.

    What the demonstration does: Computes neighborhoods, core points, border points and noise on a small synthetic dataset.

    References: DBSCAN

  15. Self-organizing map (SOM)

    Map numerical examples onto a small grid of prototype vectors. Nearby grid positions are encouraged to respond to similar examples, making a high-dimensional dataset easier to explore.

    What the demonstration does: Computes a neighborhood update-strength illustration on a small grid; it does not train a complete self-organizing map.

    References: Kohonen: Self-Organized Formation of Topologically Correct Feature Maps (1982)

  16. Two-Step clustering

    First compress records into many small pre-clusters, then group those summaries hierarchically. Implementations marketed as Two-Step often support mixed numerical and categorical data.

    What the demonstration does: Illustrates pre-clustering followed by grouping. It is not a full mixed-data Two-Step implementation with automatic model selection.

    References: Chiu et al.: A Robust and Scalable Clustering Algorithm for Mixed Type Attributes (2001); scikit-learn: BIRCH (related pre-clustering method)

  17. Apriori

    Find items that often appear in the same basket. Apriori builds larger frequent itemsets from smaller ones: if a set is frequent, each of its subsets must also be frequent.

    What the demonstration does: Counts itemsets and support in example transactions; frequent co-occurrence is not causation.

    References: Agrawal & Srikant: Fast Algorithms for Mining Association Rules (1994)

  18. FP-Growth

    Compress baskets into a tree with shared prefixes, then mine frequent itemsets by following conditional paths through the tree.

    What the demonstration does: Builds a shared-prefix FP tree from example transactions. It stops before conditional-pattern mining.

    References: Han, Pei & Yin: Mining Frequent Patterns without Candidate Generation (2000)

  19. Principal component analysis (PCA)

    Project numerical features onto a smaller set of perpendicular directions. PCA selects the directions that retain the most input variance, an unsupervised objective. Evaluate separately whether those directions help predict the target.

    What the demonstration does: Computes a small linear projection and retained variance; variance does not measure downstream prediction accuracy.

    References: scikit-learn: PCA

  20. Time-series forecasting

    Predict future numerical values using time-ordered observations. Several model families tackle this task. ARIMA, for example, combines autoregression, differencing, and past error terms.

    What the demonstration does: Computes a small autoregressive forecasting example; it is not a complete ARIMA or seasonal forecasting pipeline.

    References: Hyndman & Athanasopoulos: Forecasting—ARIMA models; scikit-learn: Time-series split

  21. AprioriAll

    Find ordered sequences that recur across many histories. “A then B” and “B then A” count as separate patterns. The result describes recurring sequences in past records; forecasting estimates future values.

    What the demonstration does: Illustrates ordered event patterns; it is not a full AprioriAll mining run.

    References: Agrawal & Srikant: Mining Sequential Patterns (1995)

Questions about this learning guide

Do these animations train a real AI model?

Some demonstrations fit small numerical models or compute individual updates. Others use fixed values or schematic animations. Each method summary states its scope; none is evidence of production training or real-world performance.

Can I use the displayed result as an accuracy benchmark?

No. The examples are designed to explain a mechanism, not compare accuracy. Evaluate a model on independent, representative data and check the assumptions of the task.

Can I read this guide without running the animations?

Yes. The summaries, demonstration boundaries, questions and source references are available as page text without JavaScript. Interactive controls and animated visuals require JavaScript.

Structured data helps describe this page; search visibility, AI citations and rich results are not guaranteed.

A small teaching example focused on how the method works.