Skip to content

Instantly share code, notes, and snippets.

@rohitdholakia
Created May 18, 2013 20:51
Show Gist options
  • Save rohitdholakia/5605752 to your computer and use it in GitHub Desktop.
Save rohitdholakia/5605752 to your computer and use it in GitHub Desktop.
Logit regression example
from sklearn import linear_model
from FeatureUtils import *
import numpy as np
(features,output) = getXy(sys.argv[1])
clf = linear_model.LogisticRegression(penalty='l1')
clf.fit(features,output)
print clf.coef_
(testFeatures, testOutput) = getXy(sys.argv[2])
print 'Error is ',np.mean((clf.predict(testFeatures) - testOutput) ** 2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment