Skip to main content

Module plots

Function plot_feature_importance

View Source

plot_feature_importance(model: RandomForestClassifier, features: DataFrame, gt: Series, model_type: str, out_path: str, num_features: int = 30) -> None

Plots feature importance plot based on out of box feature importance metric. Args: model (RandomForestClassifier): Model to plot for. features (pd.DataFrame): Features of training data. gt (pd.Series): labels of training data. model_type (str): Model used out_path (str): Path where plotly is saved Raises: NotImplementedError: Currently only Random Forest implemented, Logistic regression does not support feature importance

Function plot_misclassified

View Source

plot_misclassified(misclassified: list, out_path: str, features: DataFrame) -> None

Plot the 20 patients that were most misclassified.

Function plot_partial_dependency_plots

View Source

plot_partial_dependency_plots(model: LogisticRegression | RandomForestClassifier | Pipeline, features: DataFrame, gt: Series, out_folder: str, feature_subset: list = []) -> None

Plots partial dependency plots for predefined subset of features and saves them in out folder. Args: model (Union[LogisticRegression, RandomForestClassifier, Pipeline]): Model to plot for. features (pd.DataFrame): Features of training data. gt (pd.Series): labels of training data. model_type (str): Model used out_folder (str): Folder where partial dependency plots are stored. feature_subset (list): List of features for which partial dependency plot should be plotted. If empty all are plotted.

Function plot_roc_curve

View Source

plot_roc_curve(experiment_name: str, fprs: list, tprs: list, thresholds: list, aucs: list, out_path: str, plot_dict: dict, clearml_logger: UnionType[Logger, None] = None, pirads_dict: UnionType[dict, None] = None) -> None

Plot the ROC curve.

Args: experiment_name (str): The experiment name. fprs (list): The list of false positive rates. tprs (list): The list of true positive rates. thresholds (list): The list of thresholds. aucs (list): The list of AUCs. out_path (str): The output path. plot_dict (dict): The plot dictionary. clearml_logger (ClearmlLogger): The clearml logger. pirads_dict (dict): The PIRADS dictionary.

Returns: None

Function plot_scatter

View Source

plot_scatter(model: LogisticRegression | RandomForestClassifier | Pipeline, features: DataFrame, gt: Series, out_folder: str, feature_subset: list = [], fit: bool = False, fit_cv: bool = False) -> None

Plots scatter plots of features against predicted probabilities and saves them in out folder. Args: model (Union[LogisticRegression, RandomForestClassifier, Pipeline]): Model to plot for. features (pd.DataFrame): Features of training data. gt (pd.Series): Labels of training data. out_folder (str): Folder where scatter plots are stored. feature_subset (list, optional): List of features for which scatter plots should be plotted. If empty, all are plotted. Defaults to []. fit (bool, optional): Whether to fit the model before plotting. Defaults to False. fit_cv (bool, optional): Whether to use cross-validation when fitting the model. Defaults to False.

Function plot_shapely

View Source

plot_shapely(model: LogisticRegression | RandomForestClassifier | Pipeline, features: DataFrame, gt: Series, model_type: str, out_path: str) -> None

Plots shapely value and saves result in outpath Args: model (Union[LogisticRegression, RandomForestClassifier, Pipeline]): Model to plot for. features (pd.DataFrame): Features of training data. gt (pd.Series): labels of training data. model_type (str): Model used out_path (str): Path where plotly is saved

Raises: NotImplementedError: Currently only Random Forest implemented

Function plot_single_roc_curve

View Source

plot_single_roc_curve(gt: UnionType[Series, ndarray], y_proba: UnionType[Series, ndarray], plot_dict: dict, training_threshold: float, out_path: str, name: str) -> None

Create ROC curve based on single evaluation. Args: gt (pd.Series | np.ndarray): Ground truth y_proba (pd.Series | np.ndarray): Predicted Probabilities plot_dict (dict): Plotting dict training_threshold (float): Training Threshold out_path (str): Path for saving name (str): Plot name

Function plot_violin

View Source

plot_violin(model: LogisticRegression | RandomForestClassifier | Pipeline, features: DataFrame, gt: Series, isup: UnionType[Series, ndarray], out_folder: str, fit: bool = False, fit_cv: bool = False) -> None

Plots violin plots for ISUP and cancer separation and saves them in out folder. Args: model (Union[LogisticRegression, RandomForestClassifier, Pipeline]): Model to plot for. features (pd.DataFrame): Features of training data. gt (pd.Series): Labels of training data. isup (pd.Series | np.ndarray): ISUP scores. out_folder (str): Folder where violin plots are stored. fit (bool, optional): Whether to fit the model before plotting. Defaults to False. fit_cv (bool, optional): Whether to use cross-validation when fitting the model. Defaults to False.