Skip to content
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

Add linear regression #15

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open

Add linear regression #15

wants to merge 21 commits into from

Conversation

SarahAlidoost
Copy link
Member

@SarahAlidoost SarahAlidoost commented Jan 17, 2025

closes #2
closes #19

@SarahAlidoost SarahAlidoost marked this pull request as ready for review January 27, 2025 15:20
Copy link
Collaborator

@fnattino fnattino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good @SarahAlidoost, just a few minor comment.

One think that I have thought of right now while looking at the code is data normalization, which I think is not implemented but maybe should be included as part of the data preparation (maybe in the pipeline)?

@dataclass
class Estimator:
name: str
func: callable
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand correctly, this is actually assigned an estimator instance (something that implements estimator.fit() and estimator.predict()) - so not a callable function, right?

"mean_absolute_error": sm.mean_absolute_error,
}

def __init__(self, estimator: str | Estimator, kwargs: dict = None) -> None:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe instead of kwargs either use **kwargs (i.e. with unpacking) or use a more descriptive name (maybe params?)?

Also, I am not 100% sure, but if a parameter has None as default, this should be made explicit in the type hint:

Suggested change
def __init__(self, estimator: str | Estimator, kwargs: dict = None) -> None:
def __init__(self, estimator: str | Estimator, kwargs: dict | None = None) -> None:

Comment on lines +58 to +60
if kwargs:
for key, value in kwargs.items():
setattr(self.estimator.func, key, value)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Estimator objects in scikit-learn should have a set_params method (see link), so maybe one could do:

Suggested change
if kwargs:
for key, value in kwargs.items():
setattr(self.estimator.func, key, value)
self.estimator.func.set_params(**kwargs)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SonarCloud quality gate failing Explore linear regression models
2 participants