Algorithm Explorer
Supervised Learning Algorithms
Click each algorithm to understand how it works and where it's used in the real world.
Linear Regression
How it Works
Fits a straight line through data points to predict a continuous numeric value based on input features.
Real-World Use
Predicting house prices, stock values, or sales forecasts.
Supervised learning is where the machine is taught by example. The data you provide is already 'labeled' with the correct answers. Below are the most critical algorithms used in this field.
1. Linear & Logistic Regression
Linear Regression is used for predicting numerical values. Logistic Regression is used for classification (like Spam detection).
2. Decision Trees & Random Forests
A Decision Tree works like a flow-chart. A Random Forest is a collection of many trees that vote on the final result, making it much more robust.
3. Support Vector Machines (SVM)
SVM finds the optimal boundary to separate different classes of data effectively.
Python: Logistic Regression
Using scikit-learn to classify simple data points:
python
from sklearn.linear_model import LogisticRegression
import numpy as np
# Data: [Study Hours], Label: [Fail=0, Pass=1]
X = np.array([[1], [2], [3], [4], [5], [6]])
y = np.array([0, 0, 0, 1, 1, 1])
model = LogisticRegression()
model.fit(X, y)
# Predict for 4.5 hours of study
print(f"Prediction for 4.5h: {'Pass' if model.predict([[4.5]])[0] == 1 else 'Fail'}")