## SK-Learn Logistic Regression

Logistic Regression is a well established statistical classification technique.

### Parameters

**penalty**= string defining the logistic regression penality, default is "l2" but can also be "l1"

### Attributes

**weights**: dictionary that gets populated with weights and labels for statistical use after the model is trained and the define_weights method is fired.**intercept**: The model intercept, defined after the model is trained and the define_weights method is fired**penalty**: Penality used in the model**best_penalty**: initially set to zero, this is the penality that gives the best accuracy score. This is defined when the grid_search function is fired**model_title**: Set to "Logistic Regression" for deployment package

### Methods

Logistic regression has the following methods:

#### grid_search

This method takes no arguements. When fired the log model is trained with "l1" and "l2" penalities. The accuracy scores are compared. The penality with the best accuracy score is defines the **best_penalty** attributes. Data needs to be defined with an **outcome_pointer** before this method can be fired. For information on assigning data and defining the outcome_pointer please look at the training documentation.

#### define_weights

This method takes no arguements. It gets the weights of the trained model and populates the **weights** attribute with labels and weights. Please understand training before firing this function.

### Practical Example

Below is a practical example of training a logistic regression model

```
from deployml.sklearn import LogisticRegressionBase
# We define the model
log = LogisticRegressionBase()
# We define the data (pandas data frame)
log.data = input_data
# We define the key of the column we are trying to predict
log.outcome_pointer = 'attended'
# We then use grid search to find out the best penalty
log.grid_search()
# We then define the penalty with the best penalty
log.define_penalty(penalty=log.best_penalty)
# Now we have the best penalty, we produce a training curve and show it
# with scaled data using a standard scaler
log.plot_learning_curve(scale=True, batch_size=100)
log.show_learning_curve()
# We then print out the precision, recall and F-1 score
log.evaluate_outcome()
# And show the ROC curve
log.show_roc_curve()
```

## Not Enough?

It's understandable that you might want a more custom model. Whilst we are always working on making Deploy-ML more versatile, you can define your own SK-Learn model and import it into the Deploy-ML learning and packaging framework!