🟣 ML + AI · Lesson 59
Model Evaluation Metrics
Model Evaluation क्या है?
Model Evaluation ka matlab hai: Model evaluation checks how well a machine learning model performs on unseen data. Simple words me, ye topic practical Python programs likhne me direct use hota hai.
Is topic ko sirf definition ke liye nahi, balki checking model quality jaise real examples ke liye practice karein.
यह क्यों सीखना जरूरी है?
- Ye checking model quality me kaam aata hai.
- Ye comparing predictions with actual values se bhi connected hai.
- Isse aap code ka output aur errors better samajh paate hain.
Important Terms
| Term | Meaning |
|---|---|
| accuracy | Fraction of correct predictions. |
| precision | How many predicted positives were actually positive. |
| recall | How many actual positives were found by the model. |
| confusion matrix | Table comparing actual and predicted classes. |
| MAE | MAE is an important term in this topic. |
Syntax / Basic Pattern
Basic idea: pehle data तैयार करें, phir Python logic apply करें, aur finally result display करें.
Basic Pattern
from sklearn.metrics import accuracy_score, confusion_matrix
y_true = [1, 0, 1, 1, 0]
y_pred = [1, 0, 0, 1, 0]
print("Accuracy:", accuracy_score(y_true, y_pred))
print(confusion_matrix(y_true, y_pred))Complete Example Program
Python – model-evaluation.py
from sklearn.metrics import accuracy_score, confusion_matrix
y_true = [1, 0, 1, 1, 0]
y_pred = [1, 0, 0, 1, 0]
print("Accuracy:", accuracy_score(y_true, y_pred))
print(confusion_matrix(y_true, y_pred))Expected Output
Accuracy: 0.8
[[2 0]
[1 2]]
Program Explanation
from sklearn.metrics import accuracy_score, confusion_matriximports ready-made features from a module/library.y_true = [1, 0, 1, 1, 0]stores a value in y_true.y_pred = [1, 0, 0, 1, 0]stores a value in y_pred.print("Accuracy:", accuracy_score(y_true, y_pred))displays information or calculated result on the screen.print(confusion_matrix(y_true, y_pred))displays information or calculated result on the screen.
Practical Uses
- Checking model quality.
- Comparing predictions with actual values.
- Selecting a useful model.
Common Mistakes
- Training and testing the model on the same data.
- Using an algorithm without understanding the input features.
- Reporting only accuracy without checking actual mistakes and limitations.
Practice Tasks
- Program ko
model-evaluation.pyfile me type karke run karein. - Values change karke output compare karein.
- checking model quality par ek छोटा example banayen.
- Logic ko apne words me 5 lines me likhein.
सारांश
Model Evaluation ko tab complete maanenge jab aap iska meaning, example, output aur practical use clearly explain kar saken.
💻 लाइव कोड एडिटर
इस पेज के प्रोग्राम यहीं तैयार हैं — चलाएँ, बदलें और सीखें। कुछ भी इंस्टॉल किए बिना।
OneCompiler द्वारा संचालित। कोड एडिटर में अपने आप आ जाता है — Run दबाकर आउटपुट देखें। अगर एडिटर न खुले तो नए टैब में खोलें.