fknni.faiss.FaissImputer#

class fknni.faiss.FaissImputer(missing_values=nan, n_neighbors=5, *, metric='l2', strategy='mean', index_factory='Flat', min_data_ratio=0.25)#

Imputer for completing missing values using Faiss, incorporating weighted averages based on distance.

Methods table#

fit_transform(X[, y])

Imputes missing values in the data using the fitted Faiss index.

get_metadata_routing()

Get metadata routing of this object.

get_params([deep])

Get parameters for this estimator.

set_output(*[, transform])

Set output container.

set_params(**params)

Set the parameters of this estimator.

Methods#

FaissImputer.fit_transform(X, y=None, **fit_params)#

Imputes missing values in the data using the fitted Faiss index. This imputation will be performed in place. This imputation will use self.min_data_ratio to check if the index is of sufficient (dimension 0) size to perform a qualitative KNN lookup. If not, it will temporarily exclude enough features to reach this threshold and try again. If an index still can’t be built, it will use fallbacks values as defined by self.strategy.

Parameters:
  • X (ndarray) – Input data with potential missing values.

  • y (default: None) – Ignored, present for compatibility with sklearn’s TransformerMixin.

Return type:

ndarray[Any, dtype[Any]] | None

Returns:

Data with imputed values as a NumPy array of the original data type.

FaissImputer.get_metadata_routing()#

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Returns#

routingMetadataRequest

A MetadataRequest encapsulating routing information.

FaissImputer.get_params(deep=True)#

Get parameters for this estimator.

Parameters#

deepbool, default=True

If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns#

paramsdict

Parameter names mapped to their values.

FaissImputer.set_output(*, transform=None)#

Set output container.

See Introducing the set_output API for an example on how to use the API.

Parameters#

transform{“default”, “pandas”, “polars”}, default=None

Configure output of transform and fit_transform.

  • "default": Default output format of a transformer

  • "pandas": DataFrame output

  • "polars": Polars output

  • None: Transform configuration is unchanged

Added in version 1.4: "polars" option was added.

Returns#

selfestimator instance

Estimator instance.

FaissImputer.set_params(**params)#

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as Pipeline). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Parameters#

**paramsdict

Estimator parameters.

Returns#

selfestimator instance

Estimator instance.