def __init__(self, data, N_i, N_c, *args, **kwargs):
""" Fit a regularized logistic regression model to a Dataset object.
By default, uses L1 regularization with the strength chosen from
10 options spaced logarithmically between 1e-4 and 1e4
(the sklearn LogisticRegressionCV default) using
min(10,data.n_subjects) folds of crossvalidation, but other
options may be chosen by specifing arguments to the
LogisticRegressionCV constructor through *args and **kwargs.
N_i, N_c: parameters defining allowed time windows. See the
transform_X method.
args, kwargs: passed to the LogisticRegressionCV constructor.
"""
Wrapper.__init__(self,data,N_i,N_c)
default_folds = min(10,data.n_subjects)
default_classifier_arguments = {
'cv': default_folds,
'solver': 'liblinear',
'penalty': 'l1',
}
# Update with the arguments passed in by the user, clobbering
# the default settings if alternate values are provided.
default_classifier_arguments.update(kwargs)
self.classifier = LogisticRegressionCV(
*args,
**default_classifier_arguments
)
self.classifier.fit(self.fit_X,self.fit_y)
评论列表
文章目录