Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. import pandas as pd
  2. import numpy as np
  3. from sklearn import cross_validation
  4. from sklearn.linear_model import LogisticRegression
  5.  
  6. df = pd.read_csv("iris.csv")
  7.  
  8. df = df[["Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width", "Species"]]
  9.  
  10. X = np.array(df.drop(["Species"],1))
  11. y = np.array(df["Species"])
  12.  
  13. X_train, X_test, y_train, y_test = cross_validation.train_test_split(X,y,test_size=0.2)
  14.  
  15. clf = LogisticRegression()
  16. clf.fit(X_train, y_train)
  17. conf = clf.score(X_test, y_test)
  18. print(conf)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement