Model Pipeline - Generative vs discriminative models
This pipeline compares two types of models: generative models that learn how data is made, and discriminative models that learn to tell categories apart.
Jump into concepts and practice - no test required
This pipeline compares two types of models: generative models that learn how data is made, and discriminative models that learn to tell categories apart.
Loss
0.7 |*
0.6 | **
0.5 | ***
0.4 | ****
0.3 | *****
+---------
1 2 3 4 5 Epochs| Epoch | Loss ↓ | Accuracy ↑ | Observation |
|---|---|---|---|
| 1 | 0.65 | 0.60 | Both models start with moderate loss and accuracy. |
| 2 | 0.50 | 0.72 | Loss decreases and accuracy improves as models learn. |
| 3 | 0.40 | 0.80 | Clear improvement; discriminative model may learn faster. |
| 4 | 0.35 | 0.85 | Loss continues to decrease; accuracy rises steadily. |
| 5 | 0.30 | 0.88 | Models converge with good accuracy. |
from sklearn.naive_bayes import GaussianNB from sklearn.linear_model import LogisticRegression X_train = [[1, 2], [2, 3], [3, 4], [4, 5]] y_train = [0, 0, 1, 1] model = GaussianNB() model.fit(X_train, y_train) predictions = model.predict([[2, 3]]) print(predictions)
from sklearn.linear_model import LogisticRegression X_train = [[1, 2], [2, 3], [3, 4]] y_train = [0, 1] model = LogisticRegression() model.fit(X_train, y_train)