พื้นฐานการเรียนรู้ของเครื่อง

Supervised/unsupervised learning, data splitting, overfitting and model evaluation

Last updated:

Why it matters

Machine learning (ML) lets a computer find patterns in example data instead of having every rule written by hand. Drone work produces plenty of data to learn from: flight logs with vibration and motor current, aerial images and maintenance records. Yet a model that looks accurate in the lab can fail in practice if the data were split wrongly, the wrong metric was used, or the model memorised its training data instead of learning a pattern. This unit sets out the basics to understand before trusting any model.

Kinds of learning

KindData usedDrone example
SupervisedEach example has a label (the answer)Classify motors as healthy or faulty (classification); predict remaining flight time (regression)
UnsupervisedNo labels; the model finds structureGroup similar flights; find flights that differ from the rest
ReinforcementRewards from acting in an environmentLearning control in a simulator

A feature is an input to the model, such as mean vibration and hover current. Parameters are internal values the model adjusts during training. Hyperparameters are settings we choose, such as the depth of a decision tree.

Splitting the data correctly

Data are split into three sets with different jobs.

  • Training set: used to fit parameters.
  • Validation set: used to choose the model and hyperparameters, or replaced by cross-validation, which rotates through several splits when data are scarce.
  • Test set: held back and used once, after every choice has been made.

A common danger is data leakage: information from the test set slips into training. Examples are splitting a log randomly by second, although neighbouring seconds of one flight are almost identical, or fitting a scaler on all the data before splitting. Results then look better than they are. In drone work, split by flight, aircraft or site so the test set resembles a genuinely new situation, and when one class is rare keep its proportion in every set (stratify).

Underfitting and overfitting

Underfitting means the model is too simple and is wrong on both training and validation data. Overfitting means it memorises details and noise in the training set, scoring very well there but poorly on new data. The warning sign is a gap between training and validation scores that widens as the model grows more complex. Remedies include more data, a simpler model, regularisation and early stopping.

Evaluating for the task

A confusion matrix counts four outcomes: predicted faulty and truly faulty (TP), predicted faulty but healthy (FP), predicted healthy but faulty (FN), and predicted healthy and truly healthy (TN). From it:

  • Accuracy = (TP + TN) / total
  • Precision = TP / (TP + FP): of the alarms, how many were right
  • Recall = TP / (TP + FN): of the real faults, how many were caught
  • F1 = 2 × precision × recall / (precision + recall)

Safety tasks usually value recall, because missing a failing motor can cause a crash. But very low precision wastes technicians' time on false alarms until they stop trusting the system. Choosing the decision threshold is an engineering decision, not a software default.

Worked example: 96.6% accuracy that loses to guessing

Example: the imbalanced-data trap

A test set has 1,000 flights, 20 of them (2%) with a faulty motor. The model gives TP = 16, FN = 4, FP = 30 and TN = 950 (assumed data).

  1. Accuracy = (16 + 950) / 1,000 = 96.6%.
  2. Guessing "healthy" for every flight gives 980 / 1,000 = 98.0%, higher than the model, while catching no faults at all.
  3. Precision = 16 / (16 + 30) ≈ 0.348; recall = 16 / (16 + 4) = 0.80; F1 ≈ 0.485.

The model catches 80% of faulty motors, far more useful than guessing despite lower accuracy, but only about one alarm in three is real. The team must decide whether that re-inspection load is acceptable. With imbalanced data like this, always report precision, recall and the confusion matrix, and compare with a baseline.

Common pitfalls

  • Reporting only accuracy when one class is very rare.
  • Using the test set repeatedly to choose models, so it quietly becomes a validation set.
  • Splitting randomly by row when rows from one flight are correlated.
  • Having no baseline, such as guessing the majority class or the simple rule technicians already use.
  • Assuming results from synthetic or simulated data hold on real aircraft without testing again.

Continue in the lessons

Key references

  1. Géron, A. (2022). Hands-on machine learning with Scikit-Learn, Keras, and TensorFlow (3rd ed.). O'Reilly.
  2. Géron, A. (2025). Hands-on machine learning with Scikit-Learn and PyTorch. O'Reilly. link
  3. Goodfellow, I., Bengio, Y., & Courville, A. (2016). Deep learning. MIT Press. link
  4. scikit-learn developers. Cross-validation: Evaluating estimator performance (scikit-learn 1.9). link
  5. scikit-learn developers. Metrics and scoring: Quantifying the quality of predictions (scikit-learn 1.9). link

Used in courses

How to cite this page

Drone Institute, Rangsit University. (2026). พื้นฐานการเรียนรู้ของเครื่อง. In UAS Technology Knowledge Hub (B.Tech.). https://rsu-uat.pk-research.work/en/kb/new/ml-fundamentals/