- Overview
- What is Logistic Regression?
- Technical Aspect
- Usage
- Run the app locally
- Project Directory Structure
- Technologies Used
- Contributions / Bug
- License
Logistic Regression Playground is an educational sandbox for those who want to understand Logistic Regression from a more intuitive perspective.
The Logistic Regression model used in this app is implemented from scratch in Python.
Logistic Regression is one of the most common machine learning algorithms for classification. It a statistical model that uses a logistic function to model a binary dependent variable. In essence, it predicts the probability of an observation belonging to a certain class or label. For instance, is this a cat photo or a dog photo?
The mathematics and code implementation is covered in this Medium article.
The model accepts the following params:
learning_rate
: The tuning parameter for the optimization algorithm (here, Gradient Descent) that determines the step size at each iteration while moving toward a minimum of the cost function.max_iter
: Maximum number of iterations taken for the optimization algorithm to convergepenalty
: None or 'l2', Option to perform L2 regularization.C
: Inverse of regularization strength; must be a positive float. Smaller values specify stronger regularization.tolerance
: Value indicating the weight change between epochs in which gradient descent should terminated.
The model has the following exposed methods:
predict()
: Predicts class labels for an observationpredict_proba()
: Predicts the estimate for a classget_params()
: Returns the coefficients and intercept
Get the code for my custom implementation of Logistic Regression from here
# fit the data
clf = LogisticRegression()
clf.fit(X,y)
# predict probabilities
probs = clf.predict_proba(x_test)
# predict class labels
preds = clf.predict(x_test)
Results on a dummy dataset:
├── static # contains files for HTML
│ ├── bootstrap
│ ├── css
│ └── js
├── templates # the main web page
│ └── index.html
├── utils
│ ├── models
| | └── logreg_classifier.py # contains the classifier codes
│ ├── configs.py
│ └── helper_functions.py
├── LICENSE
├── Procfile
├── README.md
├── main.py
└── requirements.txt
First, clone this project to your local machine:
git clone https://github.com/arya46/play-with-LR.git
# change the working directory
cd play-with-LR
Then install the required packages and libraries. Run the following command:
pip install -r requirements.txt
Everything is set now. Use the following command to launch the app:
python main.py
The app will run on http://localhost:8080/
in the browser.
- Programming Language: Python
- ML Tools/Libraries: Numpy, Scipy
- Web Tools/Libraries: Flask, HTML
If you want to contribute to this project, or want to report a bug, kindly open an issue here.