Skip to content
You Start with one site
Amounts in Start with one site
Engineering · Mathematics, AI & Reasoning

ML/AI Fundamentals

Fit models to machine readings in Python, and judge them by the mistakes they make. Nine lessons, from a straight line to a model that runs inside a microcontroller.

Found this useful?
Ninety machine readings plotted by vibration against temperature. A line at 3.8 mm/s splits them; most readings before a failure, marked with crosses, lie to its right.

A bearing fails on the night shift, and the line stops for a day. The readings of the week before showed it coming, but nobody wrote the rule. A model that scored 97 % on a tidy file fails in its first week on a real pump.

In this course you fit the rule from past readings and check it on readings it has never seen. You count the failures it misses and the alarms it raises for nothing, because those decide whether people trust it. The last lesson puts a model to work and shows when it no longer matches its machine.

How each lesson goes
  1. 1Start from a problemWhich boards are defective? A missed one reaches the customer.
  2. 2Look at the readingsGaps, spikes and stuck values, before any model.
  3. 3Fit it in PythonWatch the loss fall, step by step, in NumPy and scikit-learn.
  4. 4Judge it by its missesTest on rows the model never saw, and read the errors.
You will be able to
  1. Fit a model to readings and check it on readings it has never seen
  2. Judge a model by the failures it misses and the false alarms it raises
  3. Put a model to work, and see when it no longer matches its machine

New to this? Know Python and NumPy? Start with lesson 1: fit a straight line, then a curve that fits too well.

You need Python 3 with NumPy, Matplotlib and scikit-learn, on Windows, Mac or Linux.

The engineering behind it

How a model learns a pattern from data, and how to tell when it is fooling you.

Lessons
Lesson 1 · 6 minWhat ML Actually IsA model is a rule with numbers to adjust. Fit curves of degree 1 to 15, and see which one is right for new data.Curve fittingTrain and testOverfitting Lesson 2 · 5 minLinear RegressionPredict indoor temperature from several inputs, then let the misses show what the model lacks.scikit-learnScalingRMSE and R²Residuals Lesson 3 · 5 minClassificationFind defective sensor boards, and choose the threshold by what each mistake costs.Logistic regressionConfusion matrixPrecision and recallThreshold Lesson 4 · 5 minDecision Trees and Random ForestsFind the rule that warns of a bearing failure: vibration above 3.8 mm/s, then temperature above 66 °C.Decision treesRandom forestsRare failuresFeature importance Lesson 5 · 7 minGradient DescentWrite gradient descent in a few lines of NumPy, and see what a learning rate too small or too large does.LossGradientLearning rateScaling Lesson 6 · 5 minNeural Networks from ScratchTwo level switches that must agree: a rule no straight line can learn, and a small network that can.NeuronsXORBackpropagationThree classes Lesson 7 · 4 minPractical ML with Scikit-LearnFive models compared fairly on the energy use of a building, the best one tuned, tested once and saved.PipelinesCross-validationGrid searchSaving models Lesson 8 · 4 minWorking with Sensor DataClean gaps, spikes and drift, then flag a failing pump up to a day ahead.Missing valuesOutliersFeaturesRecall Lesson 9 · 5 minFrom Training to DeploymentPut a model to work three ways, the smallest a 1760-byte C file, and notice when it drifts.Batch runsFlask APIC exportDrift
More about this course

Every score needs a second number

A high accuracy can hide a useless model. In each lesson the number that matters comes from what a mistake costs.

  • Accuracy 98.7 %the board model still misses 7 of 30 defective boardsClassification
  • Accuracy 93.9 %the forest beats the single tree, but misses 11 failures, not 8Trees and forests
  • R² 0.616the misses form a daily wave; two time features raise it to 0.824Regression
  • Learning rate0.01 learns; 0.0001 leaves the loss at 47 after 200 steps; 0.05 makes it grow without endGradient descent
  • Recall 96 %the pump model flags 171 of 179 hours before a failure, with 23 false alarmsSensor data

Advice from the model. Limits in the device.

The model
An estimate
  • Inspect this pump this week
  • Order a bearing
  • Checked each month against what technicians found

Best for advice to a person, or a slow decision.

The controller
A fixed rule
  • Stops a motor at once on high temperature
  • Can be read and tested
  • Needs no network and no training readings

Best for anything that protects people or equipment.

The tools

Python and NumPyGradient descent and a neural network, written by hand first.
scikit-learnThe same few commands for every model, in a pipeline.
Programs that run as writtenEach program is complete. A fixed seed gives the numbers in the lesson.
Three ways to deployA program on a schedule, a small web service, and C code for a microcontroller.
Windows, Mac and LinuxOne pip install, the same on every system.

Honest limits. The lessons use practice readings made by each program, with the faults of real ones: gaps, spikes, drift and rare failures. Your own machine's readings will need the same checks.

Before you start

  • Python: functions, loops, lists and dictionaries
  • NumPy arrays
  • Algebra, derivatives and matrix multiplication
  • pip install numpy matplotlib scikit-learn
The full course notes

You already know curve fitting. Machine learning is that idea, generalized. Instead of fitting a polynomial to a handful of points by hand, you let the computer discover the best function from thousands (or millions) of data points. The math underneath is the same calculus, linear algebra, and statistics you have already studied. This course connects those foundations to the tools and techniques that power modern ML, with complete Python code you can run in every lesson. #MachineLearning #Python #Engineering

What This Course Covers

Lesson 1: What Machine Learning Actually Is

What Machine Learning Actually Is. Start with curve fitting. Move to train/test splits. See overfitting and underfitting with your own eyes. Understand the central tension of all ML: models that are too simple miss patterns, models that are too complex memorize noise.

Lesson 2: Linear Regression and Prediction

Linear Regression and Prediction. Predict indoor temperature from outdoor temperature, humidity, and time of day. Build the full scikit-learn pipeline: feature scaling, train/test split, evaluation metrics, residual analysis.

Lesson 3: Classification: Yes or No Decisions

Classification: Yes or No Decisions. Detect defective sensor boards from test measurements. Logistic regression, confusion matrices, precision, recall, ROC curves, and the problem of class imbalance.

Lesson 4: Decision Trees and Random Forests

Decision Trees and Random Forests. Predict equipment failure from vibration, temperature, and operating hours. Visualize the decision rules the model discovers. Compare single trees to random forests.

Lesson 5: How Models Learn: Gradient Descent

How Models Learn: Gradient Descent. Implement gradient descent from scratch in 25 lines of NumPy. Watch the loss decrease iteration by iteration. Understand learning rate, batch size, and why this is the engine behind all modern ML.

Lesson 6: Neural Networks from Scratch

Neural Networks from Scratch. Build a two-layer neural network in pure NumPy. Forward pass, backpropagation, sigmoid and ReLU activations. Solve XOR and classify sensor readings into three categories. No TensorFlow needed.

Lesson 7: Practical ML with Scikit-Learn

Practical ML with Scikit-Learn. The complete, reusable ML workflow: Pipeline, StandardScaler, cross-validation, GridSearchCV. Compare 5 models on the same dataset. Save and load models with joblib.

Lesson 8: Working with Real Sensor Data

Working with Real Sensor Data. Handle missing values, outliers, and drift. Engineer features from raw sensor readings: rolling statistics, rate of change, FFT peaks. Build a predictive maintenance model.

Lesson 9: From Training to Deployment

From Training to Deployment. Three deployment paths: Python script, Flask REST API, or C arrays for MCU firmware. Model monitoring, data drift detection, and the retraining lifecycle.

Prerequisites

Python and basic math required

You should be comfortable with:

  • Python programming (functions, loops, lists, dictionaries)
  • NumPy basics (arrays, broadcasting, vectorized operations)
  • Basic math: algebra, derivatives, matrix multiplication

Helpful but not required:

  • The Applied Mathematics course on SiliconWit (we reference it when relevant)
  • Probability and statistics concepts
  • Experience with Matplotlib for plotting

Setup

All lessons use the same Python environment. Install the dependencies once:

Terminal window
pip install numpy matplotlib scikit-learn

Every code block in this course is complete and runnable. Copy it, paste it into a .py file or a Jupyter notebook, and run it. Every script uses np.random.seed(42) so you will get the same numbers and plots we show.

Where This Course Leads

  1. ML/AI Fundamentals (this course) Understand the core ideas: fitting, generalization, loss functions, gradient descent, and evaluation.

  2. Edge AI / TinyML Take trained models and deploy them on microcontrollers. The Edge AI / TinyML course picks up where this course leaves off.

  3. IoT Systems Combine ML inference with sensor networks and cloud integration in the IoT Systems course.

© 2021-2026 SiliconWit®. All rights reserved.

9 lessons, in order.

SiliconWit makes these courses. We also run siliconwit.io, a monitoring service.