application_vnd.jupyter.stderr_output_2.png text_plain_output_1.png
from sklearn.cross_validation import StratifiedKFold

from sklearn.linear_model import LogisticRegression

from sklearn.metrics import accuracy_score,make_scorer

from sklearn.model_selection import train_test_split, GridSearchCV

from sklearn.neighbors import KNeighborsClassifier

from sklearn.preprocessing import LabelEncoder

from sklearn.svm import SVC

from sklearn.tree import DecisionTreeClassifier

from xgboost import XGBClassifier,plot_importance

import numpy as np # linear algebra

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

dataset = pd.read_csv('../input/Iris.csv')
lb_make = LabelEncoder()
dataset['Species'] = dataset['Species'].astype('category')
dataset['SepalRatio'] = np.divide(dataset['SepalLengthCm'], dataset['SepalWidthCm'])
dataset['PetalRatio'] = np.divide(dataset['PetalLengthCm'], dataset['PetalWidthCm'])
X_all = dataset[['Id', 'SepalLengthCm', 'SepalWidthCm', 'PetalLengthCm', 'PetalWidthCm', 'SepalRatio', 'PetalRatio']]
y_all = lb_make.fit_transform(dataset['Species'])
num_test = 0.2
X_train, X_test, y_train, y_test = train_test_split(X_all, y_all, test_size=num_test, random_state=88)
acc_scorer = make_scorer(accuracy_score)

from sklearn.linear_model import LogisticRegression
clf = LogisticRegression()
parametersLR = {'C': [0.001, 0.003, 0.01, 0.03, 0.1, 0.3, 1]}
LRmodel = GridSearchCV(clf, parametersLR, scoring=acc_scorer)
_ = LRmodel.fit(X_all, y_all)

from sklearn.neighbors import KNeighborsClassifier
clf = KNeighborsClassifier()
parametersKN = {'n_neighbors': [1, 2, 4, 8, 16]}
KNmodel = GridSearchCV(clf, parametersKN, scoring=acc_scorer)
_ = KNmodel.fit(X_all, y_all)

from sklearn.tree import DecisionTreeClassifier
clf = DecisionTreeClassifier()
parametersDT = {'criterion': ['gini', 'entropy'], 'max_depth': [1, 2, 3, 4]}
DTmodel = GridSearchCV(clf, parametersDT, scoring=acc_scorer)
_ = DTmodel.fit(X_all, y_all)

from sklearn.svm import SVC
clf = SVC()
parametersSV = {'C': [0.001, 0.003, 0.01, 0.03, 0.1, 0.3, 1], 'kernel': ['linear', 'poly', 'rbf', 'sigmoid']}
SVmodel = GridSearchCV(clf, parametersSV, scoring=acc_scorer)
_ = SVmodel.fit(X_all, y_all)

from xgboost import XGBClassifier, plot_importance
clf = XGBClassifier()
parametersXG = {'n_estimators': [50, 100, 150, 200], 'max_depth': [2, 4, 6, 8]}
kfold = StratifiedKFold(y_all, n_folds=10, shuffle=True, random_state=42)
XGmodel = GridSearchCV(clf, parametersXG, scoring=acc_scorer, n_jobs=-1, cv=kfold, verbose=1)
_ = XGmodel.fit(X_all, y_all)