Keras: Introduction to Learning Curves for Diagnosing Model Performance

From OnnoWiki
Jump to navigation Jump to search

Sumber: https://machinelearningmastery.com/learning-curves-for-diagnosing-machine-learning-model-performance/

Learning Curve (Kurva Pembelajaran) adalah plot model kinerja belajar terhadap experience atau waktu.

Kurva pembelajaran adalah alat diagnostik yang banyak digunakan dalam machine learning untuk algoritma yang belajar dari set data training secara bertahap. Model dapat dievaluasi pada dataset training dan pada dataset validasi setelah setiap update selama training dan plot kinerja yang diukur dapat dibuat untuk menunjukkan kurva pembelajaran.Reviewing learning curves of models during training can be used to diagnose problems with learning, such as an underfit or overfit model, as well as whether the training and validation datasets are suitably representative.

Dalam tulisan ini, anda akan menemukan kurva pembelajaran dan bagaimana kurva tersebut dapat digunakan untuk mendiagnosis perilaku pembelajaran dan generalisasi model machine learning, dengan contoh plot yang menunjukkan masalah pembelajaran umum.

Sesudah membaca tulisan ini, anda akan mengetahui tentang:

  • Kurva pembelajaran adalah plot yang menunjukkan perubahan dalam kinerja pembelajaran dari waktu ke waktu dalam hal experience.
  • Kurva pembelajaran kinerja model pada dataset train dan dataset validasi dapat digunakan untuk mendiagnosis model apakah underfit, overfit, atau well-fit (cocok)..
  • Kurva pembelajaran kinerja model dapat digunakan untuk mendiagnosis apakah set data train atau validasi relatif tidak mewakili domain masalah.


Overview

Tutorial ini di bagi menjadi tiga (3) bagian, yaitu:

  • Kurva Pembelajaran (Learning Curve)
  • Mendiagnosa Perilaku Model (Diagnosing Model Behavior)
  • Mendiagnosa Dataset yang tidak representatif.

Kurva Pembejaran (Learning Curve) di Machine Learning

Umumnya, kurva belajar adalah plot yang menunjukkan waktu atau pengalaman (experience) pada sumbu x dan pembelajaran atau peningkatan pada sumbu y.


Learning curves (LCs) are deemed effective tools for monitoring the performance of workers exposed to a new task. LCs provide a mathematical representation of the learning process that takes place as task repetition occurs. — Learning curve models and applications: Literature review and research directions, 2011.


Misalnya, jika anda mempelajari alat musik, kemahiran anda pada instrumen tersebut dapat dievaluasi dan diberi skor numerik setiap minggu selama satu tahun. Plot skor selama 52 minggu adalah kurva belajar dan akan menunjukkan bagaimana pembelajaran Anda terhadap instrumen telah berubah seiring waktu.

  • Learning Curve: Line plot dari learning (y-axis) terhadap experience (x-axis).

Kurva pembelajaran banyak digunakan dalam machine learning untuk algoritma yang belajar (mengoptimalkan parameter internal mereka) secara bertahap, seperti deep learning neural network.

Metrik yang digunakan untuk mengevaluasi pembelajaran dapat dimaksimalkan, artinya skor yang lebih baik (angka yang lebih besar) menunjukkan lebih banyak pembelajaran. Contohnya adalah akurasi klasifikasi.

Lebih umum menggunakan skor yang diminimalkan, seperti loss atau error di mana skor yang lebih baik (angka lebih kecil) menunjukkan lebih banyak pembelajaran dan nilai 0,0 menunjukkan bahwa dataset training dipelajari dengan sempurna dan tidak ada error yang dibuat.

Selama training model machine learning, kondisi model saat ini pada setiap langkah algoritma training dapat dievaluasi. Hal ini dapat dievaluasi pada set data training untuk memberikan gambaran seberapa baik model tersebut “belajar.” Model ini juga dapat dievaluasi pada set data validasi yang bukan bagian dari set data training. Evaluasi pada dataset validasi memberikan gambaran tentang seberapa baik model tersebut untuk bisa “digeneralisasi.”

  • Train Learning Curve: Kurva pembelajaran dihitung dari dataset training yang memberikan gambaran seberapa baik model tersebut dipelajari.
  • Validation Learning Curve: Kurva pembelajaran dihitung dari set data validasi yang memberikan gambaran seberapa baik model tersebut digeneralisasi.

Adalah umum untuk membuat dua kurva belajar untuk model machine learning selama training baik pada data training maupun validasi.

Dalam beberapa kasus, juga umum untuk membuat kurva belajar untuk banyak metrik, seperti dalam kasus masalah pemodelan prediktif klasifikasi, di mana model dapat dioptimalkan sesuai dengan cross-entropy loss dan kinerja model dievaluasi menggunakan akurasi klasifikasi. Dalam hal ini, dua plot dibuat, satu untuk kurva belajar setiap metrik, dan setiap plot dapat menunjukkan dua kurva belajar, satu untuk masing-masing set data training dan validasi.

  • Optimization Learning Curves: Kurva pembelajaran dihitung pada metrik dimana parameter model dioptimalkan, mis. loss.
  • Performance Learning Curves: Kurva pembelajaran dihitung berdasarkan metrik yang digunakan model untuk dievaluasi dan dipilih, mis. accuracy.

Sekarang kita sudah terbiasa dengan penggunaan kurva belajar dalam machine learning, mari kita lihat beberapa bentuk umum yang diamati dalam plot pembelajaran kurva.

Diagnosa Perilaku Model

Bentuk dan dinamika kurva pembelajaran dapat digunakan untuk mendiagnosis perilaku model machine learning dan pada akhirnya mungkin menyarankan pada jenis perubahan konfigurasi yang dapat dilakukan untuk meningkatkan pembelajaran dan / atau kinerja.

Ada tiga dinamika umum yang cenderung anda amati dalam kurva pembelajaran, yaitu:

  • Underfit.
  • Overfit.
  • Good Fit.

Kita akan melihat lebih dekat masing-masing dengan contoh. Contoh-contoh akan mengasumsikan bahwa kita sedang melihat metrik meminimalkan, yang berarti bahwa skor relatif yang lebih kecil pada sumbu y menunjukkan pembelajaran yang lebih banyak atau lebih baik.

Underfit Learning Curves

Underfitting mengacu pada model yang tidak dapat mempelajari dataset training.


Underfitting occurs when the model is not able to obtain a sufficiently low error value on the training set. — Page 111, Deep Learning, 2016.


Model underfit dalam dapat diidentifikasi dari kurva belajar dari hanya training loss saja.

Ini mungkin menunjukkan garis datar atau nilai berisik dari loss yang relatif tinggi, menunjukkan bahwa model tidak dapat mempelajari set data training sama sekali.

Contoh dari ini disediakan di bawah ini dan umum ketika model tidak memiliki kapasitas yang sesuai untuk kompleksitas dataset.

Example-of-Training-Learning-Curve-Showing-An-Underfit-Model-That-Does-Not-Have-Sufficient-Capacity.png


Model underfit dalam juga dapat diidentifikasi dengan training loss yang menurun dan terus menurun pada akhir plot.

Ini menunjukkan bahwa model ini mampu belajar lebih lanjut dan kemungkinan peningkatan lebih lanjut dan bahwa proses pelatihan dihentikan sebelum waktunya.

Example-of-Training-Learning-Curve-Showing-An-Underfit-Model-That-Requires-Further-Training.png

Plot learning curves menunjukan underfitting jika:

  • Training loss tetap datar walaupun telah melalui proses training.
  • Training loss terus menurun hingga akhir training.

Overfit Learning Curves

Overfitting refers to a model that has learned the training dataset too well, including the statistical noise or random fluctuations in the training dataset.


… fitting a more flexible model requires estimating a greater number of parameters. These more complex models can lead to a phenomenon known as overfitting the data, which essentially means they follow the errors, or noise, too closely. — Page 22, An Introduction to Statistical Learning: with Applications in R, 2013.


The problem with overfitting, is that the more specialized the model becomes to training data, the less well it is able to generalize to new data, resulting in an increase in generalization error. This increase in generalization error can be measured by the performance of the model on the validation dataset.


This is an example of overfitting the data, […]. It is an undesirable situation because the fit obtained will not yield accurate estimates of the response on new observations that were not part of the original training data set. — Page 24, An Introduction to Statistical Learning: with Applications in R, 2013.


This often occurs if the model has more capacity than is required for the problem, and, in turn, too much flexibility. It can also occur if the model is trained for too long.

A plot of learning curves shows overfitting if:

  • The plot of training loss continues to decrease with experience.
  • The plot of validation loss decreases to a point and begins increasing again.

The inflection point in validation loss may be the point at which training could be halted as experience after that point shows the dynamics of overfitting.

The example plot below demonstrates a case of overfitting.


Example-of-Train-and-Validation-Learning-Curves-Showing-An-Overfit-Model.png

Good Fit Learning Curves

A good fit is the goal of the learning algorithm and exists between an overfit and underfit model.

A good fit is identified by a training and validation loss that decreases to a point of stability with a minimal gap between the two final loss values.

The loss of the model will almost always be lower on the training dataset than the validation dataset. This means that we should expect some gap between the train and validation loss learning curves. This gap is referred to as the “generalization gap.”

A plot of learning curves shows a good fit if:

  • The plot of training loss decreases to a point of stability.
  • The plot of validation loss decreases to a point of stability and has a small gap with the training loss.

Continued training of a good fit will likely lead to an overfit.

The example plot below demonstrates a case of a good fit.

Example-of-Train-and-Validation-Learning-Curves-Showing-A-Good-Fit.png

Diagnosing Unrepresentative Datasets

Learning curves can also be used to diagnose properties of a dataset and whether it is relatively representative.

An unrepresentative dataset means a dataset that may not capture the statistical characteristics relative to another dataset drawn from the same domain, such as between a train and a validation dataset. This can commonly occur if the number of samples in a dataset is too small, relative to another dataset.

There are two common cases that could be observed; they are:

  • Training dataset is relatively unrepresentative.
  • Validation dataset is relatively unrepresentative.

Unrepresentative Train Dataset

An unrepresentative training dataset means that the training dataset does not provide sufficient information to learn the problem, relative to the validation dataset used to evaluate it.

This may occur if the training dataset has too few examples as compared to the validation dataset.

This situation can be identified by a learning curve for training loss that shows improvement and similarly a learning curve for validation loss that shows improvement, but a large gap remains between both curves.


Example-of-Train-and-Validation-Learning-Curves-Showing-a-Training-Dataset-the-May-be-too-Small-Relative-to-the-Validation-Dataset.png

Unrepresentative Validation Dataset

An unrepresentative validation dataset means that the validation dataset does not provide sufficient information to evaluate the ability of the model to generalize.

This may occur if the validation dataset has too few examples as compared to the training dataset.

This case can be identified by a learning curve for training loss that looks like a good fit (or other fits) and a learning curve for validation loss that shows noisy movements around the training loss.


Example-of-Train-and-Validation-Learning-Curves-Showing-a-Validation-Dataset-the-May-be-too-Small-Relative-to-the-Training-Dataset.png


It may also be identified by a validation loss that is lower than the training loss. In this case, it indicates that the validation dataset may be easier for the model to predict than the training dataset.


Example-of-Train-and-Validation-Learning-Curves-Showing-a-Validation-Dataset-that-is-Easier-to-Predict-than-the-Training-Dataset.png

Further Reading

This section provides more resources on the topic if you are looking to go deeper. Books

   Deep Learning, 2016.
   An Introduction to Statistical Learning: with Applications in R, 2013.

Papers

   Learning curve models and applications: Literature review and research directions, 2011.

Posts

   How to Diagnose Overfitting and Underfitting of LSTM Models
   Overfitting and Underfitting With Machine Learning Algorithms

Articles

   Learning curve, Wikipedia.
   Overfitting, Wikipedia.

Summary

In this post, you discovered learning curves and how they can be used to diagnose the learning and generalization behavior of machine learning models.

Specifically, you learned:

  • Learning curves are plots that show changes in learning performance over time in terms of experience.
  • Learning curves of model performance on the train and validation datasets can be used to diagnose an underfit, overfit, or well-fit model.
  • Learning curves of model performance can be used to diagnose whether the train or validation datasets are not relatively representative of the problem domain.




Referensi


Pranala Menarik