Coder Social home page Coder Social logo

logistic-regression's Introduction

=========================================================================== CS 529 - Intro to Machine Learning - Assignment 3 - Logistic Regression

  1. Source code of the project is hosted on github: https://github.com/vamshins/Logistic-Regression

  2. The executable "LogisticRegression.py" is provided in the assignment submission in UNM Learn.

  3. I have programmed in "Python 2.7.9 |Anaconda 2.2.0 (64-bit)|" installed in Windows 8.1. I installed numpy, scikit_learn, scipy, scikits_talkbox. Download all the files attached in UNM Learn submission and store them in "<HOME_DIR>" (This may be any folder on your OS) Copy the data into the "<HOME_DIR>/opihi.cs.uvic.ca" folder. The folder structure looks like - - <HOME_DIR> |--> /LogisticRegression.py |--> /fftdata.txt |--> /classesmatrix.txt |--> /mfccdata.txt |--> /opihi.cs.uvic.ca/sound/genres/ |--> /classical |--> /jazz |--> /country |--> /pop |--> /rock |--> /metal

  4. Execution of the Program: 4.1. Go to Run(Windows) or Terminal(Linux) 4.2. Navigate to <HOME_DIR> 4.3. Run the command -> python LogisticRegression.py - Give -fft or -fft20 or -mfcc -fft -> Generates fft for the data and performs the Logistic Regression with Gradient Ascent and stores the data in fftdata.txt file. If there is no fftdata.txt, the program will generate it. If it is already present, then program will continue with processing the data from text file. -fft20 -> Generates 20 best features per genre for the fft data and performs the Logistic Regression with Gradient Ascent If there is no fftdata.txt, the program will generate it. If it is already present, then program will continue with processing the data from text file. -mfcc -> Generates mfcc for the data and performs the Logistic Regression with Gradient Ascent If there is no mfccdata.txt, the program will generate it. If it is already present, then program will continue with processing the data from text file. - Path to the music data. Eg: <HOME_DIR>\opihi.cs.uvic.ca\sound\genres

  5. Output of the Program for each fold with highest accuracy: ============================================================================================== For FFT: Execution : python LogisticRegression.py -fft <HOME_DIR>\opihi.cs.uvic.ca\sound\genres


	Fold 0 max accuracy : 0.483333333333
	Confusion Matrix : 
	[[ 10.   0.   0.   0.   0.   0.]
	 [  1.   1.   3.   0.   4.   1.]
	 [  2.   0.   7.   0.   1.   0.]
	 [  4.   0.   0.   0.   5.   1.]
	 [  1.   0.   0.   0.   9.   0.]
	 [  1.   3.   0.   0.   4.   2.]]


	Fold 1 max accuracy : 0.566666666667
	Confusion Matrix : 
	[[ 7.  0.  1.  0.  1.  1.]
	 [ 0.  2.  2.  3.  1.  2.]
	 [ 1.  1.  5.  1.  1.  1.]
	 [ 0.  0.  0.  9.  1.  0.]
	 [ 0.  1.  0.  0.  7.  2.]
	 [ 0.  3.  1.  1.  1.  4.]]


	Fold 2 max accuracy : 0.466666666667
	Confusion Matrix : 
	[[  5.   1.   1.   0.   2.   1.]
	 [  0.   2.   1.   0.   6.   1.]
	 [  0.   0.   6.   0.   3.   1.]
	 [  0.   0.   0.   3.   6.   1.]
	 [  0.   0.   0.   0.  10.   0.]
	 [  0.   1.   0.   1.   6.   2.]]


	Fold 3 max accuracy : 0.5
	Confusion Matrix : 
	[[ 9.  0.  0.  0.  0.  1.]
	 [ 4.  2.  0.  2.  2.  0.]
	 [ 1.  0.  4.  3.  1.  1.]
	 [ 0.  0.  0.  6.  3.  1.]
	 [ 1.  0.  0.  2.  6.  1.]
	 [ 1.  0.  0.  3.  3.  3.]]


	Fold 4 max accuracy : 0.466666666667
	Confusion Matrix : 
	[[ 7.  0.  1.  0.  1.  1.]
	 [ 0.  4.  1.  0.  4.  1.]
	 [ 2.  0.  4.  0.  1.  3.]
	 [ 1.  1.  0.  1.  2.  5.]
	 [ 0.  0.  0.  1.  6.  3.]
	 [ 0.  3.  0.  0.  1.  6.]]


	Fold 5 max accuracy : 0.5
	Confusion Matrix : 
	[[ 8.  0.  1.  0.  1.  0.]
	 [ 1.  1.  0.  6.  1.  1.]
	 [ 1.  0.  4.  3.  1.  1.]
	 [ 0.  0.  0.  7.  2.  1.]
	 [ 0.  1.  0.  2.  7.  0.]
	 [ 1.  1.  0.  4.  1.  3.]]


	Fold 6 max accuracy : 0.583333333333
	Confusion Matrix : 
	[[ 7.  0.  0.  2.  1.  0.]
	 [ 0.  3.  0.  2.  3.  2.]
	 [ 0.  1.  3.  2.  0.  4.]
	 [ 0.  0.  0.  8.  2.  0.]
	 [ 0.  0.  0.  2.  8.  0.]
	 [ 0.  0.  1.  2.  1.  6.]]


	Fold 7 max accuracy : 0.55
	Confusion Matrix : 
	[[ 8.  0.  2.  0.  0.  0.]
	 [ 0.  5.  0.  0.  3.  2.]
	 [ 1.  0.  5.  1.  1.  2.]
	 [ 0.  0.  1.  4.  4.  1.]
	 [ 0.  1.  0.  0.  8.  1.]
	 [ 0.  0.  1.  2.  4.  3.]]


	Fold 8 max accuracy : 0.566666666667
	Confusion Matrix : 
	[[  8.   0.   0.   0.   1.   1.]
	 [  0.   6.   1.   0.   2.   1.]
	 [  0.   2.   4.   0.   0.   4.]
	 [  0.   1.   0.   1.   6.   2.]
	 [  0.   0.   0.   0.  10.   0.]
	 [  0.   2.   0.   0.   3.   5.]]


	Fold 9 max accuracy : 0.516666666667
	Confusion Matrix : 
	[[ 9.  0.  1.  0.  0.  0.]
	 [ 0.  5.  1.  0.  0.  4.]
	 [ 2.  0.  5.  0.  0.  3.]
	 [ 0.  1.  0.  3.  2.  4.]
	 [ 0.  1.  1.  2.  5.  1.]
	 [ 0.  4.  1.  1.  0.  4.]]
	Avg of all folds accuracies : 0.52

============================================================================================== For FFT20: Execution : python LogisticRegression.py -fft20 <HOME_DIR>\opihi.cs.uvic.ca\sound\genres

	Fold 0 max accuracy : 0.633333333333
	Confusion Matrix : 
	[[ 9.  0.  0.  0.  1.  0.]
	 [ 2.  5.  2.  1.  0.  0.]
	 [ 2.  2.  5.  0.  1.  0.]
	 [ 1.  0.  0.  9.  0.  0.]
	 [ 0.  1.  2.  2.  5.  0.]
	 [ 2.  1.  0.  1.  1.  5.]]


	Fold 1 max accuracy : 0.616666666667
	Confusion Matrix : 
	[[ 7.  1.  2.  0.  0.  0.]
	 [ 3.  5.  2.  0.  0.  0.]
	 [ 0.  4.  6.  0.  0.  0.]
	 [ 0.  0.  1.  9.  0.  0.]
	 [ 1.  2.  2.  0.  5.  0.]
	 [ 0.  3.  1.  1.  0.  5.]]


	Fold 2 max accuracy : 0.6
	Confusion Matrix : 
	[[ 7.  2.  0.  0.  0.  1.]
	 [ 0.  6.  1.  0.  3.  0.]
	 [ 1.  1.  7.  0.  1.  0.]
	 [ 1.  0.  2.  5.  2.  0.]
	 [ 0.  2.  1.  0.  5.  2.]
	 [ 1.  1.  0.  2.  0.  6.]]


	Fold 3 max accuracy : 0.6
	Confusion Matrix : 
	[[ 8.  0.  1.  0.  1.  0.]
	 [ 4.  4.  1.  0.  1.  0.]
	 [ 1.  3.  4.  0.  2.  0.]
	 [ 1.  1.  3.  5.  0.  0.]
	 [ 0.  0.  1.  0.  9.  0.]
	 [ 1.  1.  1.  0.  1.  6.]]


	Fold 4 max accuracy : 0.583333333333
	Confusion Matrix : 
	[[ 9.  0.  1.  0.  0.  0.]
	 [ 0.  6.  3.  0.  1.  0.]
	 [ 3.  2.  4.  0.  0.  1.]
	 [ 2.  0.  3.  5.  0.  0.]
	 [ 1.  0.  5.  0.  3.  1.]
	 [ 1.  0.  1.  0.  0.  8.]]


	Fold 5 max accuracy : 0.616666666667
	Confusion Matrix : 
	[[ 8.  0.  2.  0.  0.  0.]
	 [ 1.  4.  2.  2.  1.  0.]
	 [ 1.  1.  7.  1.  0.  0.]
	 [ 2.  0.  1.  7.  0.  0.]
	 [ 1.  1.  3.  0.  4.  1.]
	 [ 3.  0.  0.  0.  0.  7.]]


	Fold 6 max accuracy : 0.616666666667
	Confusion Matrix : 
	[[ 6.  0.  4.  0.  0.  0.]
	 [ 3.  6.  1.  0.  0.  0.]
	 [ 2.  2.  5.  1.  0.  0.]
	 [ 1.  0.  4.  5.  0.  0.]
	 [ 0.  1.  2.  0.  7.  0.]
	 [ 0.  0.  2.  0.  0.  8.]]


	Fold 7 max accuracy : 0.633333333333
	Confusion Matrix : 
	[[ 8.  0.  1.  0.  1.  0.]
	 [ 0.  6.  2.  0.  2.  0.]
	 [ 3.  0.  6.  0.  1.  0.]
	 [ 0.  2.  2.  6.  0.  0.]
	 [ 1.  1.  3.  0.  5.  0.]
	 [ 1.  0.  0.  0.  2.  7.]]


	Fold 8 max accuracy : 0.666666666667
	Confusion Matrix : 
	[[ 8.  0.  2.  0.  0.  0.]
	 [ 2.  5.  3.  0.  0.  0.]
	 [ 1.  0.  8.  0.  1.  0.]
	 [ 1.  0.  2.  7.  0.  0.]
	 [ 0.  0.  4.  0.  6.  0.]
	 [ 1.  1.  2.  0.  0.  6.]]


	Fold 9 max accuracy : 0.666666666667
	Confusion Matrix : 
	[[ 8.  0.  1.  0.  0.  1.]
	 [ 0.  5.  5.  0.  0.  0.]
	 [ 0.  1.  8.  0.  1.  0.]
	 [ 0.  1.  0.  8.  1.  0.]
	 [ 0.  2.  2.  0.  5.  1.]
	 [ 0.  2.  2.  0.  0.  6.]]
	Avg of all folds accuracies : 0.623333333333

============================================================================================== For MFCC: Execution : python LogisticRegression.py -mfcc <HOME_DIR>\opihi.cs.uvic.ca\sound\genres

	Fold 0 max accuracy : 0.733333333333
	Confusion Matrix : 
	[[ 10.   0.   0.   0.   0.   0.]
	 [  0.   6.   0.   1.   1.   2.]
	 [  3.   0.   6.   1.   0.   0.]
	 [  0.   1.   0.   9.   0.   0.]
	 [  0.   1.   0.   0.   8.   1.]
	 [  0.   0.   1.   4.   0.   5.]]


	Fold 1 max accuracy : 0.633333333333
	Confusion Matrix : 
	[[ 8.  1.  0.  1.  0.  0.]
	 [ 0.  5.  3.  0.  2.  0.]
	 [ 2.  3.  2.  2.  1.  0.]
	 [ 0.  0.  0.  9.  0.  1.]
	 [ 1.  1.  0.  0.  8.  0.]
	 [ 0.  4.  0.  0.  0.  6.]]


	Fold 2 max accuracy : 0.666666666667
	Confusion Matrix : 
	[[ 8.  0.  0.  0.  0.  2.]
	 [ 0.  4.  3.  1.  1.  1.]
	 [ 2.  0.  7.  0.  1.  0.]
	 [ 0.  0.  1.  9.  0.  0.]
	 [ 0.  1.  0.  0.  8.  1.]
	 [ 0.  1.  0.  4.  1.  4.]]


	Fold 3 max accuracy : 0.683333333333
	Confusion Matrix : 
	[[  8.   1.   1.   0.   0.   0.]
	 [  0.   6.   0.   0.   1.   3.]
	 [  1.   3.   5.   0.   0.   1.]
	 [  0.   0.   0.  10.   0.   0.]
	 [  0.   2.   0.   0.   7.   1.]
	 [  0.   2.   0.   1.   2.   5.]]


	Fold 4 max accuracy : 0.666666666667
	Confusion Matrix : 
	[[  7.   1.   2.   0.   0.   0.]
	 [  1.   4.   2.   0.   2.   1.]
	 [  2.   2.   5.   0.   0.   1.]
	 [  0.   0.   0.  10.   0.   0.]
	 [  0.   0.   0.   0.   9.   1.]
	 [  1.   0.   0.   4.   0.   5.]]


	Fold 5 max accuracy : 0.683333333333
	Confusion Matrix : 
	[[ 9.  0.  1.  0.  0.  0.]
	 [ 0.  6.  2.  0.  1.  1.]
	 [ 2.  2.  5.  0.  0.  1.]
	 [ 0.  1.  0.  9.  0.  0.]
	 [ 0.  0.  0.  0.  9.  1.]
	 [ 1.  1.  3.  2.  0.  3.]]


	Fold 6 max accuracy : 0.716666666667
	Confusion Matrix : 
	[[  8.   1.   1.   0.   0.   0.]
	 [  2.   5.   3.   0.   0.   0.]
	 [  3.   0.   4.   0.   2.   1.]
	 [  0.   0.   1.   9.   0.   0.]
	 [  0.   0.   0.   0.  10.   0.]
	 [  0.   0.   1.   2.   0.   7.]]


	Fold 7 max accuracy : 0.783333333333
	Confusion Matrix : 
	[[  8.   0.   2.   0.   0.   0.]
	 [  1.   7.   1.   0.   0.   1.]
	 [  0.   1.   8.   0.   1.   0.]
	 [  0.   0.   1.   9.   0.   0.]
	 [  0.   0.   0.   0.  10.   0.]
	 [  0.   2.   0.   3.   0.   5.]]


	Fold 8 max accuracy : 0.7
	Confusion Matrix : 
	[[  9.   0.   0.   1.   0.   0.]
	 [  2.   6.   0.   1.   0.   1.]
	 [  3.   1.   5.   0.   1.   0.]
	 [  0.   0.   0.  10.   0.   0.]
	 [  0.   0.   0.   0.  10.   0.]
	 [  1.   1.   0.   5.   1.   2.]]


	Fold 9 max accuracy : 0.733333333333
	Confusion Matrix : 
	[[  8.   0.   1.   0.   0.   1.]
	 [  1.   7.   0.   1.   1.   0.]
	 [  2.   3.   5.   0.   0.   0.]
	 [  0.   0.   0.  10.   0.   0.]
	 [  0.   1.   0.   0.   8.   1.]
	 [  0.   0.   2.   0.   2.   6.]]
	Avg of all folds accuracies : 0.7

logistic-regression's People

Contributors

vamshins avatar

Watchers

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