Machine Learning

What is Machine Learning?

Machine Learning (ML) is a subset of artificial intelligence that focuses on building systems that learn from data, identify patterns, and make decisions with minimal human intervention.

Key concepts include:

  • Supervised Learning – learning from labeled data.
  • Unsupervised Learning – discovering hidden structures in unlabeled data.
  • Reinforcement Learning – agents learning via rewards and penalties.

Common Algorithms

Algorithm Type Typical Use‑Case
Linear Regression Supervised Predict continuous values
Logistic Regression Supervised Binary classification
K‑Means Unsupervised Clustering
Random Forest Supervised Ensemble classification/regression
Q‑Learning Reinforcement Game playing, robotics

Interactive Quiz

Which algorithm is best suited for clustering?

Sample Code (Python)

import numpy as np
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import accuracy_score

# Dummy dataset
X = np.random.rand(200, 5)
y = (X[:, 0] + X[:, 1] > 1).astype(int)

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42)

model = RandomForestClassifier(n_estimators=100, random_state=42)
model.fit(X_train, y_train)

pred = model.predict(X_test)
print("Accuracy:", accuracy_score(y_test, pred))