Skip to content

Commit ebf3ab2

Browse files
Update README sections for dataset inputs and usage instructions in linear regression implementations
1 parent bda36ee commit ebf3ab2

2 files changed

Lines changed: 33 additions & 1 deletion

File tree

machine_learning/linear_regression_naive.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
"""README, Author - Somrita Banerjee(mailto:somritabanerjee126@gmail.com)
2+
Requirements:
3+
- Python >= 3.13
4+
- httpx
5+
- numpy
6+
7+
Inputs:
8+
- Downloads a CSV dataset (ADR vs Rating) from a public GitHub URL.
9+
- The dataset should have features in all columns except the last, which is the label.
10+
11+
Usage:
12+
- Run this script directly:
13+
python linear_regression_naive.py
14+
- The script will fetch the dataset, run linear regression using gradient descent, and print the learned feature vector (theta) and error at each iteration.
15+
16+
"""
117
"""
218
Naive implementation of Linear Regression using Gradient Descent.
319
@@ -120,7 +136,7 @@ def mean_absolute_error(predicted_y: np.ndarray, original_y: np.ndarray) -> floa
120136
>>> mean_absolute_error(predicted_y, original_y)
121137
0.5
122138
"""
123-
total = sum(abs(y - predicted_y[i]) for i, y in enumerate(original_y))
139+
total = sum(abs(predicted_y[i] - y) for i, y in enumerate(original_y))
124140
return total / len(original_y)
125141

126142

machine_learning/linear_regression_vectorized.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
"""README, Author - Somrita Banerjee(mailto:somritabanerjee126@gmail.com)
2+
Requirements:
3+
- Python >= 3.13
4+
- httpx
5+
- numpy
6+
7+
Inputs:
8+
- The script automatically downloads a CSV dataset (ADR vs Rating) from a public GitHub URL.
9+
- The dataset must have features in all columns except the last, which is the label (rating).
10+
11+
Usage:
12+
- Run this script directly:
13+
python linear_regression_vectorized.py
14+
- The script will fetch the dataset, run linear regression using gradient descent, and print the learned feature vector (theta) and error at intervals.
15+
16+
"""
117
"""
218
Vectorized implementation of Linear Regression using Gradient Descent.
319

0 commit comments

Comments
 (0)