Coder Social home page Coder Social logo

logistic-regression-from-scratch's Introduction

Logistic-Regression-from-scratch

STEPS TO RUN THE CODE**** All of the required code blocks are included in the notebook and are generally sorted in a way to be run sequentially. This readme explains the flow of the code in the notebook:

1.Mount google drive 2.Import necessary libraries 3.Run both Class Definitions: Log_class and k_fold

A.Bankrupcy Dataset

A.1 Running Logistic regression on the entire dataset:
1.import data and split into xtrain,ytrain,xtest,ytest
2.OPTIONAL: Add polynomial features(square,cube etc. of features)
3.OPTIONAL: Scale the data using Z score scaling . This is Required to run if adding polynomial features in step 2.
4.Instance the model using model=Log_Class(xtrain,xtest,ytrain,ytest,alpha) where alpha=learning rate
5.run the fit method : model.fit(err_threshold) where err_threshold is the error threshold. Also note runtime
6.run the model.predict(threshold=0.5) where threshold is the probability threshold
7.run model.accu_eval() to print out the metrics

A.2 Running K-fold cross validation:
1.import data and split into xtrain,ytrain,xtest,ytest
2.OPTIONAL: Add polynomial features(square,cube etc. of features)
3.Run the k fold code block. Its located after the code for running model.accu_eval() in step 7 of A.1.it has the following parameters:
	features,target:your data  
	k : value of k(=10 for 10 fold cross validation), 
	alpha : learning rate  
	err_threshold: error threshold, 
	prob_threshold=0.5 :probability threshold,
	scaler=None : input an instance of a scikit learn scaling function like MinMaxScaler() or StandardScaler().

B.Hepatitis Dataset

B.1 Running Logistic regression on the entire dataset:
1.import data and split into xtrain,ytrain,xtest,ytest
2.OPTIONAL: Add polynomial features(square,cube etc. of features)
3.OPTIONAL: Scale either only continuous features of original dataset or scale complete dataset. scale complete dataset if adding polynomial features
4.Instance the model using model=Log_Class(xtrain,xtest,ytrain,ytest,alpha) where alpha=learning rate
5.run the fit method : model.fit(err_threshold) where err_threshold is the error threshold. Also note runtime
6.run the model.predict(threshold=0.5) where threshold is the probability threshold
7.run model.accu_eval() to print out the metrics

A.2 Running K-fold cross validation:
1.import data and split into xtrain,ytrain,xtest,ytest
2.OPTIONAL: Add polynomial features(square,cube etc. of features)
3.Run the k fold code block. Its located after the code for running model.accu_eval() in step 7 of B.1.it has the following parameters:
	features,target:your data  
	k : value of k(=10 for 10 fold cross validation), 
	alpha : learning rate  
	err_threshold: error threshold, 
	prob_threshold=0.5 :probability threshold,
	scaler=None : input an instance of a scikit learn scaling function like MinMaxScaler() or StandardScaler().

logistic-regression-from-scratch's People

Contributors

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