-
Notifications
You must be signed in to change notification settings - Fork 416
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
Type annotations & code refactor #704
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b0ff89f
reformat code, added type annotation for predictions method.
DanielAvdar 25a1168
reformat code and naming.
DanielAvdar 34e5ace
code reformat plus type annotations.
DanielAvdar d44f868
callback code reformat plus type annotations.
DanielAvdar a7f9503
validation code reformat plus type annotations.
DanielAvdar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
import uuid | ||
from typing import Union | ||
|
||
import numpy as np | ||
import pandas as pd | ||
|
||
from supervised.utils.common import construct_learner_name | ||
from supervised.utils.importance import PermutationImportance | ||
|
@@ -16,15 +18,15 @@ class BaseAlgorithm: | |
algorithm_name = "Unknown" | ||
algorithm_short_name = "Unknown" | ||
|
||
def __init__(self, params): | ||
self.params = params | ||
self.stop_training = False | ||
self.library_version = None | ||
self.model = None | ||
self.uid = params.get("uid", str(uuid.uuid4())) | ||
self.ml_task = params.get("ml_task") | ||
self.model_file_path = None | ||
self.name = "amazing_learner" | ||
def __init__(self, params: dict): | ||
self.params: dict = params | ||
self.stop_training: bool = False | ||
self.library_version: str = None | ||
self.model: object = None | ||
self.uid: str = params.get("uid", str(uuid.uuid4())) | ||
self.ml_task: str = params.get("ml_task") | ||
self.model_file_path: str = None | ||
self.name: str = "amazing_learner" | ||
|
||
def set_learner_name(self, fold, repeat, repeats): | ||
self.name = construct_learner_name(fold, repeat, repeats) | ||
|
@@ -38,15 +40,15 @@ def reload(self): | |
self.load(self.model_file_path) | ||
|
||
def fit( | ||
self, | ||
X, | ||
y, | ||
sample_weight=None, | ||
X_validation=None, | ||
y_validation=None, | ||
sample_weight_validation=None, | ||
log_to_file=None, | ||
max_time=None, | ||
self, | ||
X: Union[np.ndarray, pd.DataFrame], | ||
y: Union[np.ndarray, pd.Series], | ||
sample_weight=None, | ||
X_validation=None, | ||
y_validation=None, | ||
sample_weight_validation=None, | ||
log_to_file=None, | ||
max_time=None, | ||
): | ||
pass | ||
|
||
|
@@ -76,18 +78,18 @@ def get_fname(self): | |
return f"{self.name}.{self.file_extension()}" | ||
|
||
def interpret( | ||
self, | ||
X_train, | ||
y_train, | ||
X_validation, | ||
y_validation, | ||
model_file_path, | ||
learner_name, | ||
target_name=None, | ||
class_names=None, | ||
metric_name=None, | ||
ml_task=None, | ||
explain_level=2, | ||
self, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. spaces again? |
||
X_train, | ||
y_train, | ||
X_validation, | ||
y_validation, | ||
model_file_path, | ||
learner_name, | ||
target_name=None, | ||
class_names=None, | ||
metric_name=None, | ||
ml_task=None, | ||
explain_level=2, | ||
): | ||
# do not produce feature importance for Baseline | ||
if self.algorithm_short_name == "Baseline": | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
why are you adding spaces?
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.
This is automatic reformatting by the IDE.