bosk.comparison.base#

Module Contents#

Classes#

BaseForeignModel

Adapter class for all models, defined outside

BaseComparator

Class that performes comparison of different models.

Functions#

get_block_md5_hash(block)

Helper function to obtain blocks' hashes

class bosk.comparison.base.BaseForeignModel#

Bases: abc.ABC

Adapter class for all models, defined outside of the bosk framework. It is needed to make sure that the model handles bosk’s style of the data transmission.

abstract fit(data)#

Method to handle the data dictionary and fit the model.

Parameters:

data (Dict[str, bosk.data.BaseData]) –

Return type:

None

abstract predict(data)#

Method for using the fitted model and obtain transformed data dictionary.

Parameters:

data (Dict[str, bosk.data.BaseData]) –

Return type:

Dict[str, bosk.data.BaseData]

abstract set_random_state(random_state)#

Set random state for the model.

Parameters:

random_state (int) –

Return type:

None

bosk.comparison.base.get_block_md5_hash(block)#

Helper function to obtain blocks’ hashes and cache them.

Parameters:

block (bosk.block.base.BaseBlock) –

class bosk.comparison.base.BaseComparator(pipelines, foreign_models, f_optimize_pipelines=True, random_state=None)#

Bases: abc.ABC

Class that performes comparison of different models. The models, defined via bosk framework, marked as pipelines and may have a common part in them to optimize calculations (common part pipeline will be executed once and retreived data will be used in other pipelines). The common part must be a common begining of all pipelines.

The models, defined with others but bosk frameworks, are marked as models and must be wrapped in BaseForeignModel adapter to handle the bosk data transmission style.

Parameters:
random_state :Optional[int]#
_get_aj_lists(pipeline)#
Parameters:

pipeline (bosk.pipeline.base.BasePipeline) –

_compare_blocks_conns(block_1, block_2, aj_list_1, aj_list_2, conns_iso_1, conns_iso_2)#
Parameters:
Return type:

bool

_set_random_state(random_state=None)#
_set_manual_state(pipeline, random_state)#
_get_common_inputs(pipelines)#
Parameters:

pipelines (List[bosk.pipeline.base.BasePipeline]) –

Return type:

List[str]

_find_next_block(cur_block, leading_conn_map, pipelines, conn_maps_list, queue_list, leading_slots_iso, slots_iso_list)#
Return type:

Optional[List[bosk.block.base.BaseBlock]]

_add_common_block(pipelines_blocks, conn_map_list, iso_blocks_list, iso_slots_list, common_blocks, common_conn_map)#
Parameters:
Return type:

None

_continue_bfs(continue_blocks, queue_list, conn_maps_blocks)#
Return type:

None

_get_input_plug(slot)#
Parameters:

slot (bosk.block.base.BaseSlot) –

Return type:

bosk.block.base.BaseInputBlock

_splice_pipelines(conns_to_append, conns_to_remove, inp_slot_pip, common_outputs, out_slot_cp, extra_inputs, extra_blocks)#
Return type:

None

_get_common_input_dict(common_inp_names, inp_dict_pip, slots_iso)#
Return type:

Dict[str, bosk.block.base.BlockInputSlot]

abstract get_score(data, metrics)#

Function to obtain results of different metrics for the models.

Parameters:
Return type:

pandas.DataFrame