0

Is there a way to implement a generalized linear model to classification problems in sklearn? Since there isn't a classification class for that I thought of applying a sigmoid function to regression results. Is there an easy way to do it with sklearn?

I've tried stacking but StackingClassifier does not support regressors as estimators.

glm = TweedieRegressor()
logit = LogisticRegression(penalty = 'none')

GLM_logistic = StackingClassifier(estimators = [('glm', glm)], final_estimator = logit)

GLM_logistic.fit(X, y)

This gives

ValueError: The estimator TweedieRegressor should be a classifier.
desertnaut
  • 57,590
  • 26
  • 140
  • 166

1 Answers1

0

I found a way to force it:

glm = TweedieRegressor()
glm._estimator_type = 'classifier'
logit = LogisticRegression()

GLM_logistic = StackingClassifier(estimators = [('glm', glm)], final_estimator = logit)

If someone has an idea of how to improve this solution, please leave an answer.