fusilli.utils.model_chooser

This module contains the function to filter the fusion models based on the conditions specified by the user. Conditions are specified in a dictionary, where the keys are the features to filter by and the values are the conditions to filter by. The function returns a dataframe containing the filtered models.

Functions

all_model_importer(fusion_model_dict[,Ā ...])

Imports all the fusion models in the fusion_model_dict.

get_models(conditions_dict[,Ā skip_models,Ā ...])

Filters the models based on the conditions specified by the user.

import_chosen_fusion_models(model_conditions)

Imports the fusion models specified by the user.

all_model_importer(fusion_model_dict, skip_models=None)[source]

Imports all the fusion models in the fusion_model_dict.

Parameters:
  • fusion_model_dict (list) – List of dictionaries containing all the fusion models’ names and paths. Names mean the name of the class, and paths mean the path to the .py file containing the class. Note: this must be updated whenever a new fusion model is added.

  • skip_models (list) – List of models to skip when importing. Default is None. The list should consist of the class names of the models to skip e.g. [ā€œTabularDecisionā€, ā€œImgUnimodalā€]. You might skip models if some are not working properly for you.

Returns:

  • fusion_models (list) – List of all the fusion models class objects

  • fusion_model_dict_copy (list) – List of dictionaries containing all the fusion models’ names and paths, without the models that were skipped.

get_models(conditions_dict, skip_models=None, fusion_model_dict=[{'name': 'Tabular1Unimodal', 'path': 'fusionmodels.unimodal.tabular1'}, {'name': 'Tabular2Unimodal', 'path': 'fusionmodels.unimodal.tabular2'}, {'name': 'ImgUnimodal', 'path': 'fusionmodels.unimodal.image'}, {'name': 'ConcatTabularFeatureMaps', 'path': 'fusionmodels.tabularfusion.concat_feature_maps'}, {'name': 'ConcatImageMapsTabularData', 'path': 'fusionmodels.tabularimagefusion.concat_img_maps_tabular_data'}, {'name': 'ConcatTabularData', 'path': 'fusionmodels.tabularfusion.concat_data'}, {'name': 'ConcatImageMapsTabularMaps', 'path': 'fusionmodels.tabularimagefusion.concat_img_maps_tabular_maps'}, {'name': 'TabularChannelWiseMultiAttention', 'path': 'fusionmodels.tabularfusion.channelwise_att'}, {'name': 'ImageChannelWiseMultiAttention', 'path': 'fusionmodels.tabularimagefusion.channelwise_att'}, {'name': 'CrossmodalMultiheadAttention', 'path': 'fusionmodels.tabularimagefusion.crossmodal_att'}, {'name': 'TabularCrossmodalMultiheadAttention', 'path': 'fusionmodels.tabularfusion.crossmodal_att'}, {'name': 'TabularDecision', 'path': 'fusionmodels.tabularfusion.decision'}, {'name': 'ImageDecision', 'path': 'fusionmodels.tabularimagefusion.decision'}, {'name': 'MCVAE_tab', 'path': 'fusionmodels.tabularfusion.mcvae_model'}, {'name': 'ConcatImgLatentTabDoubleTrain', 'path': 'fusionmodels.tabularimagefusion.concat_img_latent_tab_doubletrain'}, {'name': 'ConcatImgLatentTabDoubleLoss', 'path': 'fusionmodels.tabularimagefusion.concat_img_latent_tab_doubleloss'}, {'name': 'EdgeCorrGNN', 'path': 'fusionmodels.tabularfusion.edge_corr_gnn'}, {'name': 'DAETabImgMaps', 'path': 'fusionmodels.tabularimagefusion.denoise_tab_img_maps'}, {'name': 'AttentionWeightedGNN', 'path': 'fusionmodels.tabularfusion.attention_weighted_GNN'}, {'name': 'AttentionAndSelfActivation', 'path': 'fusionmodels.tabularfusion.attention_and_activation'}, {'name': 'ActivationFusion', 'path': 'fusionmodels.tabularfusion.activation'}])[source]

Filters the models based on the conditions specified by the user.

Parameters:
  • conditions_dict (dict) –

    Dictionary containing the conditions to filter the models. Structure: {feature1: condition, feature2: condition, …} or {feature1: [condition1, condition2, …], feature2: [condition1, …], …}

    Accepted features and accepted conditions:

    • ā€fusion_typeā€: ā€œunimodalā€, ā€œoperationā€, ā€œattentionā€, ā€œsubspaceā€, ā€œgraphā€, or ā€œallā€

    • ā€modality_typeā€: ā€œtabular1ā€, ā€œtabular2ā€, ā€œimgā€, ā€œtabular_tabularā€, ā€œtabular_imageā€, or ā€œallā€

    • ā€method_nameā€: any method name currently implemented (e.g. ā€œTabular decisionā€), or ā€œallā€

    • ā€class_nameā€: any model name currently implemented (e.g. ā€œTabularDecisionā€), or ā€œallā€

    Example: To get all the models that are uni-modal and attention-based, the dictionary would be:

    conditions_dict = {
        "fusion_type": ["unimodal", "operation"],
        "modality_type": "all",
        }
    

  • fusion_model_dict (list) – List of dictionaries containing the fusion models’ names and paths. Default is fusion_model_dict.

  • skip_models (list) – List of models to skip when importing. Default is None. The list should consist of the class names of the models to skip e.g. [ā€œTabularDecisionā€, ā€œImgUnimodalā€]. You might skip models if some are not working properly for you.

Returns:

filtered_models – Dataframe containing the filtered models.

Column names:

  • ā€method_nameā€: name of the model (e.g. ā€œTabular decisionā€)

  • ā€fusion_typeā€: type of fusion (e.g. ā€œoperationā€)

  • ā€modality_typeā€: type of modality (e.g. ā€œtabular_tabularā€)

  • ā€class_nameā€: name of the class (e.g. ā€œTabularDecisionā€)

  • ā€method_pathā€: path to the method’s py file (e.g. ā€œfusilli.fusionmodels.tabular_decisionā€)

Return type:

pd.DataFrame

import_chosen_fusion_models(model_conditions, skip_models=None)[source]

Imports the fusion models specified by the user.

Parameters:
  • model_conditions (dict) –

    Dictionary containing the conditions to filter the models. Structure: {feature1: condition, feature2: condition, …} or {feature1: [condition1, condition2, …], feature2: [condition1, …], …}

    Accepted features and accepted conditions:

    • ā€fusion_typeā€: ā€œunimodalā€, ā€œoperationā€, ā€œattentionā€, ā€œsubspaceā€, ā€œgraphā€, or ā€œallā€

    • ā€modality_typeā€: ā€œtabular1ā€, ā€œtabular2ā€, ā€œimgā€, ā€œtabular_tabularā€, ā€œtabular_imageā€, or ā€œallā€

    • ā€method_nameā€: any method name currently implemented (e.g. ā€œTabular decisionā€), or ā€œallā€

    • ā€class_nameā€: any model name currently implemented (e.g. ā€œTabularDecisionā€), or ā€œallā€

    Example: To get all the models that are uni-modal and attention-based, the dictionary would be:

    conditions_dict = {
        "fusion_type": ["unimodal", "operation"],
        "modality_type": "all",
        }
    

  • skip_models (list) – List of models to skip when importing. Default is None. The list should consist of the class names of the models to skip e.g. [ā€œTabularDecisionā€, ā€œImgUnimodalā€]. You might skip models if some are not working properly for you.

Returns:

fusion_models – List of all the fusion models class objects

Return type:

list