Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- In[73]: data.head(20)
- Out[73]:
- admit gre gpa rank_2 rank_3 rank_4
- 0 0 380 3.61 0.0 1.0 0.0
- 1 1 660 3.67 0.0 1.0 0.0
- 2 1 800 4.00 0.0 0.0 0.0
- 3 1 640 3.19 0.0 0.0 1.0
- 4 0 520 2.93 0.0 0.0 1.0
- 5 1 760 3.00 1.0 0.0 0.0
- 6 1 560 2.98 0.0 0.0 0.0
- y = data['admit']
- x = data[data.columns[1:]]
- from sklearn.cross_validation import train_test_split
- xtrain,xtest,ytrain,ytest = train_test_split(x,y,random_state=2)
- ytrain=np.ravel(ytrain)
- #modelling
- clf = LogisticRegression(penalty='l2')
- clf.fit(xtrain,ytrain)
- ypred = clf.predict(xtest)
- In[77]: #checking the classification accuracy
- accuracy_score(ytest,ypred)
- Out[77]: 0.66000000000000003
- In[78]: #confusion metrix...
- from sklearn.metrics import confusion_matrix
- confusion_matrix(ytest,ypred)
- Out[78]:
- array([[62, 1],
- [33, 4]])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement