W3cubDocs

/scikit-learn

sklearn.linear_model.RandomizedLogisticRegression

Warning

DEPRECATED

class sklearn.linear_model.RandomizedLogisticRegression(*args, **kwargs) [source]

Randomized Logistic Regression

Randomized Logistic Regression works by subsampling the training data and fitting a L1-penalized LogisticRegression model where the penalty of a random subset of coefficients has been scaled. By performing this double randomization several times, the method assigns high scores to features that are repeatedly selected across randomizations. This is known as stability selection. In short, features selected more often are considered good features.

Parameters:
C : float or array-like of shape [n_reg_parameter], optional, default=1

The regularization parameter C in the LogisticRegression. When C is an array, fit will take each regularization parameter in C one by one for LogisticRegression and store results for each one in all_scores_, where columns and rows represent corresponding reg_parameters and features.

scaling : float, optional, default=0.5

The s parameter used to randomly scale the penalty of different features. Should be between 0 and 1.

sample_fraction : float, optional, default=0.75

The fraction of samples to be used in each randomized design. Should be between 0 and 1. If 1, all samples are used.

n_resampling : int, optional, default=200

Number of randomized models.

selection_threshold : float, optional, default=0.25

The score above which features should be selected.

tol : float, optional, default=1e-3

tolerance for stopping criteria of LogisticRegression

fit_intercept : boolean, optional, default=True

whether to calculate the intercept for this model. If set to false, no intercept will be used in calculations (e.g. data is expected to be already centered).

verbose : boolean or integer, optional

Sets the verbosity amount

normalize : boolean, optional, default True

If True, the regressors X will be normalized before regression. This parameter is ignored when fit_intercept is set to False. When the regressors are normalized, note that this makes the hyperparameters learnt more robust and almost independent of the number of samples. The same property is not valid for standardized data. However, if you wish to standardize, please use preprocessing.StandardScaler before calling fit on an estimator with normalize=False.

random_state : int, RandomState instance or None, optional (default=None)

If int, random_state is the seed used by the random number generator; If RandomState instance, random_state is the random number generator; If None, the random number generator is the RandomState instance used by np.random.

n_jobs : int or None, optional (default=None)

Number of CPUs to use during the resampling. None means 1 unless in a joblib.parallel_backend context. -1 means using all processors. See Glossary for more details.

pre_dispatch : int, or string, optional

Controls the number of jobs that get dispatched during parallel execution. Reducing this number can be useful to avoid an explosion of memory consumption when more jobs get dispatched than CPUs can process. This parameter can be:

  • None, in which case all the jobs are immediately created and spawned. Use this for lightweight and fast-running jobs, to avoid delays due to on-demand spawning of the jobs
  • An int, giving the exact number of total jobs that are spawned
  • A string, giving an expression as a function of n_jobs, as in ‘2*n_jobs’
memory : None, str or object with the joblib.Memory interface, optional (default=None)

Used for internal caching. By default, no caching is done. If a string is given, it is the path to the caching directory.

Attributes:
scores_ : array, shape = [n_features]

Feature scores between 0 and 1.

all_scores_ : array, shape = [n_features, n_reg_parameter]

Feature scores between 0 and 1 for all values of the regularization parameter. The reference article suggests scores_ is the max of all_scores_.

References

Stability selection Nicolai Meinshausen, Peter Buhlmann Journal of the Royal Statistical Society: Series B Volume 72, Issue 4, pages 417-473, September 2010 DOI: 10.1111/j.1467-9868.2010.00740.x

Examples

>>> from sklearn.linear_model import RandomizedLogisticRegression
>>> randomized_logistic = RandomizedLogisticRegression() 

Methods

fit(X, y) Fit the model using X, y as training data.
fit_transform(X[, y]) Fit to data, then transform it.
get_params([deep]) Get parameters for this estimator.
get_support([indices]) Get a mask, or integer index, of the features selected
inverse_transform(X) Reverse the transformation operation
set_params(**params) Set the parameters of this estimator.
transform(X) Reduce X to the selected features.
__init__(*args, **kwargs) [source]

DEPRECATED: The class RandomizedLogisticRegression is deprecated in 0.19 and will be removed in 0.21.

fit(X, y) [source]

Fit the model using X, y as training data.

Parameters:
X : array-like, shape = [n_samples, n_features]

Training data.

y : array-like, shape = [n_samples]

Target values. Will be cast to X’s dtype if necessary

Returns:
self : object

Returns an instance of self.

fit_transform(X, y=None, **fit_params) [source]

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) [source]

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.

get_support(indices=False) [source]

Get a mask, or integer index, of the features selected

Parameters:
indices : boolean (default False)

If True, the return value will be an array of integers, rather than a boolean mask.

Returns:
support : array

An index that selects the retained features from a feature vector. If indices is False, this is a boolean array of shape [# input features], in which an element is True iff its corresponding feature is selected for retention. If indices is True, this is an integer array of shape [# output features] whose values are indices into the input feature vector.

inverse_transform(X) [source]

Reverse the transformation operation

Parameters:
X : array of shape [n_samples, n_selected_features]

The input samples.

Returns:
X_r : array of shape [n_samples, n_original_features]

X with columns of zeros inserted where features would have been removed by transform.

set_params(**params) [source]

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:
self
transform(X) [source]

Reduce X to the selected features.

Parameters:
X : array of shape [n_samples, n_features]

The input samples.

Returns:
X_r : array of shape [n_samples, n_selected_features]

The input samples with only the selected features.

© 2007–2018 The scikit-learn developers
Licensed under the 3-clause BSD License.
http://scikit-learn.org/stable/modules/generated/sklearn.linear_model.RandomizedLogisticRegression.html