Advertisement
Guest User

Untitled

a guest
Jun 28th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. In[73]: data.head(20)
  2. Out[73]:
  3.  
  4. admit gre gpa rank_2 rank_3 rank_4
  5. 0 0 380 3.61 0.0 1.0 0.0
  6. 1 1 660 3.67 0.0 1.0 0.0
  7. 2 1 800 4.00 0.0 0.0 0.0
  8. 3 1 640 3.19 0.0 0.0 1.0
  9. 4 0 520 2.93 0.0 0.0 1.0
  10. 5 1 760 3.00 1.0 0.0 0.0
  11. 6 1 560 2.98 0.0 0.0 0.0
  12.  
  13. y = data['admit']
  14. x = data[data.columns[1:]]
  15.  
  16. from sklearn.cross_validation import train_test_split
  17. xtrain,xtest,ytrain,ytest = train_test_split(x,y,random_state=2)
  18.  
  19. ytrain=np.ravel(ytrain)
  20.  
  21. #modelling
  22. clf = LogisticRegression(penalty='l2')
  23. clf.fit(xtrain,ytrain)
  24. ypred = clf.predict(xtest)
  25.  
  26. In[77]: #checking the classification accuracy
  27. accuracy_score(ytest,ypred)
  28. Out[77]: 0.66000000000000003
  29.  
  30. In[78]: #confusion metrix...
  31. from sklearn.metrics import confusion_matrix
  32. confusion_matrix(ytest,ypred)
  33.  
  34. Out[78]:
  35. array([[62, 1],
  36. [33, 4]])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement