Model Pipeline - Model selection for tasks
This pipeline helps choose the best model for a specific NLP task by comparing different models' performance on the same data.
This pipeline helps choose the best model for a specific NLP task by comparing different models' performance on the same data.
Loss: 0.65 |**** Loss: 0.50 |****** Loss: 0.40 |******** Loss: 0.35 |********* Loss: 0.30 |**********
| Epoch | Loss ↓ | Accuracy ↑ | Observation |
|---|---|---|---|
| 1 | 0.65 | 0.60 | Model starts learning with moderate accuracy |
| 2 | 0.50 | 0.75 | Loss decreases and accuracy improves |
| 3 | 0.40 | 0.82 | Model continues to improve |
| 4 | 0.35 | 0.86 | Training converging with good accuracy |
| 5 | 0.30 | 0.89 | Final epoch with best performance |
from sklearn.feature_extraction.text import CountVectorizer from sklearn.linear_model import LogisticRegression from sklearn.model_selection import train_test_split texts = ['I love this movie', 'This movie is bad', 'Amazing film', 'Terrible acting', 'Great plot', 'Worst movie ever'] labels = [1, 0, 1, 0, 1, 0] X_train, X_test, y_train, y_test = train_test_split(texts, labels, test_size=0.33, random_state=42) vectorizer = CountVectorizer() X_train_vec = vectorizer.fit_transform(X_train) X_test_vec = vectorizer.transform(X_test) model = LogisticRegression() model.fit(X_train_vec, y_train) accuracy = model.score(X_test_vec, y_test) print(round(accuracy, 2))
ValueError: Found input variables with inconsistent numbers of samples. What is the most likely cause?Pass the test and this pattern moves unknown