What Is Machine Learning? A Worked Example and How to Get Started
Machine learning explained by doing it: a model learns a spring's stiffness (2.03 N/mm from 8 readings) by gradient descent, step by step and checked by script. Then the types of ML, overfitting in numbers, precision vs accuracy, where ChatGPT fits, a 2026 learning path with current tools, and Skill-Lync placement data on first data science jobs.

Machine learning is a way of building software in which the computer learns a rule from examples instead of being given the rule by a programmer. You show it data with known answers, it adjusts a model's numbers until its predictions match, and then it predicts answers for data it has not seen. To get started, learn Python, enough linear algebra and probability to follow the maths, and scikit-learn, then build small projects on data you understand.
Key takeaways
- Tom Mitchell's textbook definition (McGraw Hill, 1997): a program learns from experience E on tasks T, measured by performance P, if its performance at T, as measured by P, improves with E. Every ML project can be described by its E, T and P.
- Worked example below: from 8 spring readings, gradient descent learns a stiffness of 2.03 N/mm (the data were generated with 2.0). It matches the closed-form least-squares answer to 3 decimal places.
- Overfitting, shown with numbers: a degree-7 polynomial fits the same 8 readings perfectly (training error 0) but is off by 8.4 N one millimetre past the data. Its held-out error is 3.08 N against 0.41 N for a straight line.
- A defect detector can score 97% accuracy and still miss 1 in 5 bad parts. A model that flags nothing scores 95%. Precision and recall tell you more.
- Current tools (PyPI, November 2026): scikit-learn 1.9.1 (released 10 Sep 2026), PyTorch 2.15.0 (28 Oct 2026), Keras 3.15.1, TensorFlow 2.21.0.
- Skill-Lync placement records list 174 learners placed in data science roles, at a median starting offer of 3.6 LPA (snapshot 15 Nov 2026, mostly 2021-23 offers; details and caveats below).
This guide explains what machine learning is, how a model actually learns (one example worked step by step, with every number checked by a Python script), the main types of ML, overfitting, and how to judge a classifier. It then covers where ChatGPT fits, where engineers use ML, and a practical path to get started in 2026, with free resources and what Skill-Lync's placement data says about first jobs.
What is machine learning?
Machine learning (ML) is the branch of artificial intelligence in which a computer improves at a task by learning from data rather than following hand-written rules. A model, which is a formula with adjustable numbers called parameters, is fitted to examples. Once fitted, it can make predictions or decisions about new cases it has never seen.
Tom Mitchell's definition from his 1997 textbook is still the most useful one, because it forces you to say exactly what is being learned: a program learns from experience E with respect to tasks T and a performance measure P if its performance at T, measured by P, improves with E. For a spam filter, T is labelling emails, P is the share labelled correctly, and E is a pile of emails people have already marked. For the spring example below, T is predicting force from extension, P is the mean squared error, and E is eight bench readings. If you cannot name E, T and P for a project, it is not yet an ML problem.
How is machine learning different from normal programming?
In normal programming, a person writes the rule and the computer applies it to produce answers. In machine learning, the person supplies examples with the answers and the computer works out the rule. ML pays off when the rule is too complex to write by hand, such as spotting a crack in a weld image.
For a spring you would never use ML: Hooke's law is known, and a single measurement gives you k. That is exactly why it makes a good first example. Because you know the right answer, you can watch the learning process recover it and see what can go wrong.
How does a machine learning model learn? A worked example
A model learns by repeatedly comparing its predictions with the known answers and nudging its parameters in the direction that reduces the error. The error is measured by a loss function, such as the mean squared error. The nudging rule, gradient descent, moves each parameter a small step against the slope of the loss, until the loss stops falling.
The data. Eight readings of force against extension for a spring. These are illustrative bench data: we generated them from plus random measurement noise and rounded them to 0.1 N, so we know the true stiffness is 2.0 N/mm.
| Extension x (mm) | 2 | 4 | 6 | 8 | 10 | 12 | 14 | 16 |
|---|---|---|---|---|---|---|---|---|
| Force F (N) | 4.0 | 8.2 | 11.8 | 15.3 | 19.6 | 23.2 | 28.0 | 33.1 |
The model. A straight line with two parameters, a slope (the stiffness) and an intercept :
The loss. The mean squared error over the readings:
The update. Gradient descent with a learning rate :
Step 1 by hand. Start at , so every prediction is 0 and the loss is 407.3 N². The mean of is 203.75 and the mean of is 17.9, so the two gradients are and . One step gives and . The loss falls to 13.2 N².
Keep going. After 10 steps and the loss is 0.35 N². After 3,000 steps N/mm and N, with a loss of 0.29 N². The exact least-squares solution, computed directly, is , , so gradient descent has essentially found it. The learned stiffness is about 1.5% above the true 2.0 N/mm; the gap is the noise in eight readings.
Use it, and test it honestly. On eight more readings the model never saw (3, 5, ... 17 mm), its root-mean-square error is 0.41 N, about the same as on the training data (0.54 N), so it has learned the pattern rather than memorised the points. It predicts 40.2 N at 20 mm. That is an extrapolation beyond the last reading at 16 mm, and a real spring may stop being linear there. A model is only trustworthy inside the range of its data.
Everything in larger ML is this loop at a bigger scale: more parameters (a neural network can have millions or billions), a loss suited to the task, a smarter version of gradient descent, and a held-out test set to keep the result honest.
What are the main types of machine learning?
The main types are supervised learning (learning from labelled examples, as in the spring), unsupervised learning (finding structure in unlabelled data), semi-supervised learning (a few labels, much unlabelled data), self-supervised learning (labels made from the data itself, used to train large language models) and reinforcement learning (learning by trial, error and reward).
| Type | What it learns from | Typical tasks | Engineering example |
|---|---|---|---|
| Supervised: regression | Inputs with a known number as the answer | Predict a quantity | Remaining tool life from cutting time and spindle load |
| Supervised: classification | Inputs with a known category | Predict a label | Weld image: good or defective |
| Unsupervised | Inputs only | Clustering, dimensionality reduction, anomaly detection | Grouping vibration signatures from a fleet of pumps |
| Semi-supervised | A few labelled, many unlabelled examples | Classification when labels are costly | Defect images where only some have been inspected by an expert |
| Self-supervised | Unlabelled data, with the task built from the data | Predict a hidden part of the input | Language models predicting the next token of text |
| Reinforcement | Rewards from actions in an environment | Control, planning | Tuning a controller in simulation |
Most entry-level ML work in industry is supervised learning on tabular data: rows of measurements and a column you want to predict. That is where to start.
What is overfitting in machine learning?
Overfitting is when a model fits its training data so closely that it learns the noise as well as the pattern, so it does worse on new data. Google's Machine Learning Crash Course calls it memorising the training set. The warning sign is training error that keeps falling while error on held-out data rises.
Take the same eight spring readings and fit polynomials of increasing degree instead of a straight line. A degree-7 polynomial has eight coefficients, enough to pass exactly through all eight points.
| Polynomial degree | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
|---|---|---|---|---|---|---|---|
| Training RMSE (N) | 0.54 | 0.30 | 0.16 | 0.15 | 0.14 | 0.12 | 0.00 |
| Held-out RMSE (N) | 0.41 | 0.64 | 0.77 | 0.76 | 0.86 | 0.65 | 3.08 |
Training error falls as the degree rises. Held-out error is lowest for the straight line and far worst for degree 7. The degree-7 curve is twice as wrong as the straight line inside the measured range (0.82 N against 0.40 N), and at 17 mm, just one millimetre past the last reading, it misses by 8.4 N. The straight line, which matches the physics, wins. The fixes in practice are more data, a simpler model, regularisation (penalising large parameters), and always judging a model on data it was not trained on.
How do you know if a classification model is good?
Look at precision and recall, not just accuracy. Accuracy is the share of all predictions that are right, and it looks excellent whenever one class is rare. Precision is the share of flagged items that really are positive; recall is the share of real positives the model catches. Which matters more depends on the cost of each kind of mistake.
Worked example: a vision model inspects 1,000 machined parts, of which 50 are defective. It flags 60 parts, and 40 of those really are defective.
| Actually defective | Actually good | |
|---|---|---|
| Flagged defective | 40 (true positives) | 20 (false positives) |
| Passed as good | 10 (false negatives) | 930 (true negatives) |
- Accuracy = (40 + 930) / 1,000 = 97.0%.
- Precision = 40 / 60 = 66.7%: one in three rejected parts was actually fine (scrap or re-inspection cost).
- Recall = 40 / 50 = 80.0%: 10 defective parts, one in five, still ship (warranty and safety cost).
- F1 score, the harmonic mean of precision and recall, = 72.7%.
- A "model" that passes every part scores 95.0% accuracy with 0% recall. That is why accuracy alone is a trap on imbalanced data.
Is ChatGPT machine learning? AI vs ML vs deep learning
Yes. ChatGPT is built on a large language model, which is a machine learning model. Artificial intelligence is the broad goal of machines doing tasks that need intelligence; machine learning is the main way AI is built today; deep learning is ML with many-layered neural networks; and large language models are deep-learning models trained on huge amounts of text.
Google's Machine Learning Crash Course defines a language model as one that "estimates the probability of a token or sequence of tokens occurring within a longer sequence of tokens". Training one is the same loop as the spring: predict, measure the error against the real next token, adjust the parameters. The differences are scale (billions of parameters instead of two) and that the "labels" come free from the text itself, which is why it is called self-supervised. For a design or simulation engineer, classical ML on measured data and LLM-based tools are different jobs: see our pieces on AI surrogate models vs CFD and FEA solvers and AI agents in CAD and CAE.
Where is machine learning used in engineering?
Engineers use machine learning wherever there is plenty of measured or simulated data and a decision that depends on it. Examples are predicting machine failures from vibration and temperature, spotting defects in images, standing in for slow simulations, estimating a battery's state of charge, and recognising objects for driver-assistance systems.
- Predictive maintenance: classify a bearing as healthy or faulty from vibration features. Skill-Lync's free bearing fault detection project and predictive maintenance project walk through both with code.
- Surrogate models: train a fast model on a few hundred CFD or FEA runs, then use it to explore thousands of design variants. It is reliable only inside the range it was trained on, as the spring example showed.
- Quality inspection: image classifiers for welds, castings and PCBs, judged on recall for the defects that matter.
- Batteries and EVs: state-of-charge and state-of-health estimation from current, voltage and temperature data.
- ADAS: camera and radar perception (detecting lanes, vehicles and pedestrians) is deep learning.
The broader view is in our guide to AI for mechanical engineers.
How do I get started with machine learning in 2026?
Start with Python and the NumPy and pandas libraries, then learn enough linear algebra, calculus and probability to follow gradient descent and a loss function. Then use scikit-learn for classic models and finish small projects end to end, moving to PyTorch or Keras for deep learning after that. Expect about six months of steady part-time study to reach a solid project portfolio.
| Stage | Learn | Tools (current versions) | Finish with |
|---|---|---|---|
| 1. Python and data | Python basics, arrays, data frames, plotting | Python 3.11+, NumPy, pandas, Matplotlib | A cleaned dataset from your own field, with plots |
| 2. The maths | Vectors and matrices, derivatives, mean and variance, probability | Pen and paper, NumPy | Gradient descent written by hand, as above |
| 3. Classic ML | Train/test split, regression, classification, trees, clustering, metrics | scikit-learn 1.9.1 | Two projects with honest held-out scores |
| 4. Deep learning | Neural networks, CNNs for images, sequence models | PyTorch 2.15 or Keras 3.15 | An image or signal project |
| 5. Show it | Write-ups, code on GitHub, a short report per project | Git, Jupyter | A portfolio a hiring manager can read in 5 minutes |
Good free starting points: Tom Mitchell's Machine Learning textbook, which Carnegie Mellon hosts as a free PDF; Google's Machine Learning Crash Course, refreshed with interactive modules and a new introduction to large language models; and the scikit-learn user guide. If you prefer guided study with mentor reviews, Skill-Lync's Machine Learning Fundamentals In Depth and Math behind Machine Learning and AI using Python cover stages 2 and 3, and the Post Graduate Program in Data Science and Machine Learning runs through to deep learning. Our 24-week self-study plan sets out a week-by-week schedule.
Is machine learning a good career for engineering freshers in India?
It can be, but the usual first job is a data analyst or junior data scientist role, not "ML engineer". In Skill-Lync's placement records, 174 learners were placed in data science roles at a median starting offer of 3.6 LPA. Employers hire on projects you can explain, so build two or three solid ones before applying.
The figures, with their limits. Based on 3,711 Skill-Lync placement records up to 7 Nov 2026 (data snapshot of 15 Nov 2026). This is a starting point, and we will update it as new placements come in.
| Skill-Lync data science placements (snapshot 15 Nov 2026) | n | Median | Middle 50% |
|---|---|---|---|
| All data science roles | 174 | 3.6 LPA | 3.0-4.26 LPA |
| Data analyst / data scientist | 76 | 3.6 LPA | 3.0-4.2 LPA |
| Placed in 2024 | 33 | 4.0 LPA | 3.0-5.0 LPA |
| Placed in 2025 | 12 | 4.0 LPA | 3.62-4.88 LPA |
The companies with the most data science placements in these records are NielsenIQ (14), RNTBCI (10), Kabira Mobility (8), William O'Neil (6), Ola Electric (6) and TCS (5). Read the numbers with care: the sample is Skill-Lync learners who reported a placement, not the whole market. Most are starting offers from 2021-23, recent years are small (n = 12 in 2025), and they are not a promise of any salary.
On the policy side, the Union Cabinet approved the IndiaAI Mission on 7 March 2024 with an outlay of ₹10,371.92 crore (PIB). It includes public compute of 10,000 or more GPUs and an IndiaAI FutureSkills component meant to increase AI courses at undergraduate, master's and PhD level and set up data and AI labs in Tier 2 and Tier 3 cities. For an engineering graduate, the strongest position is usually ML plus your own domain: a mechanical engineer who can build a vibration classifier, or a civil engineer who can model sensor data from a structure, competes with fewer people than a generalist does. To work out which route suits your branch and timeline, talk to a Skill-Lync counsellor.
Frequently asked questions
What is machine learning in simple words?
Machine learning is teaching a computer by example. Instead of writing the rule yourself, you give the computer many examples with the right answers, and it adjusts a model until its answers match. It then uses what it learned to answer new cases. Spam filters, product recommendations and face unlock on phones all work this way.
Can I learn machine learning without coding?
You can understand the ideas without coding, and some no-code tools can train simple models. To work in ML, though, you need Python, because data cleaning, model training and checking results are all done in code. The good news is that the Python needed for a first project is modest: data frames, plots and a few scikit-learn calls.
How much maths do I need for machine learning?
For applied work you need school-level algebra plus three university topics: vectors and matrices, derivatives (for gradient descent), and basic probability and statistics (mean, variance, distributions). If you can follow the spring example on this page, including the gradient step by hand, you have enough maths to start, and you can learn more as you go.
How long does it take to learn machine learning?
For an engineering student studying part time, about three months gets you through Python and classic ML with scikit-learn, and about six months to a portfolio of two or three sound projects. Deep learning adds a few more months. Progress depends far more on finishing real projects than on the number of courses watched.
Is machine learning the same as AI?
No. Artificial intelligence is the wider field of making machines do tasks that need intelligence. Machine learning is one approach to AI, in which systems learn from data, and it is the approach behind almost all modern AI, including ChatGPT. Rule-based expert systems are AI without machine learning.
Which is better for beginners, scikit-learn or TensorFlow?
Start with scikit-learn. It covers regression, classification, clustering and model evaluation with a simple, consistent interface, and most tabular-data problems in industry are solved with it. Move to PyTorch or Keras (which runs on TensorFlow, JAX or PyTorch) when you need neural networks for images, signals or text.
Sources and further reading
- Tom M. Mitchell, Machine Learning (McGraw Hill, 1997), Carnegie Mellon University book page: definition of learning in terms of E, T and P (chapter 1); free PDF of the full book. Accessed 18 Nov 2026.
- Google for Developers, Machine Learning Crash Course: refreshed course with 12 modules including "Intro to Large Language Models". Accessed 18 Nov 2026.
- Google MLCC, Overfitting: definition; training loss falls while validation loss rises. Accessed 18 Nov 2026.
- Google MLCC, Intro to Large Language Models: definition of a language model. Accessed 18 Nov 2026.
- PyPI, scikit-learn (1.9.1, 10 Sep 2026), torch (2.15.0, 28 Oct 2026), keras (3.15.1, 29 Jul 2026), tensorflow (2.21.0, 6 Mar 2026): current versions. Accessed 18 Nov 2026.
- Keras, Introducing Keras 3: Keras 3 runs on JAX, TensorFlow or PyTorch. Accessed 18 Nov 2026.
- PIB, Cabinet Approves Ambitious IndiaAI Mission to Strengthen the AI Innovation Ecosystem, 7 Mar 2024: ₹10,371.92 crore outlay, 10,000+ GPU compute, IndiaAI FutureSkills. Accessed 18 Nov 2026.
- Skill-Lync placement records, snapshot 15 Nov 2026 (3,711 records up to 7 Nov 2026): data science domain n = 174 and top hiring companies. Aggregates only.
- Worked examples: Skill-Lync verification script (Python, NumPy), run 18 Nov 2026. Spring data are illustrative, generated from F = 2.0x plus noise; gradient descent checked against closed-form least squares.


