Choose a machine learning model by matching the required output, available training data, evaluation criteria, and computational constraints to an appropriate machine learning approach. No single model is best for every problem.
The Reasoning
First, define the task precisely by identifying input data, required output, and success measure. This establishes whether the problem requires supervised learning, unsupervised learning, or reinforcement learning.
| Problem and data | Suitable approach | Example |
|---|---|---|
| Labeled data and a discrete output category | Classification using supervised learning | Classifying email as spam or not spam |
| Labeled data and a continuous numerical output | Regression using supervised learning | Predicting a house price |
| Unlabeled data where patterns or groups must be discovered | Clustering using unsupervised learning | Grouping customers by purchasing behaviour |
| An agent learns through rewards and penalties | Reinforcement learning | Teaching a game-playing agent to select actions |
Next, compare candidate models using relevant criteria: predictive accuracy, training time, memory requirements, scalability, robustness to noisy data, and interpretability. A decision tree may be preferred when users must understand each decision, whereas a neural network may suit complex image data but be less interpretable. Practical constraints can therefore outweigh a small increase in accuracy.
Train candidate models on training data and compare them with separate validation data. Evaluate the selected model once on unseen test data. This separation reduces overfitting, where performance is strong on training examples but weak on new data. Use identical metrics when comparing candidates.