Skip to content

back

Converter - abstract class

class arsa_ml.converters.Converter


This class is an abstract class asserting all converter classes have the same set of obligatory methods. Converters are used to provide models results to the RashomonSet/RashomonIntersection in a correct format.



Methods


Note: All methods are decorated as @abstractmethod and must be implemented in every child class.

create_predictions_dict()

Method for extracting trained models and their class predictions from a used framework. Returns the results in a dictionary format with model names as keys and their class prediction vector (pandas.Series) as values.

Returns :
predictions_dict : dict[str, pd.Series]

create_proba_predictions_dict()

Method for extracting trained models and their probability predictions from a used framework. Returns the results in a dictionary format with model names as keys and their probabilistic predictions (pandas.DataFrame) as values.

Returns :
proba_predictions_dict : dict[str, pd.DataFrame]

create_feature_importance_dict()

Method for extracting trained models and their feature importance from a used framework. Returns the results in a dictionary format with model names as keys and the list of features sorted by feature importance as values.

Returns :
feature_importance_dict : dict[str, list]

save_results(leaderboard, predictions_dict, proba_predictions_dict, feature_importance_dict, y_true, saving_path)

Method for saving results returned by the convert() method in a specified or default directory.

Parameters :
leaderboard: pd.DataFrame
created leaderboard to be saved as csv

predictions_dict : dict
created class predictions dict to be saved as pickle

proba_predictions_dict : dict
created proba predictions dict to be saved as pickle

feature_importance_dict : dict
created feature importance dict to be saved as pickle

y_true : pd.DataFrame
extracted target column to be saved as a csv

saving_path : Path
path to a saving directory, if not specified default is timestamp + df_name

convert(saving_path)

  Primary method performing all the necessary calculations and returning the converted objects:
1. pd.DataFrame - leaderboard with all models and their scores
2. dict : predictions_dict
3. dict : proba_predictions_dict
4. dict : feature_importance_dict (or None if feature importance was not needed)
5. pd.DataFrame : y_true


Parameters :
saving_path: Path
    path to a saving directory, if not specified default is timestamp + df_name

Returns :
leaderboard : pd.DataFrame
predictions_dict : dict
proba_predictions_dict : dict
feature_importance_dict : dict
y_true : pd.DataFrame