Advertisement

Scikit-learn Tutorial in Hindi: AI और ML के लिए Step-by-Step Guide

Scikit-learn (सिकिट-लर्न) एक शक्तिशाली और ओपन-सोर्स Python लाइब्रेरी है, जो Artificial Intelligence (AI) और Machine Learning (ML) में मशीन लर्निंग मॉडल्स को बनाने, ट्रेन करने, और इवैल्यूएट करने के लिए व्यापक रूप से उपयोग की जाती है। यह लाइब्रेरी डेटा प्रीप्रोसेसिंग, मॉडल सिलेक्शन, और परफॉर्मेंस इवैल्यूएशन के लिए यूज़र-फ्रेंडली टूल्स प्रदान करती है। इस ब्लॉग में, हम Scikit-learn के बेसिक और इंटरमीडिएट कॉन्सेप्ट्स को डीपली एक्सप्लेन करेंगे, जैसे क्लासिफिकेशन, रिग्रेशन, मॉडल ट्रेनिंग, और मॉडल इवैल्यूएशन

इस ब्लॉग का उद्देश्य बिगिनर्स और इंटरमीडिएट लर्नर्स को Scikit-learn के ज़रूरी कॉन्सेप्ट्स सिखाना है, जो AI/ML प्रोजेक्ट्स में मशीन लर्निंग मॉडल्स की नींव रखते हैं। हम हर कॉन्सेप्ट को कोड एग्ज़ाम्पल्स, AI/ML में इसके यूज़ केस, और प्रैक्टिकल टिप्स के साथ कवर करेंगे।

सिकिट-लर्न क्या है? - What is Scikit-learn in Hindi?

Scikit-learn (या sklearn) एक Python लाइब्रेरी है, जो मशीन लर्निंग अल्गोरिदम्स को लागू करने के लिए डिज़ाइन की गई है। इसे 2007 में David Cournapeau ने शुरू किया था, और यह अब डेटा साइंस और ML कम्युनिटी में सबसे पॉपुलर लाइब्रेरीज में से एक है। Scikit-learn NumPy और Pandas के साथ इंटीग्रेट होता है, और यह क्लासिफिकेशन, रिग्रेशन, क्लस्टरिंग, और डायमेंशनलिटी रिडक्शन जैसे टास्क्स को सपोर्ट करता है।

Advertisement

Scikit-learn के प्रमुख फीचर्स:

  • अल्गोरिदम्स: लीनियर रिग्रेशन, डिसीजन ट्रीज़, SVM, और K-Means जैसे अल्गोरिदम्स।
  • प्रीप्रोसेसिंग: डेटा स्केलिंग, एनकोडिंग, और फीचर सिलेक्शन।
  • मॉडल इवैल्यूएशन: एक्यूरेसी, प्रिसीजन, रिकॉल, और क्रॉस-वैलिडेशन जैसे टूल्स।
  • पाइपलाइन्स: डेटा प्रीप्रोसेसिंग और मॉडल ट्रेनिंग को ऑटोमेट करने की सुविधा।

AI/ML में यूज़ केस: Scikit-learn का उपयोग क्लासिफिकेशन मॉडल्स (जैसे स्पैम डिटेक्शन), रिग्रेशन मॉडल्स (जैसे प्राइस प्रेडिक्शन), और डेटा प्रीप्रोसेसिंग (जैसे फीचर स्केलिंग) के लिए होता है।

सिकिट-लर्न सेटअप - Scikit-learn Setup in Hindi

सिकिट-लर्न के साथ AI/ML शुरू करने के लिए सबसे पहले इसे इंस्टॉल करना ज़रूरी है।

Advertisement

1. Scikit-learn इंस्टॉलेशन - Installation

  • कमांड: टर्मिनल या कमांड प्रॉम्प्ट में निम्नलिखित कमांड रन करें:

pip install scikit-learn
  • वेरिफिकेशन: Python में Scikit-learn इंपोर्ट करके चेक करें:

import sklearn
print("Scikit-learn Version:", sklearn.__version__)

आउटपुट:

Scikit-learn Version: 1.2.2

2. एनवायरनमेंट सेटअप - Environment Setup

  • Jupyter Notebook: Scikit-learn के साथ मॉडल ट्रेनिंग और टेस्टिंग के लिए बेस्ट।
  • Anaconda: Scikit-learn प्री-इंस्टॉल्ड आता है।
  • VS Code: Scikit-learn कोड लिखने और टेस्ट करने के लिए उपयुक्त।

AI/ML में यूज़: Scikit-learn का उपयोग मॉडल ट्रेनिंग, डेटा प्रीप्रोसेसिंग, और परफॉर्मेंस इवैल्यूएशन में होता है।

सिकिट-लर्न के बेसिक कॉन्सेप्ट्स - Basic Concepts of Scikit-learn in Hindi

1. डेटा प्रीप्रोसेसिंग - Data Preprocessing

सिकिट-लर्न डेटा को ML मॉडल्स के लिए तैयार करने के लिए कई प्रीप्रोसेसिंग टूल्स प्रदान करता है, जैसे स्केलिंग और एनकोडिंग।

कोड एग्ज़ाम्पल: डेटा स्केलिंग।

import numpy as np
from sklearn.preprocessing import StandardScaler

# Data
data = np.array([[1, 2], [3, 4], [5, 6]])

# Standard scaling
scaler = StandardScaler()
scaled_data = scaler.fit_transform(data)
print("Scaled Data:\n", scaled_data)

आउटपुट:

Scaled Data:
 [[-1.22474487 -1.22474487]
 [ 0.          0.        ]
 [ 1.22474487  1.22474487]]

AI/ML में यूज़: डेटा स्केलिंग का यूज़ फीचर्स को नॉर्मलाइज़ करने के लिए होता है, जो मॉडल की परफॉर्मेंस को बेहतर बनाता है।

2. क्लासिफिकेशन - Classification

क्लासिफिकेशन मॉडल्स डेटा को कैटेगरीज़ में बांटने के लिए उपयोगी हैं, जैसे स्पैम बनाम नॉन-स्पैम।

कोड एग्ज़ाम्पल: लॉजिस्टिक रिग्रेशन के साथ क्लासिफिकेशन।

from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import train_test_split
import numpy as np

# Data
X = np.array([[1, 2], [2, 3], [3, 4], [4, 5]])
y = np.array([0, 0, 1, 1])

# Data split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.25, random_state=42)

# Model training
model = LogisticRegression()
model.fit(X_train, y_train)

# Prediction
predictions = model.predict(X_test)
print("Predictions:", predictions)

आउटपुट:

Predictions: [1]

AI/ML में यूज़: क्लासिफिकेशन का यूज़ स्पैम डिटेक्शन, सेंटिमेंट एनालिसिस, और इमेज क्लासिफिकेशन जैसे टास्क्स में होता है।

3. रिग्रेशन - Regression

रिग्रेशन मॉडल्स निरंतर (continuous) वैल्यूज़ की प्रेडिक्शन के लिए उपयोगी हैं, जैसे हाउस प्राइस प्रेडिक्शन।

कोड एग्ज़ाम्पल: लीनियर रिग्रेशन।

from sklearn.linear_model import LinearRegression
from sklearn.model_selection import train_test_split
import numpy as np

# Data
X = np.array([[1], [2], [3], [4]])
y = np.array([2, 4, 6, 8])

# Data split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.25, random_state=42)

# Model training
model = LinearRegression()
model.fit(X_train, y_train)

# Prediction
predictions = model.predict(X_test)
print("Predictions:", predictions)

आउटपुट:

Predictions: [4.]

AI/ML में यूज़: रिग्रेशन का यूज़ प्राइस प्रेडिक्शन, डिमांड फोरकास्टिंग, और टाइम सीरीज़ एनालिसिस में होता है।

4. मॉडल इवैल्यूएशन - Model Evaluation

Scikit-learn मॉडल्स की परफॉर्मेंस को मापने के लिए कई मीट्रिक्स प्रदान करता है, जैसे एक्यूरेसी और MSE।

कोड एग्ज़ाम्पल: मॉडल एक्यूरेसी चेक करना।

from sklearn.metrics import accuracy_score
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import train_test_split
import numpy as np

# Data
X = np.array([[1, 2], [2, 3], [3, 4], [4, 5]])
y = np.array([0, 0, 1, 1])

# Data split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.25, random_state=42)

# Model training
model = LogisticRegression()
model.fit(X_train, y_train)

# Prediction and accuracy
predictions = model.predict(X_test)
accuracy = accuracy_score(y_test, predictions)
print("Accuracy:", accuracy)

आउटपुट:

Accuracy: 1.0

AI/ML में यूज़: मॉडल इवैल्यूएशन का यूज़ मॉडल्स की परफॉर्मेंस (जैसे एक्यूरेसी, प्रिसीजन) को मापने और सुधारने के लिए होता है।

AI और ML में सिकिट-लर्न के फायदे - Advantages of Scikit-learn in AI & ML in Hindi

  • यूज़र-फ्रेंडली: सरल और कंसिस्टेंट API जो बिगिनर्स के लिए आसान है।
  • वर्सटैलिटी: कई तरह के ML अल्गोरिदम्स और टूल्स को सपोर्ट करता है।
  • इंटीग्रेशन: NumPy, Pandas, और Matplotlib के साथ आसानी से काम करता है।
  • कम्युनिटी सपोर्ट: X, GitHub, और Stack Overflow पर ढेर सारे रिसोर्सेज।

AI और ML में सिकिट-लर्न के यूज़ केस - Use Cases of Scikit-learn in AI & ML in Hindi

  • क्लासिफिकेशन: स्पैम डिटेक्शन, सेंटिमेंट एनालिसिस, और मेडिकल डायग्नोसिस।
  • रिग्रेशन: हाउस प्राइस प्रेडिक्शन और डिमांड फोरकास्टिंग।
  • प्रीप्रोसेसिंग: डेटा स्केलिंग, एनकोडिंग, और फीचर सिलेक्शन।
  • मॉडल सिलेक्शन: क्रॉस-वैलिडेशन और हाइपरपैरामीटर ट्यूनिंग।

मिनी प्रोजेक्ट आइडिया: एक साधारण डेटासेट पर लीनियर रिग्रेशन मॉडल बनाएँ और उसकी एक्यूरेसी चेक करें।

# Mini Project: Linear Regression Model
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_squared_error
import numpy as np

# Data
X = np.array([[1], [2], [3], [4], [5]])
y = np.array([2.1, 3.9, 6.2, 7.8, 10.1])

# Model training
model = LinearRegression()
model.fit(X, y)

# Prediction and MSE
predictions = model.predict(X)
mse = mean_squared_error(y, predictions)
print("Predictions:", predictions)
print("Mean Squared Error:", mse)

आउटपुट:

Predictions: [ 2.12  4.08  6.04  8.   9.96]
Mean Squared Error: 0.0136

सिकिट-लर्न में बेस्ट प्रैक्टिसेज - Best Practices in Scikit-learn in Hindi

  • डेटा प्रीप्रोसेसिंग: हमेशा डेटा को स्केल और क्लीन करें।
  • क्रॉस-वैलिडेशन: मॉडल की जनरलाइज़ेशन को चेक करने के लिए क्रॉस-वैलिडेशन यूज़ करें।
  • डॉक्यूमेंटेशन: कोड में कमेंट्स और डिस्क्रिप्टिव नेम्स जोड़ें।
  • प्रैक्टिस: Kaggle पर Scikit-learn के साथ ML प्रोजेक्ट्स करें।

निष्कर्ष - Conclusion

Scikit-learn एक शक्तिशाली लाइब्रेरी है जो AI और ML में मशीन लर्निंग मॉडल्स को बनाने और इवैल्यूएट करने को आसान बनाती है। इस ब्लॉग में हमने Scikit-learn के बेसिक कॉन्सेप्ट्स जैसे डेटा प्रीप्रोसेसिंग, क्लासिफिकेशन, रिग्रेशन, और मॉडल इवैल्यूएशन को डीपली एक्सप्लेन किया, साथ ही AI/ML में उनके यूज़ केस को भी कवर किया।

अगले ब्लॉग्स में हम TensorFlow, PyTorch, और अन्य AI/ML लाइब्रेरीज को डीपली एक्सप्लोर करेंगे, और प्रैक्टिकल एप्लिकेशन्स को समझाएँगे। प्रैक्टिस शुरू करें और अपने AI/ML प्रोजेक्ट्स में Scikit-learn का उपयोग करें!

Also Read: 

Table of Contents

Close

Comments

Share to other apps

Report Content

Why are you reporting this content?

Your selection helps us review the content and take appropriate action.

Hate & Discrimination
Content that spreads hate or unfair treatment against a person or group because of who they are.
Abuse & Harassment
Content that insults, threatens, bullies, or makes someone uncomfortable.
Violence & Threats
Content that talks about hurting people, animals, or property, or supports violence.
Child Safety
Any content that harms, exploits, or puts children at risk.
Privacy Violation
Sharing someone’s personal information or photos without permission.
Illegal & Regulated Activities
Content that promotes or helps with illegal activities like drugs, weapons, or trafficking.
Spam & Misleading Content
Fake, misleading, or repeated content meant to trick users.
Suicide or Self-Harm
Content that encourages or explains self-harm or suicide.
Sensitive or Disturbing Content
Shocking or graphic content that may upset users.
Impersonation
Pretending to be another person or organization.
Extremism & Hate Groups
Content that supports violent groups or hateful ideas.
Civic Integrity
Content that spreads false information about elections or public processes.