[docs]classLogisticRegression(SklearnMethod):""" This is a wrapper of scikit-learn’s LogisticRegression class. Please see the `scikit-learn documentation <https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html>`_ of LogisticRegression for the parameters. Note: if you are interested in plotting the coefficients of the logistic regression model, consider running the :ref:`Coefficients` report. For usage instructions, check :py:obj:`~immuneML.ml_methods.classifiers.SklearnMethod.SklearnMethod`. **YAML specification:** .. indent with spaces .. code-block:: yaml definitions: ml_methods: my_logistic_regression: # user-defined method name LogisticRegression: # name of the ML method # sklearn parameters (same names as in original sklearn class) penalty: l1 # always use penalty l1 C: [0.01, 0.1, 1, 10, 100] # find the optimal value for C # Additional parameter that determines whether to print convergence warnings show_warnings: True # if any of the parameters under LogisticRegression is a list and model_selection_cv is True, # a grid search will be done over the given parameters, using the number of folds specified in model_selection_n_folds, # and the optimal model will be selected model_selection_cv: True model_selection_n_folds: 5 # alternative way to define ML method with default values: my_default_logistic_regression: LogisticRegression """default_parameters={"max_iter":1000,"solver":"saga"}def__init__(self,parameter_grid:dict=None,parameters:dict=None):parameters={**self.default_parameters,**(parametersifparametersisnotNoneelse{})}ifparameter_gridisnotNone:parameter_grid=parameter_gridelse:parameter_grid={"max_iter":[1000]}super(LogisticRegression,self).__init__(parameter_grid=parameter_grid,parameters=parameters)def_get_ml_model(self,cores_for_training:int=2,X=None):params=self._parameters.copy()params["n_jobs"]=cores_for_trainingreturnSklearnLogisticRegression(**params)