logistic-reg 0.0.6
Logistic Regression module for classification and regression cases.
Requires Python: >=3.6

# Logistic Regression Module (logistic-reg)

In statistics, the logistic model (or logit model) is used to model the probability of a certain class or event existing such as pass/fail, win/lose, alive/dead or healthy/sick. This can be extended to model several classes of events such as determining whether an image contains a cat, dog, lion, etc. Each object being detected in the image would be assigned a probability between 0 and 1, with a sum of one.

Logistic regression is a statistical model that in its basic form uses a logistic function to model a binary dependent variable, although many more complex extensions exist. In regression analysis, logistic regression is estimating the parameters of a logistic model (a form of binary regression). Mathematically, a binary logistic model has a dependent variable with two possible values, such as pass/fail which is represented by an indicator variable, where the two values are labeled "0" and "1". In the logistic model, the log-odds (the logarithm of the odds) for the value labeled "1" is a linear combination of one or more independent variables ("predictors"); the independent variables can each be a binary variable (two classes, coded by an indicator variable) or a continuous variable (any real value). The corresponding probability of the value labeled "1" can vary between 0 (certainly the value "0") and 1 (certainly the value "1"), hence the labeling; the function that converts log-odds to probability is the logistic function, hence the name. The unit of measurement for the log-odds scale is called a logit, from logistic unit, hence the alternative names. Analogous models with a different sigmoid function instead of the logistic function can also be used, such as the probit model; the defining characteristic of the logistic model is that increasing one of the independent variables multiplicatively scales the odds of the given outcome at a constant rate, with each independent variable having its own parameter; for a binary dependent variable this generalizes the odds ratio.

In a binary logistic regression model, the dependent variable has two levels (categorical). Outputs with more than two values are modeled by multinomial logistic regression and, if the multiple categories are ordered, by ordinal logistic regression (for example the proportional odds ordinal logistic model). The logistic regression model itself simply models probability of output in terms of input and does not perform statistical classification (it is not a classifier), though it can be used to make a classifier, for instance by choosing a cutoff value and classifying inputs with probability greater than the cutoff as one class, below the cutoff as the other; this is a common way to make a binary classifier. The coefficients are generally not computed by a closed-form expression, unlike linear least squares; see Â§ Model fitting. The logistic regression as a general statistical model was originally developed and popularized primarily by Joseph Berkson, beginning in Berkson (1944), where he coined "logit"; see Â§ History. ([Wikipedia Article about Logistic Regression](https://en.wikipedia.org/wiki/Logistic_regression))


### Installation
```
pip install logistic-reg
```

### Sample Usage
```python
from logistic_reg.model import LogisticRegression
from logistic_reg.functions import Activations


# construct the model
model = LogisticRegression(Activations.sigmoid)

# train the model with data - returns "Model" object
trained = model.train(images = my_images, labels = my_labels, epochs = 10)
```

### Using only "forward-propagation" and "back-propagation" functions
```python
from logistic_reg.model import LogisticRegression
from logistic_reg.functions import Activations

# construct the model
model = LogisticRegression(Activation.sigmoid)

# use forward-propagation - returns activated one step forward-propagation
activated = model.forward(array = image_array, label = image_label, 
	weights = model_weights, bias = model_bias)

# use backpropagation - returns delta of weights and delta of bias
# for using at the process of updating weights
# takes activated value from "forward-propagation"
dw, db = model.backprop(array = image_array, label = image_label, activated = activated)
```