help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Proper usage of logistic_regression Octave function


From: Daniel Korzekwa
Subject: Proper usage of logistic_regression Octave function
Date: Wed, 13 Jun 2012 23:57:47 +0100

Hi,

I'm using logistic_regression function from Octave to obtain theta and beta parameters and to make predictions later on. Is there any better way, than the one I'm giving below to learn the logistic model and make predictions? I'm thinking about a function that takes theta and beta parameters and returns prediction values as well as prediction accuracy (ratio of predicted records, precision, recall, etc.). Is there a logistic function that takes nominal features as one of the input features?

data.csv file:
feature_1, feature_2,predicted_feature
0 0 0
0 1 1
1 0 1
1 1 1
1 1 0
1 1 1
0 0 0
0 0 1
1 0 0
1 0 1

Step 1) X = load('data.csv') //Load input data into matrix X.

Step 2) [theta beta dev] = logistic_regression(X(:,3),X(:,1:2),1) // Fit input data into logistic model. Output:
theta =  0.23970
beta =

   0.47939
   0.98780

dev =  12.696 (-2* log likelihood)

Step 3) [X 1 ./ (1 .+ exp(-([ones(size(X,1),1) X(:,1:2)]* [-theta ; beta] )))] //Return X matrix with additional column (on the right) with predicted values:

 0.00000   0.00000   0.00000   0.44036
 0.00000   1.00000   1.00000   0.67876
 1.00000   0.00000   1.00000   0.55964
 1.00000   1.00000   1.00000   0.77338
 1.00000   1.00000   0.00000   0.77338
 1.00000   1.00000   1.00000   0.77338
 0.00000   0.00000   0.00000   0.44036
 0.00000   0.00000   1.00000   0.44036
 1.00000   0.00000   0.00000   0.55964
 1.00000   0.00000   1.00000   0.55964

Regards
Daniel

reply via email to

[Prev in Thread] Current Thread [Next in Thread]