Skip to content

Instantly share code, notes, and snippets.

@nithyadurai87
Last active April 4, 2019 06:10
Show Gist options
  • Save nithyadurai87/9d7cc99cc4ae18a3707cc76f8711193b to your computer and use it in GitHub Desktop.
Save nithyadurai87/9d7cc99cc4ae18a3707cc76f8711193b to your computer and use it in GitHub Desktop.
import numpy as np
import matplotlib.pyplot as plt
from sklearn import svm
import pandas as pd
from sklearn.metrics import accuracy_score
from sklearn.model_selection import train_test_split
from sklearn.svm import SVC
from sklearn.metrics import classification_report, confusion_matrix
from sklearn.linear_model.logistic import LogisticRegression
from matplotlib.colors import ListedColormap
df = pd.read_csv('./flowers.csv')
X = df[list(df.columns)[:-1]]
y = df['Flower']
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state = 0)
logistic = LogisticRegression()
logistic.fit(X_train, y_train)
y_pred = logistic.predict(X_test)
print ('Accuracy-logistic:', accuracy_score(y_test, y_pred))
gaussian = SVC(kernel='rbf')
gaussian.fit(X_train, y_train)
y_pred = gaussian.predict(X_test)
print ('Accuracy-svm:', accuracy_score(y_test, y_pred))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment