October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
DM9

DM9: Rules, Regression, and KNN—How These Prediction Methods Work

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Rules, regression, and k-nearest neighbors (KNN) make predictions in fundamentally different ways. A rule-based model applies explicit conditions, regression estimates a numeric outcome, and KNN looks at nearby examples before predicting. The right comparison is not which method is universally “best,” but what each predicts, how it represents evidence, how it is tuned, and how it performs on data it did not train on.

The label “DM9” is not uniquely identifiable from the available institutional material. A University of Pisa Data Mining page uses “DM9 CFU” in an optional-project context and lists KNN, regression, and rule-based classifiers; Cornell’s archived Fall 2019 CS4780/5780 syllabus covers the same method families. Neither page is confirmed as the definitive source for this exact title.

Start with the prediction target

The first question is whether the outcome is a class or a number.

  • Classification predicts a label such as “fraud” or “approved.”
  • Regression predicts a numeric or continuous value such as delivery time, demand, or temperature.

“Regression” therefore does not mean every predictive model. A rule set or KNN model can perform classification or regression, depending on the target and the prediction rule.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Rule-based prediction

How a rule produces an answer

A rule-based model expresses decisions as conditions followed by an outcome:

IF balance < 0 AND payment_history = “late” THEN risk = “high”

A model normally contains multiple rules. When more than one rule matches, an ordered rule list, rule priority, or a tie-breaking policy determines which conclusion is used. A default rule can handle cases that match none of the explicit conditions.

Rank #2
Sale
Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow: Concepts, Tools, and Techniques to Build Intelligent Systems
  • Use scikit-learn to track an example ML project end to end
  • Explore several models, including support vector machines, decision trees, random forests, and ensemble methods
  • Exploit unsupervised learning techniques such as dimensionality reduction, clustering, and anomaly detection
  • Dive into neural net architectures, including convolutional nets, recurrent nets, generative adversarial networks, autoencoders, diffusion models, and transformers
  • Use TensorFlow and Keras to build and train neural nets for computer vision, natural language processing, generative models, and deep reinforcement learning

What rules represent well

  • Interpretability: a reader can inspect the conditions behind a prediction.
  • Domain policy: rules can mirror requirements that are already written in business or operational language.
  • Discrete decisions: they are natural for class labels and threshold-based actions.

Where rules can fail

Rules can become long, contradictory, or brittle when a problem has many interacting variables. A threshold that works in one population may perform poorly after the data distribution changes. Rules also need an explicit treatment of missing values and cases that satisfy several rules at once.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Regression and linear prediction

Regression estimates a number

In ordinary linear regression, a numeric prediction is represented as a weighted combination of input features:

ŷ = β₀ + β₁x₁ + β₂x₂ + … + βₚxₚ

The coefficients describe how the fitted model changes its estimate as features change, subject to the model’s assumptions and the way the data were prepared. The output is a number rather than a class label.

Linear classification is related but different

A linear classifier also computes a weighted score, but it turns that score into a class decision. Perceptrons and other linear classification rules are examples. Logistic regression uses a linear score to model class probabilities, while ridge regression adds regularization to a linear regression objective. These methods share mathematical ingredients—features, weights, and an optimization procedure—yet their targets and loss functions differ.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Strengths and limits

  • Strengths: fast prediction, compact representation, and coefficients that can support interpretation.
  • Limits: a strictly linear relationship may miss curves, interactions, and local structure unless features are transformed or expanded.
  • Regularization: methods such as ridge regression penalize overly large coefficients, which can improve stability when predictors are numerous or correlated.

K-nearest neighbors (KNN)

Instance-based learning

KNN is an instance-based method: instead of learning one global equation or a fixed list of rules, it retains labeled training examples. To predict a new case, it calculates a distance to the stored examples and selects the k closest.

  • For classification, the neighbors vote; an unweighted vote gives each neighbor equal influence.
  • For regression, the prediction is commonly an average of the neighbors’ numeric outcomes.
  • In a weighted version, nearer neighbors receive more influence than farther ones.

Why the choice of k matters

A small k follows local detail closely but can react strongly to noise or an unusual training example. A large k smooths the prediction across more examples but can blur meaningful local patterns. There is no universal best value: choose k using validation data or cross-validation rather than the training set alone.

Distance, scale, and prediction cost

KNN is only as sensible as its distance measure. If one feature is measured in thousands and another in decimals, the large-unit feature can dominate unless the inputs are scaled appropriately. Categorical variables also require a distance treatment that reflects their meaning; simply assigning arbitrary numeric codes can create misleading proximity.

Because KNN compares a query with stored examples at prediction time, it can require more computation and memory during deployment than a compact rule list or linear model. The cost depends on the number of stored cases, the number of features, and any search index used.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Side-by-side comparison

Method Typical target Representation Main tuning concern Interpretability Prediction behavior
Rule-based model Usually a class, but numeric outcomes are possible Conditions mapped to outcomes Rule thresholds, ordering, coverage, and conflict handling High when the rule set is short and consistent Applies conditions; cost is usually low
Linear regression Numeric value Weighted sum of features Feature specification and regularization Coefficients are inspectable, subject to scaling and assumptions Evaluates a compact equation
Linear classifier or logistic regression Class label or class probability Linear score followed by a decision or probability mapping Regularization and decision threshold Often relatively high Evaluates a compact equation
KNN Class or numeric value Nearby stored examples k, distance metric, weighting, and feature scaling Local examples are explainable, but the overall boundary may be complex Searches the training set at prediction time

How to assess and select a model

Training performance alone is not evidence that a method will generalize. Cornell’s supervised-learning syllabus explicitly treats model selection and assessment, including train/validate/test splits and k-fold cross-validation.

  1. Define the target and metric. Use a classification metric for class labels and a numeric-error metric for regression. Decide what kinds of mistakes matter before comparing models.
  2. Separate the data. Keep a test set untouched while choosing rules, coefficients, feature processing, and KNN’s k. A train/validation/test split is one option.
  3. Fit candidate methods on training data. For KNN, perform scaling and any distance construction inside the training process so information from validation or test cases does not leak into the fit.
  4. Tune on validation data or by k-fold cross-validation. Compare plausible values of k, regularization strengths, rule thresholds, or feature sets.
  5. Evaluate once on the held-out test set. Report the result with the data split, metric, and relevant preprocessing described. Do not treat a test result used repeatedly for tuning as an independent final estimate.
  6. Inspect failure cases. Check which classes, value ranges, or subgroups produce errors. A small average error can conceal serious performance problems in a minority case.

Choosing among rules, regression, and KNN

Prefer rules when decisions must be auditable

Rules are a strong starting point when stakeholders need to read, challenge, and revise the decision logic. Keep the rule set ordered and test coverage, conflicts, and the default outcome.

Prefer a linear model when a stable global relationship is plausible

Regression and linear classification are attractive when prediction must be fast, the feature effects should be inspectable, or the dataset is large enough that storing and searching every example is undesirable. Validate whether linear assumptions are adequate rather than assuming they are.

Prefer KNN when local similarity is meaningful

KNN can work well when nearby cases genuinely share outcomes and the feature representation supports a meaningful distance. It is also useful for collaborative-filtering-style problems; Cornell’s KNN coverage includes both regression and collaborative filtering. Treat scaling, missing values, memory use, and prediction latency as first-class design concerns.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

DM9 course context and further reading

The University of Pisa Data Mining 2019/20 material associates “DM9 CFU” with an optional project and lists KNN, regression, and rule-based classifiers. Cornell’s Fall 2019 CS4780/5780 syllabus describes a broader supervised-machine-learning course covering instance-based learning, KNN, decision trees, linear rules, support-vector machines, generative models, and statistical learning theory. It also lists logistic and ridge regression among regularized linear models. These references support the concepts here, but they do not establish the exact identity of a course titled “DM9.”

Cornell’s course description summarizes the field this way: “Machine learning is concerned with the question of how to make computers learn from experience.” The syllabus names Shai Shalev-Shwartz and Shai Ben-David’s Understanding Machine Learning: From Theory to Algorithms as its main textbook. That makes the book a useful optional path for theoretical depth, not a confirmed requirement for DM9.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Read next

Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.