Git Product home page Git Product logo

play-with-lr's Introduction

Logistic Regression Playground

Live version here!

Table of Contents

Overview

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.

What is Logistic Regression?

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?

Technical Aspect

The mathematics and code implementation is covered in this Medium article.

Parameters:

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 converge
  • penalty : 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.

Methods:

The model has the following exposed methods:

  • predict() : Predicts class labels for an observation
  • predict_proba() : Predicts the estimate for a class
  • get_params() : Returns the coefficients and intercept

Usage

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:

Project Directory Structure

├── 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

Run the app locally

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.

Technologies Used

  • Programming Language: Python
  • ML Tools/Libraries: Numpy, Scipy
  • Web Tools/Libraries: Flask, HTML

Contributions / Bug

If you want to contribute to this project, or want to report a bug, kindly open an issue here.

License

LICENSE

play-with-lr's People

Contributors

arya46 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.