Machine Learning Basics Notes (English + Simple Hindi)

Complete beginner's guide to ML concepts – click a topic to jump

Topics of Machine Learning

1. Introduction to Machine Learning / मशीन लर्निंग का परिचय

English

What is Machine Learning? Machine Learning (ML) is a subset of artificial intelligence (AI) that enables systems to learn and improve from experience without being explicitly programmed. ML algorithms build mathematical models based on training data to make predictions or decisions.

Why ML? It helps in finding patterns in large datasets, making predictions, automating tasks, and continuously improving performance.

सरल हिंदी

मशीन लर्निंग क्या है? यह AI का एक भाग है, जिसमें सिस्टम बिना स्पष्ट प्रोग्रामिंग के डेटा से सीखता है और अनुभव से बेहतर होता है। ML एल्गोरिदम ट्रेनिंग डेटा के आधार पर मॉडल बनाते हैं ताकि भविष्यवाणी या निर्णय किए जा सकें।

# Simple ML pipeline: Data -> Train Model -> Evaluate -> Predict
↑ Back to Top

2. Types of Machine Learning / मशीन लर्निंग के प्रकार

English

  • Supervised Learning: Model learns from labeled data (input-output pairs). Used for regression (predict continuous values) and classification (predict categories).
  • Unsupervised Learning: Model finds patterns in unlabeled data. Used for clustering (grouping similar items) and dimensionality reduction.
  • Reinforcement Learning: Agent learns by interacting with environment, receiving rewards/penalties. Used in game playing, robotics.

सरल हिंदी

  • सुपरवाइज्ड लर्निंग: लेबल वाले डेटा से सीखना (जैसे फल की तस्वीर और उसका नाम)। रिग्रेशन (संख्यात्मक मान) और क्लासिफिकेशन (श्रेणी) इसमें आते हैं।
  • अनसुपरवाइज्ड लर्निंग: बिना लेबल वाले डेटा में पैटर्न ढूँढ़ना, जैसे ग्राहकों को समूहों में बाँटना।
  • रिइन्फोर्समेंट लर्निंग: एजेंट पर्यावरण से बातचीत करके सीखता है, इनाम/दंड से।
# Example: Supervised learning with scikit-learn
from sklearn.ensemble import RandomForestClassifier
model = RandomForestClassifier()
model.fit(X_train, y_train)
↑ Back to Top

3. Key Terminology / महत्वपूर्ण शब्दावली

English

  • Features (X): Input variables used for prediction.
  • Labels (y): Target/output variable.
  • Training set: Data used to train the model.
  • Test set: Data used to evaluate model performance.
  • Model: Mathematical representation learned from data.
  • Algorithm: Method to learn the model.

सरल हिंदी

  • फीचर (X): इनपुट वेरिएबल, जिसके आधार पर भविष्यवाणी करते हैं।
  • लेबल (y): हमें जो अनुमान लगाना है।
  • ट्रेनिंग सेट: जिस डेटा से मॉडल सीखता है।
  • टेस्ट सेट: मॉडल का मूल्यांकन करने के लिए अलग डेटा।
# Typical ML code structure
X = dataset[['feature1', 'feature2']]
y = dataset['target']
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)
↑ Back to Top

4. Data Preprocessing / डेटा तैयार करना

English

Raw data often needs cleaning and transformation: handling missing values, scaling/normalization, encoding categorical variables, feature selection. Common libraries: pandas, numpy, scikit-learn.

सरल हिंदी

कच्चे डेटा को साफ करना जरूरी है: लापता मान भरना, फीचर्स को एक पैमाने पर लाना, श्रेणियों (categories) को संख्याओं में बदलना आदि।

import pandas as pd
from sklearn.preprocessing import StandardScaler, LabelEncoder

# Handle missing values
df.fillna(df.mean(), inplace=True)

# Encode categorical
le = LabelEncoder()
df['gender'] = le.fit_transform(df['gender'])

# Scale features
scaler = StandardScaler()
X_scaled = scaler.fit_transform(X)
↑ Back to Top

5. Linear Regression / लीनियर रिग्रेशन

English

Linear regression models the relationship between a dependent variable (y) and one or more independent variables (X) by fitting a linear equation: y = β0 + β1x1 + ... + βnxn + ε. Used for predicting continuous values (e.g., house prices).

सरल हिंदी

लीनियर रिग्रेशन दो या अधिक चरों के बीच रैखिक संबंध स्थापित करता है। इसका उपयोग निरंतर मान (जैसे घर की कीमत) का अनुमान लगाने में होता है।

from sklearn.linear_model import LinearRegression

model = LinearRegression()
model.fit(X_train, y_train)
y_pred = model.predict(X_test)

print("Coefficients:", model.coef_)
↑ Back to Top

6. Classification / क्लासिफिकेशन

English

Classification predicts a categorical label. Examples: spam detection, image recognition. Evaluation metrics: accuracy, precision, recall, F1-score, ROC-AUC.

सरल हिंदी

क्लासिफिकेशन में श्रेणी का अनुमान लगाया जाता है (जैसे ईमेल स्पैम है या नहीं)। सटीकता, प्रेसिजन, रिकॉल आदि से मॉडल का मूल्यांकन करते हैं।

from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import accuracy_score

clf = RandomForestClassifier()
clf.fit(X_train, y_train)
y_pred = clf.predict(X_test)
print("Accuracy:", accuracy_score(y_test, y_pred))
↑ Back to Top

7. Logistic Regression / लॉजिस्टिक रिग्रेशन

English

Despite its name, logistic regression is used for binary classification. It models the probability that an instance belongs to a particular class using the logistic (sigmoid) function. Output is between 0 and 1.

सरल हिंदी

लॉजिस्टिक रिग्रेशन दो श्रेणियों (binary) में वर्गीकरण के लिए प्रयोग होता है। यह सिग्मॉइड फंक्शन की मदद से प्रायिकता (0 से 1) देता है।

from sklearn.linear_model import LogisticRegression

logreg = LogisticRegression()
logreg.fit(X_train, y_train)
y_prob = logreg.predict_proba(X_test)  # probabilities
↑ Back to Top

8. Decision Trees / डिसीजन ट्री

English

Decision trees are flowchart-like structures where each internal node tests a feature, each branch represents outcome, and each leaf holds a class label or value. Easy to interpret, prone to overfitting.

सरल हिंदी

डिसीजन ट्री एक फैसले का पेड़ होता है – हर नोड पर एक शर्त, और हर पत्ती पर परिणाम। इसे समझना आसान है, लेकिन यह ओवरफिटिंग का शिकार हो सकता है।

from sklearn.tree import DecisionTreeClassifier

dt = DecisionTreeClassifier(max_depth=5)
dt.fit(X_train, y_train)
↑ Back to Top

9. k-Nearest Neighbors (k-NN) / के-नियरेस्ट नेबर्स

English

k-NN is a simple, instance-based learning algorithm. It classifies a point based on majority vote of its k nearest neighbors in feature space. No explicit training; all computation happens during prediction.

सरल हिंदी

k-NN में नए डेटा बिंदु को उसके k निकटतम पड़ोसियों के बहुमत से वर्गीकृत किया जाता है। यह इंस्टेंस-बेस्ड लर्निंग है, ट्रेनिंग के दौरान कुछ नहीं सीखता।

from sklearn.neighbors import KNeighborsClassifier

knn = KNeighborsClassifier(n_neighbors=3)
knn.fit(X_train, y_train)
↑ Back to Top

10. Clustering (k-Means) / क्लस्टरिंग

English

k-Means is an unsupervised learning algorithm that partitions data into k clusters. Each point belongs to the cluster with the nearest mean. Used for customer segmentation, image compression, etc.

सरल हिंदी

k-Means बिना लेबल वाले डेटा को k समूहों में बाँटता है। हर बिंदु उस समूह में जाता है जिसके केंद्र के सबसे पास होता है। ग्राहक वर्गीकरण, छवि संपीड़न आदि में उपयोग।

from sklearn.cluster import KMeans

kmeans = KMeans(n_clusters=3, random_state=42)
kmeans.fit(X)
labels = kmeans.labels_
centers = kmeans.cluster_centers_
↑ Back to Top

11. Model Evaluation / मॉडल मूल्यांकन

English

Regression metrics: Mean Absolute Error (MAE), Mean Squared Error (MSE), R-squared.

Classification metrics: Accuracy, Precision, Recall, F1-score, Confusion Matrix, ROC curve.

Always evaluate on a separate test set or using cross-validation.

सरल हिंदी

रिग्रेशन के लिए MAE, MSE, R-squared। क्लासिफिकेशन के लिए सटीकता, प्रेसिजन, रिकॉल, F1, कन्फ्यूजन मैट्रिक्स। हमेशा टेस्ट सेट या क्रॉस-वैलिडेशन से मूल्यांकन करें।

from sklearn.metrics import classification_report, confusion_matrix

print(confusion_matrix(y_test, y_pred))
print(classification_report(y_test, y_pred))
↑ Back to Top

12. Overfitting and Underfitting / ओवरफिटिंग और अंडरफिटिंग

English

Overfitting: Model learns training data too well, including noise, and performs poorly on new data. (high variance)

Underfitting: Model is too simple and fails to capture patterns in training data. (high bias)

Solutions: cross-validation, regularization, more data, simpler/complex models.

सरल हिंदी

Overfitting: मॉडल ट्रेनिंग डेटा को बहुत अच्छे से सीख लेता है, लेकिन नए डेटा पर खराब प्रदर्शन करता है।

Underfitting: मॉडल बहुत सरल है, पैटर्न नहीं सीख पाता।

# Regularization example (Ridge/Lasso)
from sklearn.linear_model import Ridge

ridge = Ridge(alpha=1.0)
ridge.fit(X_train, y_train)
↑ Back to Top

13. Bias-Variance Tradeoff / बायस-वैरियंस ट्रेडऑफ

English

Bias: Error due to wrong assumptions (underfitting). Variance: Error due to sensitivity to fluctuations in training data (overfitting). The tradeoff is finding the optimal model complexity to minimize total error.

सरल हिंदी

Bias: गलत धारणाओं से उत्पन्न त्रुटि (अंडरफिटिंग)। Variance: ट्रेनिंग डेटा में बदलाव से उत्पन्न त्रुटि (ओवरफिटिंग)। सही संतुलन बनाना होता है।

# Visualizing with learning curves (example)
from sklearn.model_selection import learning_curve
↑ Back to Top

14. Feature Engineering / फीचर इंजीनियरिंग

English

Creating new features from existing data to improve model performance. Includes: polynomial features, interaction terms, binning, domain-specific features, feature selection techniques (PCA, feature importance).

सरल हिंदी

मौजूदा डेटा से नए फीचर बनाना ताकि मॉडल बेहतर हो। जैसे दो फीचर का गुणा, पॉलिनोमियल फीचर, डोमेन ज्ञान से नए फीचर।

from sklearn.preprocessing import PolynomialFeatures

poly = PolynomialFeatures(degree=2, include_bias=False)
X_poly = poly.fit_transform(X)
↑ Back to Top

15. Neural Networks Introduction / न्यूरल नेटवर्क का परिचय

English

Neural networks are inspired by the human brain. They consist of layers of interconnected neurons (nodes). Each connection has a weight. Activation functions (ReLU, sigmoid) introduce non-linearity. Simple feedforward networks can learn complex patterns.

सरल हिंदी

न्यूरल नेटवर्क मानव मस्तिष्क से प्रेरित हैं। इनमें परतों में न्यूरॉन्स होते हैं, हर कनेक्शन का वज़न होता है। एक्टिवेशन फंक्शन (ReLU, sigmoid) गैर-रैखिकता लाते हैं।

# Simple NN with TensorFlow/Keras
from tensorflow import keras

model = keras.Sequential([
    keras.layers.Dense(64, activation='relu', input_shape=(n_features,)),
    keras.layers.Dense(1, activation='sigmoid')
])
model.compile(optimizer='adam', loss='binary_crossentropy')
↑ Back to Top

16. Deep Learning Introduction / डीप लर्निंग का परिचय

English

Deep learning is a subset of ML using neural networks with many layers (deep architectures). It excels at tasks like image recognition, NLP, speech recognition. Requires large data and computational power. Frameworks: TensorFlow, PyTorch.

सरल हिंदी

डीप लर्निंग ML का एक भाग है जिसमें कई परतों वाले न्यूरल नेटवर्क का उपयोग होता है। छवि पहचान, भाषा अनुवाद जैसे कार्यों में बेहतर। बड़े डेटा और कंप्यूट संसाधन चाहिए।

# Convolutional Neural Network (CNN) snippet
model = keras.Sequential([
    keras.layers.Conv2D(32, (3,3), activation='relu', input_shape=(28,28,1)),
    keras.layers.MaxPooling2D(2,2),
    keras.layers.Flatten(),
    keras.layers.Dense(10, activation='softmax')
])
↑ Back to Top

17. Tools and Libraries / उपकरण और पुस्तकालय

English

  • Python: Most popular language for ML.
  • NumPy: Numerical computing.
  • Pandas: Data manipulation.
  • Matplotlib/Seaborn: Data visualization.
  • Scikit-learn: Classical ML algorithms.
  • TensorFlow/PyTorch: Deep learning.
  • Jupyter: Interactive notebooks.

सरल हिंदी

  • Python – मुख्य भाषा।
  • NumPy – गणितीय कार्य।
  • Pandas – डेटा संचालन।
  • Scikit-learn – पारंपरिक ML एल्गोरिदम।
  • TensorFlow/PyTorch – डीप लर्निंग।
# Install essential libraries
pip install numpy pandas matplotlib scikit-learn tensorflow
↑ Back to Top

18. Ethics in Machine Learning / मशीन लर्निंग में नैतिकता

English

ML models can perpetuate or amplify biases present in training data, leading to unfair outcomes. Important considerations: fairness, accountability, transparency, privacy. Techniques: bias detection, explainable AI (XAI), differential privacy.

सरल हिंदी

ML मॉडल डेटा में मौजूद पूर्वाग्रहों को बढ़ा सकते हैं, जिससे अनुचित परिणाम हो सकते हैं। निष्पक्षता, पारदर्शिता, और गोपनीयता पर ध्यान देना जरूरी है।

# Example: Check for demographic parity in predictions
# (conceptual)
import fairlearn
↑ Back to Top