Skip to content

Conversation

@Olivier998
Copy link
Collaborator

Review des fichiers dans le folder MED3pa/MED3pa/*.

Returns:
List[str]: A list of supported file formats.
"""
return list(DataLoadingContext.strategies.keys())

This comment was marked as resolved.

elif dataset_type == 'testing':
self.testing_set = dataset
else:
raise ValueError(f"Invalid dataset_type provided: {dataset_type}")

This comment was marked as resolved.

elif operator == '!=':
mask &= x[:, column_index] != value
else:
raise ValueError(f"Unsupported operator '{operator}' in condition '{condition}'.")

This comment was marked as resolved.


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.


return {
"model": self.__baseModel.__class__.__name__,
"model_type": self.__baseModel.__class__.__name__,

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?

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.

@@ -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.

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.

'R2': cls.r2_score
}
if metric_name == '':
return list(metrics_mappings.keys())

This comment was marked as resolved.

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.

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.

This comment was marked as resolved.

Comment on lines +47 to +54
def get_strategy(self) -> DataLoadingStrategy:
"""
Returns the currently selected data loading strategy.

Returns:
DataLoadingStrategy: The currently selected data loading strategy.
"""
return self.selected_strategy

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**.

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

Copy link
Collaborator Author

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):

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 ?

Comment on lines 90 to 99
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}")

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

Comment on lines 118 to 125
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.

Comment on lines +181 to +186
if mode == 'ipc':
self.ipc_scores = scores
elif mode == "apc":
self.apc_scores = scores
elif mode == "mpc":
self.mpc_scores = scores

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.

Comment on lines +102 to +109
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

Choose a reason for hiding this comment

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

properety

Comment on lines 177 to 181
# if params is not None:
# if training_parameters is None:
# training_parameters = params
# else:
# training_parameters.update(params)

This comment was marked as resolved.

from .concrete_classifiers import XGBoostModel


class ModelFactory:

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 ?


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.

from MED3pa.models.xgboost_params import valid_xgboost_custom_params, valid_xgboost_params


class XGBoostModel(ClassificationModel):
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

à enlever ou refaire

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.

6 participants