#from sklearn.svm import SVC #from sklearn.linear_model import LogisticRegression from sklearn.metrics import classification_report from sklearn.metrics import accuracy_score from sklearn import cross_validation from sklearn.pipeline import Pipeline from temporalPivot import playByPlay from sklearn.preprocessing import MinMaxScaler from sklearn import linear_model pbp = playByPlay() ''' pbp.select("KC",2010) preppedData = pbp.temporal(20) logistic = linear_model.LogisticRegression(C=100, solver='newton-cg') pipeline = Pipeline([('min/max scaler',MinMaxScaler(feature_range=(0.0, 1.0))), ('logistic',logistic)]) print "Classifier created" print "Train Classification report:" pipeline.fit(preppedData['train'],preppedData['label']) y_true, y_pred = preppedData['label'], pipeline.predict(preppedData['train']) print classification_report(y_true,y_pred) print accuracy_score(y_true,y_pred) print "CrossValidation:" scores = cross_validation.cross_val_score(pipeline,preppedData['train'],preppedData['label'],cv=10)
import pickle import math from sknn.mlp import Classifier, Layer from sknn import ae from sklearn.pipeline import Pipeline from temporalPivot import playByPlay from sklearn.preprocessing import MinMaxScaler from sklearn.metrics import accuracy_score from sklearn.grid_search import GridSearchCV from sklearn.metrics import classification_report pbp = playByPlay() #instantiate object pbp.select("CAR", 2014) #select team and year, this is done in place preppedData = pbp.temporal(20) #this will return the training and test data #as dict preppedData['train'], preppedData['label'] def neuralCombo(data): pipeline = Pipeline([('min/max scaler', MinMaxScaler(feature_range=(0.0, 1.0))), ('nn', Classifier(layers=[ Layer("Rectifier", units=100), Layer("Sigmoid", units=100), Layer("Softmax") ], n_iter=25))]) learningRate = [0.05, 0.005, 0.001, 0.0001, 0.00001] units = [5, 50, 100, 200] type = [
# -*- coding: utf-8 -*- """ Created on Sat Dec 12 11:49:55 2015 @author: Adithya """ from sklearn.svm import SVC from sklearn.metrics import classification_report from sklearn.metrics import accuracy_score from sklearn import cross_validation from sklearn.pipeline import Pipeline from temporalPivot import playByPlay from sklearn.preprocessing import MinMaxScaler pbp = playByPlay() pbp.select("CAR",2014) preppedData = pbp.temporal(20) pipeline = Pipeline([('min/max scaler',MinMaxScaler(feature_range=(0.0, 1.0))), ('svm',SVC(kernel='poly',C=100,degree=5))]) print "Classifier created" print "Train Classification report:" pipeline.fit(preppedData['train'],preppedData['label']) y_true, y_pred = preppedData['label'], pipeline.predict(preppedData['train']) print classification_report(y_true,y_pred) print accuracy_score(y_true,y_pred) print "CrossValidation:"
import pickle import math from sknn.mlp import Classifier, Layer from sknn import ae from sklearn.pipeline import Pipeline from temporalPivot import playByPlay from sklearn.preprocessing import MinMaxScaler from sklearn.metrics import accuracy_score from sklearn.grid_search import GridSearchCV from sklearn.metrics import classification_report pbp = playByPlay() #instantiate object pbp.select("CAR", 2014) #select team and year, this is done in place preppedData = pbp.temporal(20) #this will return the training and test data #as dict preppedData['train'], preppedData['label'] def neuralCombo(data): pipeline = Pipeline([ ('min/max scaler', MinMaxScaler(feature_range=(0.0, 1.0))), ('nn', Classifier(layers=[ Layer("Rectifier", units=100), Layer("Sigmoid", units=100), Layer("Softmax")], n_iter=25))]) learningRate = [0.05, 0.005, 0.001, 0.0001, 0.00001] units = [5, 50, 100, 200] type = ['Rectifier', 'Sigmoid', 'Sigmoid', 'Tanh', 'Linear', 'Softmax', 'Gaussian'] #type = ['Rectifier', 'Linear', 'Gaussian']