random_output_trees.random_projection.AchlioptasRandomProjection

class random_output_trees.random_projection.AchlioptasRandomProjection(n_components='auto', eps=0.1, random_state=None, dense_output=False)

Sparse random projection using Achlioptas random matrix

If we note `s = 1 / density = 1 / 3 ` the components of the random matrix are drawn from:

  • -sqrt(s) / sqrt(n_components) with probability 1 / 2s
  • 0 with probability 1 - 1 / s
  • +sqrt(s) / sqrt(n_components) with probability 1 / 2s
Parameters:

n_components : int or ‘auto’, optional (default = ‘auto’)

Dimensionality of the target projection space.

n_components can be automatically adjusted according to the number of samples in the dataset and the bound given by the Johnson-Lindenstrauss lemma. In that case the quality of the embedding is controlled by the eps parameter.

It should be noted that Johnson-Lindenstrauss lemma can yield very conservative estimated of the required number of components as it makes no assumption on the structure of the dataset.

eps : strictly positive float, optional (default=0.1)

Parameter to control the quality of the embedding according to the Johnson-Lindenstrauss lemma when n_components is set to ‘auto’.

Smaller values lead to better embedding and higher number of dimensions (n_components) in the target projection space.

dense_output : boolean, optional (default=False)

If True, ensure that the output of the random projection is a dense numpy array even if the input and random projection matrix are both sparse. In practice, if the number of components is small the number of zero components in the projected data will be very small and it will be more CPU and memory efficient to use a dense representation.

If False, the projected data uses a sparse representation if the input is sparse.

random_state : integer, RandomState instance or None (default=None)

Control the pseudo random number generator used to generate the matrix at fit time.

Attributes

n_component_ int Concrete number of components computed when n_components=”auto”.
components_ numpy array of shape [n_components, n_features] Random matrix used for the projection.

Methods

fit(X[, y]) Generate a sparse random projection matrix
fit_transform(X[, y]) Fit to data, then transform it.
get_params([deep]) Get parameters for this estimator.
set_params(**params) Set the parameters of this estimator.
transform(X[, y]) Project the data by using matrix product with the random matrix
__init__(n_components='auto', eps=0.1, random_state=None, dense_output=False)
fit(X, y=None)

Generate a sparse random projection matrix

Parameters:

X : numpy array or scipy.sparse of shape [n_samples, n_features]

Training set: only the shape is used to find optimal random matrix dimensions based on the theory referenced in the afore mentioned papers.

y : is not used: placeholder to allow for usage in a Pipeline.

Returns:

self :

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 : numpy array of shape [n_samples, n_features_new]

Transformed array.

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 : mapping of string to any

Parameter names mapped to their values.

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 former have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Returns:self :
transform(X, y=None)

Project the data by using matrix product with the random matrix

Parameters:

X : numpy array or scipy.sparse of shape [n_samples, n_features]

The input data to project into a smaller dimensional space.

y : is not used: placeholder to allow for usage in a Pipeline.

Returns:

X_new : numpy array or scipy sparse of shape [n_samples, n_components]

Projected array.