Skip to content

xgbse._base.XGBSEBaseEstimator

Base class for all estimators in xgbse. Implements explainability through prototypes.

get_neighbors(self, query_data, index_data=None, query_id=None, index_id=None, n_neighbors=30)

Search for portotypes (size: n_neighbors) for each unit in a dataframe X. If units array is specified, comparables will be returned using its identifiers. If not, a dataframe of comparables indexes for each sample in X is returned.

Parameters:

Name Type Description Default
query_data pd.DataFrame

Dataframe of features to be used as input

required
query_id [pd.Series, np.array]

Series or array of identification for each sample of query_data. Will be used in set_index if specified.

None
index_id [pd.Series, np.array]

Series or array of identification for each sample of index_id. If specified, comparables will be returned using this identifier.

None
n_neighbors int

Number of neighbors/comparables to be considered.

30

Returns:

Type Description
comps_df (pd.DataFrame)

A dataframe of comparables/neighbors for each evaluated sample. If units identifier is specified, the output dataframe is converted to use units the proper identifier for each sample. The reference sample is considered to be the index of the dataframe and its comparables are its specific row values.