Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How am I supposed to use RandomizedLogisticRegression in Scikit-learn?

I simply have failed to understand the documentation for this class. I can fit data using it, and get the scores for features, but it this all this class is supposed to do?

I can't see how I can use it to actually perform regression using the model that was fit. The example in the documentation above is simply creating an instance of the class, so I can't see how that is supposed to help.

There are methods that perform 'transform' operation, but no mention of what kind of transform that is.

so is it possible to use this class to get actual predictions on new test data, and is it possible to use it in cross fold validation to compare performance with other methods I'm using?

I've used the highest ranking features in other classifiers, but I'm not sure if more than that is possible with this classifier.

Update: I've found the use for fit_transform under feature selection part of the documentation:

When the goal is to reduce the dimensionality of the data to use with another classifier, they expose a transform method to select the non-zero coefficient

Unless I get an answer that says I'm wrong, I'll assume that this classifier indeed does not do prediction. I'll wait before I answer my own question.

like image 554
mahonya Avatar asked Nov 27 '13 15:11

mahonya


People also ask

What is Max_iter in Sklearn?

max_iterint, default=100. Maximum number of iterations taken for the solvers to converge.

How does Sklearn logistic regression work?

It computes the probability of an event occurrence. It is a special case of linear regression where the target variable is categorical in nature. It uses a log of odds as the dependent variable. Logistic Regression predicts the probability of occurrence of a binary event utilizing a logit function.


1 Answers

Randomized LR is supposed to be a feature selection method, not a classifier in and of itself. Its API matches that of a standard scikit-learn transformer:

randomlr = RandomizedLogisticRegression()
X_train = randomlr.fit_transform(X_train)
X_test = randomlr.transform(X_test)

Then fit a model to X_train and do classification on X_test as usual.

like image 167
Fred Foo Avatar answered Nov 15 '22 10:11

Fred Foo