Git Product home page Git Product logo

anshpg / malignant-or-benign-a-logistic-regression-study Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 294 KB

I have been working on a logistic regression project from scratch, without relying on external libraries like scikit-learn, to predict whether a patient has breast cancer or not. Typically, breast cancer is classified into two categories: malignant (positive) and benign (negative).

License: MIT License

Jupyter Notebook 93.38% Python 6.62%
andrew-ng classification logistic-regression machine-learning numpy pyhton

malignant-or-benign-a-logistic-regression-study's Introduction

Malignant-or-Benign-A-Logistic-Regression-Study

LR_train

I have been working on a logistic regression project from scratch, without relying on external libraries like scikit-learn, to predict whether a patient has breast cancer or not. Typically, breast cancer is classified into two categories: malignant (positive) and benign (negative).

Project Overview

Data Acquisition

I obtained the data from Kaggle's Breast Cancer Wisconsin (Diagnostic) Data Set.

Project Phases

The project is divided into two parts:

  1. Algorithm Development: Creating the logistic regression algorithm from scratch to derive the equation by finding parameters for each feature.
  2. Decision Boundary Plotting: Visualizing the decision boundary on a scatter plot to help validate the direction and performance of the algorithm.

Feature Selection

To simplify the decision boundary plotting, I selected two features: 'radius' and 'smoothness'. This choice allows us to plot a 2D decision boundary. However, the algorithm is designed to handle any number of features for improved results. The features are also expanded into different polynomial degrees to enhance the model's performance.

LR_test

Key Processes

  1. Sigmoid Function: 1/(1+e^-z)

    The sigmoid function returns a value between 0 and 1. The greater the value of (z), the closer the output will be to 1, where z = wx + b (with w and x as vectors, and x representing the features).

  2. Loss Function: loss = -y(i).log(f(z)) - (1 - y(i)) .log(1 - f(z))

    This loss function is used to compute the cost function.

formula_1 forrmula_2

Observations

  • Degree: Using a polynomial degree of 5 for the two features results in a total of 10 features. Higher degrees led to overfitting.
  • Iterations: More than 1000 iterations are unnecessary as the cost reduction becomes minimal beyond this point. iterations
  • Learning Rate ((\alpha)): Set to 0.01. Be cautious with higher values as it may lead to overshooting.

COST_VS_ITERATION_100K overshooting_alpha

Implementation

I have structured the algorithm like a package. You only need to specify the features you want to use, the polynomial degree, and the number of iterations. The algorithm will handle everything else, including generating the appropriate parameter values and plotting the decision boundary.

Minimal Use of External Libraries

To ensure a better understanding, I have kept the use of external libraries to a minimum, primarily utilizing NumPy.

Repository

The repository, maintained by Anshuman Pattnaik, is publicly available for use.

Happy coding!

malignant-or-benign-a-logistic-regression-study's People

Contributors

anshpg 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.