-
-
Notifications
You must be signed in to change notification settings - Fork 46.6k
Fixes#8847 #9141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes#8847 #9141
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution. However, I'd really prefer that you don't just limit your fix to the univariate case, because the old implementation worked for multiple variables. Could you provide a direct-method implementation that also works for multiple variables?
""" | ||
import numpy as np | ||
import requests | ||
|
||
|
||
# Function to collect the CSGO dataset |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Function to collect the CSGO dataset |
This comment is unnecessary because we already have a docstring for the function.
# Remove the labels (headers) from the list | ||
data.pop(0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Remove the labels (headers) from the list | |
data.pop(0) | |
data.pop(0) # Remove the labels (headers) from the list |
# Remove the labels (headers) from the list | ||
data.pop(0) | ||
|
||
# Convert data to a NumPy matrix |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Convert data to a NumPy matrix |
Comment is unnecessary because this line is already clear without one
:param theta : Feature vector (weight's for our model) | ||
;param return : Updated Feature's, using | ||
curr_features - alpha_ * gradient(w.r.t. feature) | ||
# Function to calculate Mean Absolute Error (MAE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Function to calculate Mean Absolute Error (MAE) |
Unnecessary comment, we already have a docstring for the function
;param return : Updated Feature's, using | ||
curr_features - alpha_ * gradient(w.r.t. feature) | ||
# Function to calculate Mean Absolute Error (MAE) | ||
def calculate_mae(predicted_y, original_y): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add type hints
return sum(abs(y - predicted_y[i]) for i, y in enumerate(original_y)) / len( | ||
original_y | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return sum(abs(y - predicted_y[i]) for i, y in enumerate(original_y)) / len( | |
original_y | |
) | |
return sum(abs(y1 - y2) for y1, y2 in zip(predicted_y, original_y)) / len( | |
original_y | |
) |
) | ||
|
||
|
||
# Function to perform simple linear regression |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Function to perform simple linear regression |
Comment is unnecessary when there's already a docstring for the function
|
||
|
||
# Function to perform simple linear regression | ||
def simple_solve(data_x, data_y): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add type hints
print(f"sse is: {sse}") | ||
print(f"Half mse is: {half_mse}") | ||
print(f"Coefficient is: {beta_1}") | ||
print(f"Intercept is: {beta_0}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please read the contributing guidelines. Algorithmic functions should avoid side effects, including printing. Instead, please have your function simply return the regression coefficients.
The title of this pull request is not self-documenting. Why force readers and reviewers to look up an issue? Closing. |
Describe your change:
Fixes #8847
Checklist: