-
Notifications
You must be signed in to change notification settings - Fork 0
Review #2
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
base: code_review
Are you sure you want to change the base?
Review #2
Conversation
MED3pa/datasets/loading_context.py
Outdated
| Returns: | ||
| List[str]: A list of supported file formats. | ||
| """ | ||
| return list(DataLoadingContext.strategies.keys()) |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
MED3pa/datasets/manager.py
Outdated
| elif dataset_type == 'testing': | ||
| self.testing_set = dataset | ||
| else: | ||
| raise ValueError(f"Invalid dataset_type provided: {dataset_type}") |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
| elif operator == '!=': | ||
| mask &= x[:, column_index] != value | ||
| else: | ||
| raise ValueError(f"Unsupported operator '{operator}' in condition '{condition}'.") |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
MED3pa/med3pa/profiles.py
Outdated
|
|
||
| Args: | ||
| profiles_list (List[dict]): List of profiles data. | ||
| to_dict (bool, optional): If True, transforms profiles to dictionaries. Defaults to True. |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
|
|
||
| return { | ||
| "model": self.__baseModel.__class__.__name__, | ||
| "model_type": self.__baseModel.__class__.__name__, |
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.
je trouve que model et model_type sont redondants, peut être une seule variable à séparer plus tard?
MED3pa/models/concrete_regressors.py
Outdated
| Args: | ||
| base_model (RandomForestRegressorModel): A prototype instance of RandomForestRegressorModel. | ||
| n_models (int): The number of RandomForestRegressorModel instances in the ensemble. | ||
| params (Dict[str, Any]): A list of parameter dictionaries for each model in the ensemble. |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
MED3pa/models/data_strategies.py
Outdated
| @@ -0,0 +1,148 @@ | |||
| """ | |||
| This module is crucial for data handling, utilizing the **Strategy design pattern** and therefor offering multiple strategies to transform raw data into formats that enhance model training and evaluation. | |||
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
| Args: | ||
| result (Med3paResults): The results of the experiment to visualize. | ||
| dr (int): Declaration rate of predictions for the visualization. | ||
| samp_ratio (int): The minimum samples ratio in each profile (in percentage). |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
MED3pa/models/regression_metrics.py
Outdated
| 'R2': cls.r2_score | ||
| } | ||
| if metric_name == '': | ||
| return list(metrics_mappings.keys()) |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
| Initializes the EnsembleRandomForestRegressorModel with multiple RandomForestRegressor models. | ||
|
|
||
| Args: | ||
| base_model (RandomForestRegressorModel): A prototype instance of RandomForestRegressorModel. |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
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.
La methode _run_by_set est trop longue ( 225 lignes God Function ), je pense c bien de diviser la méthode en plusieurs sous-méthodes pour réspecter le principe de SRP
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
| def get_strategy(self) -> DataLoadingStrategy: | ||
| """ | ||
| Returns the currently selected data loading strategy. | ||
|
|
||
| Returns: | ||
| DataLoadingStrategy: The currently selected data loading strategy. | ||
| """ | ||
| return self.selected_strategy |
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.
ça devrait pas être une properety ?
| @@ -0,0 +1,78 @@ | |||
| """ | |||
| This module provides a flexible framework for loading datasets from various file formats by utilizing the **strategy design pattern**. | |||
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.
tu pourrais ajouter le nom de l'auteur dans l'entête de chaque fichier
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.
MED3pa Team!
| from abc import ABC, abstractmethod | ||
|
|
||
|
|
||
| class DataLoadingStrategy(ABC): |
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.
Quel est le but de créer une classe parent qui est héritée par une seule classe seulement, et qui ne contient qu'une seule méthode statique ? est-ce que créer une fonction load_data_from_csv() n'est pas suffisant ?
MED3pa/datasets/manager.py
Outdated
| if dataset_type == 'training': | ||
| self.base_model_training_set = dataset | ||
| elif dataset_type == 'validation': | ||
| self.base_model_validation_set = dataset | ||
| elif dataset_type == 'reference': | ||
| self.reference_set = dataset | ||
| elif dataset_type == 'testing': | ||
| self.testing_set = dataset | ||
| else: | ||
| raise ValueError(f"Invalid dataset_type provided: {dataset_type}") |
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.
ce bloc de codes est répété plusieurs fois, tu peux en faire une méthode
MED3pa/datasets/manager.py
Outdated
| if self.base_model_training_set is not None: | ||
| self.base_model_training_set.column_labels = columns | ||
| if self.base_model_validation_set is not None: | ||
| self.base_model_validation_set.column_labels = columns | ||
| if self.reference_set is not None: | ||
| self.reference_set.column_labels = columns | ||
| if self.testing_set is not None: | ||
| self.testing_set.column_labels = columns |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
| if mode == 'ipc': | ||
| self.ipc_scores = scores | ||
| elif mode == "apc": | ||
| self.apc_scores = scores | ||
| elif mode == "mpc": | ||
| self.mpc_scores = scores |
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.
pourraient tous être des setters
| Concrete implementation of the UncertaintyMetric class using Sigmoidal error. | ||
| """ | ||
| @staticmethod | ||
| def calculate(x: np.ndarray, predicted_prob: np.ndarray, y_true: np.ndarray, threshold=0.5) -> np.ndarray: |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
| def is_pickled(self) -> bool: | ||
| """ | ||
| Returns whether the model has been loaded from a pickled file. | ||
|
|
||
| Returns: | ||
| Boolean: has the model been loaded from a pickled file. | ||
| """ | ||
| return self.pickled_model |
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.
properety
MED3pa/models/concrete_regressors.py
Outdated
| # if params is not None: | ||
| # if training_parameters is None: | ||
| # training_parameters = params | ||
| # else: | ||
| # training_parameters.update(params) |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
| from .concrete_classifiers import XGBoostModel | ||
|
|
||
|
|
||
| class ModelFactory: |
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.
une classe dont toutes les méthodes sont statiques ?
MED3pa/med3pa/experiment.py
Outdated
|
|
||
| if predicted_probabilities is None: | ||
| # base_model = base_model_manager.get_instance() | ||
| predicted_probabilities = base_model_manager.predict_proba(x)[:, 1] # base_model.predict(x, True) |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
| from MED3pa.models.xgboost_params import valid_xgboost_custom_params, valid_xgboost_params | ||
|
|
||
|
|
||
| class XGBoostModel(ClassificationModel): |
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.
à enlever ou refaire
Review des fichiers dans le folder MED3pa/MED3pa/*.