Introduction to Machine Learning
Machine learning helps a computer learn a useful pattern from examples instead of requiring a programmer to write every decision rule by hand.
Start With a Familiar Problem
Imagine an email service that must decide whether a new message is spam. We could write rules such as: if the message contains a certain word, mark it as spam. Real messages are more complicated. Spammers change their words, and a normal message may also contain those words.
A machine-learning system studies many past emails and their correct labels. It learns which combinations of words, links, senders, and other signals are useful. It then uses that learned pattern to classify a new email.
AI, Machine Learning, and Deep Learning
Artificial Intelligence is the broad goal of making computers perform tasks that appear intelligent. Machine Learning is one approach inside AI: it learns patterns from data. Deep Learning is a part of Machine Learning that uses multi-layer neural networks.
PrepLoom keeps ML and DL as separate subjects so that classical ML foundations are learned before neural networks.
Fixed Rules and Learned Patterns
Traditional programming starts with rules written by a programmer. The computer applies those rules to input data and produces an answer.
Supervised machine learning starts with examples and their known answers. A learning algorithm searches for model parameters that connect the inputs to the answers.
What Exactly Is Learned?
A model is a mathematical mapping from input values to an output. Training adjusts the model's parameters so that its outputs become closer to the correct answers in the training data.
For a house-price model, area and number of bedrooms may be inputs. The learned parameters describe how strongly those inputs affect the predicted price.
| Term | Simple meaning | House-price example |
|---|---|---|
| Example or sample | One item in the dataset | One house |
| Feature | Information given to the model | Area |
| Target | Answer to learn or predict | Sale price |
| Algorithm | Procedure that learns from data | Linear regression training |
| Model | The learned mapping | The fitted price equation |
| Parameter | A value learned during training | A coefficient |
| Hyperparameter | A setting chosen before or around training | Regularization strength |
| Loss | A number measuring prediction error | Difference from the true price |
| Prediction | Output for a new input | Estimated price |
In plain words: prediction = trained model(input). A lowercase x represents one example.
Training and Inference
Training is the learning stage. The algorithm repeatedly examines training examples, measures errors, and adjusts the model.
Inference is the usage stage. The trained model receives a new input and produces a prediction. Inference normally does not change the model.
The Basic Workflow
A useful ML system begins with a clearly defined problem and ends with an honest test on unseen data. Training a model is only one part of that process.

When Machine Learning Is a Good Choice
Machine learning is useful when the desired pattern is difficult to express as reliable hand-written rules, enough relevant examples are available, and the result can be measured.
- The same type of decision must be made many times.
- Past examples contain information about future cases.
- A clear metric can tell us whether the model is improving.
- The environment is stable enough for past patterns to remain useful.
When Simple Rules Are Better
Machine learning is not automatically the best solution. If a correct rule is short, stable, and easy to verify, normal programming is clearer and safer.
- Use a formula for a tax calculation whose rules are explicitly defined.
- Use validation rules to reject an empty required field.
- Do not train a model when there is too little reliable data.
- Do not use an inaccurate prediction where every decision must be provably correct.
Check Your Understanding
Classify each situation before thinking about an algorithm. The first question is whether learning from examples is actually needed.
Problem 01
Is learning useful?
A bank wants to estimate whether a transaction looks fraudulent using patterns from millions of reviewed transactions.
- 01The decision depends on many interacting signals.
- 02Reviewed past transactions provide examples and correct labels.
- 03Performance can be measured on unseen transactions.
Answer
This is a suitable machine-learning problem.
How a basic ML system works
- 01Define the input, the required output, and the success measure.
- 02Collect examples that represent the real problem.
- 03Prepare the examples and separate them into training, validation, and test data.
- 04Choose an algorithm and train a model on the training data.
- 05Use validation data to compare choices and improve the system.
- 06Evaluate the finished model once on the untouched test data.
- 07Use the model for inference and monitor whether real data changes over time.
Example
Learning to estimate delivery time
Past deliveries contain distance, traffic, weather, restaurant preparation time, and actual delivery time. Training learns a relationship between those inputs and the actual time. Inference uses the learned model to estimate the time for a new order.
A common mistake
A model does not understand a problem like a person. It learns statistical relationships from the examples and objective it receives.

