11"""
22Linear regression is the most basic type of regression commonly used for
3- predictive analysis. The idea is pretty simple: we have a dataset and we have
3+ predictive analysis. The idea is pretty simple: we have a dataset, and we have
44features associated with it. Features should be chosen very cautiously
55as they determine how much our model will be able to make future predictions.
66We try to set the weight of these features, over many iterations, so that they best
7- fit our dataset. In this particular code, I had used a CSGO dataset (ADR vs
8- Rating). We try to best fit a line through dataset and estimate the parameters.
7+ fit our dataset. In this particular code, I used a CSGO dataset (ADR vs
8+ Rating). We try to best fit a line through the dataset and estimate the parameters.
99"""
1010
1111# /// script
1212# requires-python = ">=3.13"
1313# dependencies = [
14- # "httpx ",
14+ # "httpx2 ",
1515# "numpy",
1616# "matplotlib",
1717# ]
1818# ///
1919
20- import httpx
20+ import httpx2
2121import matplotlib .pyplot as plt
2222import numpy as np
2323
2424
2525def collect_dataset ():
2626 """Collect dataset of CSGO
2727 The dataset contains ADR vs Rating of a Player
28- :return : dataset obtained from the link, as matrix
28+ :return : dataset obtained from the link, as a matrix
2929 """
30- response = httpx .get (
30+ response = httpx2 .get (
3131 "https://raw.githubusercontent.com/yashLadha/The_Math_of_Intelligence/"
3232 "master/Week1/ADRvsRating.csv" ,
3333 timeout = 10 ,
@@ -43,13 +43,13 @@ def collect_dataset():
4343
4444
4545def run_steep_gradient_descent (data_x , data_y , len_data , alpha , theta ):
46- """Run steep gradient descent and updates the Feature vector accordingly_
46+ """Run steep gradient descent and update the Feature vector accordingly_
4747 :param data_x : contains the dataset
4848 :param data_y : contains the output associated with each data-entry
4949 :param len_data : length of the data_
5050 :param alpha : Learning rate of the model
51- :param theta : Feature vector (weight's for our model)
52- ;param return : Updated Feature's , using
51+ :param theta : Feature vector (weights for our model)
52+ ;param return : Updated features , using
5353 curr_features - alpha_ * gradient(w.r.t. feature)
5454 >>> import numpy as np
5555 >>> data_x = np.array([[1, 2], [3, 4]])
@@ -70,7 +70,7 @@ def run_steep_gradient_descent(data_x, data_y, len_data, alpha, theta):
7070
7171
7272def sum_of_square_error (data_x , data_y , len_data , theta ):
73- """Return sum of square error for error calculation
73+ """Return the sum of square error for error calculation
7474 :param data_x : contains our dataset
7575 :param data_y : contains the output (result vector)
7676 :param len_data : len of the dataset
@@ -121,7 +121,7 @@ def mean_absolute_error(predicted_y, original_y):
121121 """Return sum of square error for error calculation
122122 :param predicted_y : contains the output of prediction (result vector)
123123 :param original_y : contains values of expected outcome
124- :return : mean absolute error computed from given feature's
124+ :return : mean absolute error computed from given features
125125
126126 >>> predicted_y = [3, -0.5, 2, 7]
127127 >>> original_y = [2.5, 0.0, 2, 8]
0 commit comments