An AI model is a program that learns from data and makes predictions.
Training data โ Learning โ Predictions
Model Components
# Dataset
dataset = [
{"input": "Great product!", "output": "positive"},
{"input": "Terrible quality", "output": "negative"},
{"input": "Nothing special", "output": "neutral"},
]
# Training
model.train(dataset)
# Prediction
label = model.predict("Awesome item!") # "positive"
Key Metrics
Accuracy โ percentage of correct answers:
accuracy = correct / total # 85 / 100 = 0.85 โ 85%
Loss โ average error:
loss = sum(abs(pred - real) for pred, real in zip(preds, actuals)) / len(preds)
Dataset size and expected accuracy:
| Size | Expected accuracy |
|------|------------------|
| < 1,000 | ~65% |
| 1,000โ5,000 | ~80% |
| 5,000โ10,000 | ~90% |
| > 10,000 | ~95%+ |
Model Types
| Type | Task | Example |
|---|---|---|
| Classification | Assign a category | Spam / not spam |
| Regression | Predict a number | House price |
| Generation | Create content | Text, code, image |
Overfitting vs Underfitting
def check_fit(train_acc, test_acc):
if train_acc < 0.7 and test_acc < 0.7:
return "Underfitting โ model is weak, needs more data"
if train_acc > 0.9 and test_acc < 0.7:
return "Overfitting โ model memorized data, needs regularization"
return "Good Fit"
check_fit(0.95, 0.60) # Overfitting
check_fit(0.65, 0.63) # Underfitting
check_fit(0.88, 0.85) # Good Fit
Lifecycle
1. Collect data โ gather / label examples
2. Train โ model.fit(X_train, y_train)
3. Evaluate โ model.evaluate(X_test, y_test)
4. Improve โ more data / hyperparameter tuning
5. Deploy โ API / service for users
Practical Tips
- Split dataset: 80% train / 20% test
- Track both metrics: high train acc + low test acc = overfitting
- Start simple: baseline model โ evaluate โ improve
- Quality over quantity: 1,000 clean examples beat 10,000 noisy ones
๐ฌ Comments (0)
No comments yet
Be the first to share your opinion about this article!