Supervised Learning वह तकनीक है जिसमें मॉडल को ऐसे डेटा पर प्रशिक्षित किया जाता है जिसमें इनपुट के साथ-साथ सही आउटपुट (label) भी होता है।
उदाहरण:
Input (Features) | Output (Label) |
---|---|
उम्र = 30, वेतन = ₹40k | लोन स्वीकृत (Yes) |
अब हम ऐसे प्रमुख एल्गोरिद्म्स को समझेंगे जो Supervised Learning में सबसे ज़्यादा उपयोग होते हैं।
🔷 🔹 Why Supervised Algorithms?
Feature | Benefit |
---|---|
Input-output mapping defined | आसानी से train और evaluate किया जा सकता है |
Classification & Regression दोनों के लिए | बहुत versatile models उपलब्ध हैं |
Scalability | छोटे से बड़े डेटासेट तक लागू होता है |
🔶 Supervised Learning Algorithms के दो प्रमुख प्रकार:
प्रकार | उपयोग क्षेत्र | उदाहरण |
---|---|---|
Classification | Label पहचानना | Email Spam, Disease Detection |
Regression | Value predict करना | House Price, Stock Prediction |
🔷 1. Linear Regression (रेखीय प्रतिगमन)
📌 उपयोग:
Continuous Value Prediction
(जैसे घर की कीमत, तापमान)
🧮 फॉर्मूला:
y = w*x + b
✅ Python Example:
from sklearn.linear_model import LinearRegression
model = LinearRegression()
model.fit(X_train, y_train)
y_pred = model.predict(X_test)
🔷 2. Logistic Regression (तर्कशक्ति प्रतिगमन)
📌 उपयोग:
Binary Classification (Yes/No)
✅ Output:
Probability (0 to 1), फिर threshold लगाकर decision
from sklearn.linear_model import LogisticRegression
model = LogisticRegression()
model.fit(X_train, y_train)
y_pred = model.predict(X_test)
🔷 3. Decision Tree
📌 उपयोग:
Classification और Regression दोनों के लिए
डाटा को बार-बार विभाजित करके निर्णय लेना।
from sklearn.tree import DecisionTreeClassifier
model = DecisionTreeClassifier()
model.fit(X_train, y_train)
🔷 4. Random Forest
📌 क्या है?
Multiple Decision Trees का ensemble
Voting या averaging के ज़रिए output देता है।
from sklearn.ensemble import RandomForestClassifier
model = RandomForestClassifier(n_estimators=100)
model.fit(X_train, y_train)
🔷 5. Support Vector Machine (SVM)
📌 उपयोग:
High-dimensional datasets में classification के लिए बेहतरीन
from sklearn.svm import SVC
model = SVC(kernel='linear')
model.fit(X_train, y_train)
🔷 6. K-Nearest Neighbors (KNN)
📌 उपयोग:
Instance-based learning — training में कोई model नहीं, prediction के समय नज़दीकी K-पड़ोसियों को देखता है।
from sklearn.neighbors import KNeighborsClassifier
model = KNeighborsClassifier(n_neighbors=3)
model.fit(X_train, y_train)
🔷 7. Naive Bayes
📌 उपयोग:
Text classification जैसे spam detection
(Statistical probability आधारित)
from sklearn.naive_bayes import GaussianNB
model = GaussianNB()
model.fit(X_train, y_train)
📊 Summary Table:
Algorithm | Type | Strengths | Use Case |
---|---|---|---|
Linear Regression | Regression | Simple, fast | Price prediction |
Logistic Regression | Classification | Probabilistic output | Spam detection |
Decision Tree | Both | Interpretability | Credit approval |
Random Forest | Both | Accuracy, handles overfitting | Medical diagnosis |
SVM | Classification | Works in high dimensions | Face recognition |
KNN | Classification | No training, easy to implement | Pattern recognition |
Naive Bayes | Classification | Fast, good for text | Sentiment analysis |
📝 Practice Questions:
- Linear Regression और Logistic Regression में क्या अंतर है?
- Random Forest को Decision Tree से बेहतर क्यों माना जाता है?
- SVM किस तरह से Classification करता है?
- KNN में K का चुनाव कैसे किया जाता है?
- Naive Bayes कब अच्छा और कब बेकार perform करता है?