pyrfm.random_feature.MB

class pyrfm.random_feature.MB(n_components=1000, dense_output=False)[source]

Bases: sklearn.base.BaseEstimator, sklearn.base.TransformerMixin

Approximates feature map of the intersection (min) kernel by explicit feature map, which is proposed by S.Maji and A.C.Berg.

Parameters
  • n_components (int (default=1000)) – The dimension of the computed (mapped) feature space.

  • dense_output (bool (default=False)) – Whether output feature matrix is dense or sparse.

References

[1] Max-Margin Additive Classifiers for Detection. Subhransu Maji and Alexander C. Berg. In ICCV 2009. (http://acberg.com/papers/mb09iccv.pdf)

fit(X, y=None)[source]

Compute the number of grids according to n_features.

Parameters

X ({array-like, sparse matrix}, shape (n_samples, n_features)) – Training data, where n_samples is the number of samples and n_features is the number of features.

Returns

self – Returns the transformer.

Return type

object

fit_transform(X, y=None, **fit_params)

Fit to data, then transform it.

Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.

Parameters
  • X (numpy array of shape [n_samples, n_features]) – Training set.

  • y (numpy array of shape [n_samples]) – Target values.

Returns

X_new – Transformed array.

Return type

numpy array of shape [n_samples, n_features_new]

get_params(deep=True)

Get parameters for this estimator.

Parameters

deep (boolean, optional) – If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns

params – Parameter names mapped to their values.

Return type

mapping of string to any

set_params(**params)

Set the parameters of this estimator.

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

Returns

Return type

self

transform(X)[source]

Apply the approximate feature map to X.

Parameters

X ({array-like, sparse matrix}, shape (n_samples, n_features)) – New data, where n_samples is the number of samples and n_features is the number of features.

Returns

X_new

Return type

{np.ndarray, csr_matrix}, shape (n_samples, n_components)