def runTest(self): data = cleanData(self.filename) knearest = getDiscreetClassifier('knearest') resultTime = CV.doShuffleCrossValidation(knearest, data.data, data.target) print('knearest result: ' + str(resultTime.meanScore) + ' Time taken: ' + str(resultTime.timeTaken)) self.assertTrue(resultTime.timeTaken > 0)
def runTest(self): svm = 'svm' svmC = getDiscreetClassifier(svm) saveAble = TrainClassifier.trainWithLabels(svmC,self.data.data, self.data.target) meanScore = CV.doShuffleCrossValidation(svmC, self.data.data, self.data.target).meanScore s = saveClassifierAsString(saveAble) clf = loadClassifierFromString(s) newScore = clf.score(self.data.data,self.data.target) result = abs(meanScore - newScore) # Ensure the score after reloading the classifier is close to the cross validation score self.assertTrue(result < .05)
def runTest(self): svm = 'svm' svmC = getDiscreetClassifier(svm) meanScore = CV.doShuffleCrossValidation(svmC, self.data.data, self.data.target).meanScore trained = TrainClassifier.trainWithLabels(getDiscreetClassifier(svm), self.data.data, self.data.target) predictions = predict(trained, self.data.data) # Ensure the score after from predicting is close to the cross validation score correct = 0 for x in range(len(predictions)): if (predictions[x][0] == self.data.target[x]): correct += 1 newScore = float(correct) / len(self.data.target) result = abs(meanScore - newScore) self.assertTrue(result < .05)
def runTest(self): leastSquares = 'leastSquares' kC = getDiscreetClassifier(leastSquares) meanScoreTimeTaken = CV.doShuffleCrossValidation(kC, self.data.data, self.data.target) print('LeastSquares result: ' + str(meanScoreTimeTaken.meanScore) + ' Time taken:' + str(meanScoreTimeTaken.timeTaken) + ' seconds')
def runTest(self): dt = 'decisionTree' kC = getDiscreetClassifier(dt) meanScoreTimeTaken = CV.doShuffleCrossValidation(kC, self.data.data, self.data.target) print('Decision Tree result: ' + str(meanScoreTimeTaken.meanScore) + ' Time taken:' + str(meanScoreTimeTaken.timeTaken) + ' seconds')
def runTest(self): pa = 'passiveAggressive' kC = getDiscreetClassifier(pa) meanScoreTimeTaken = CV.doShuffleCrossValidation(kC, self.data.data, self.data.target) print('Passive Aggressive result: ' + str(meanScoreTimeTaken.meanScore) + ' Time taken:' + str(meanScoreTimeTaken.timeTaken) + ' seconds')
def runTest(self): nCentroid = 'nearestCentroid' kC = getDiscreetClassifier(nCentroid) meanScoreTimeTaken = CV.doShuffleCrossValidation(kC, self.data.data, self.data.target) print('Nearest Centroid result: ' + str(meanScoreTimeTaken.meanScore) + ' Time taken:' + str(meanScoreTimeTaken.timeTaken) + ' seconds')
def runTest(self): preceptron = 'perceptron' kC = getDiscreetClassifier(preceptron) meanScoreTimeTaken = CV.doShuffleCrossValidation(kC, self.data.data, self.data.target) print('Perceptron result: ' + str(meanScoreTimeTaken.meanScore) + ' Time taken:' + str(meanScoreTimeTaken.timeTaken) + ' seconds')
def runTest(self): rForest = 'randomForest' kC = getDiscreetClassifier(rForest) meanScoreTimeTaken = CV.doShuffleCrossValidation(kC, self.data.data, self.data.target) print('Random Forest result: ' + str(meanScoreTimeTaken.meanScore) + ' Time taken:' + str(meanScoreTimeTaken.timeTaken) + ' seconds')
def runTest(self): sgd = 'sgd' kC = getDiscreetClassifier(sgd) meanScoreTimeTaken = CV.doShuffleCrossValidation(kC, self.data.data, self.data.target) print('SGD result: ' + str(meanScoreTimeTaken.meanScore) + ' Time taken:' + str(meanScoreTimeTaken.timeTaken) + ' seconds')
def runTest(self): gauss = 'guassNB' kC = getDiscreetClassifier(gauss) meanScoreTimeTaken = CV.doShuffleCrossValidation(kC, self.data.data, self.data.target) print('Guassian Naive Bayes result: ' + str(meanScoreTimeTaken.meanScore) + ' Time taken:' + str(meanScoreTimeTaken.timeTaken) + ' seconds')
def runTest(self): kC = getDiscreetClassifier('logisticRegression') meanScoreTimeTaken = CV.doShuffleCrossValidation(kC, self.data.data, self.data.target) print('logisticRegression result: ' + str(meanScoreTimeTaken.meanScore) + ' Time taken:' + str(meanScoreTimeTaken.timeTaken) + ' seconds')
def runTest(self): kC = getDiscreetClassifier('bayesianRidge') meanScoreTimeTaken = CV.doShuffleCrossValidation(kC, self.data.data, self.data.target) print('BayesianRidge result: ' + str(meanScoreTimeTaken.meanScore) + ' Time taken:' + str(meanScoreTimeTaken.timeTaken) + ' seconds')
def runTest(self): kC = getDiscreetClassifier('orthogonalMatchingPursuit') meanScoreTimeTaken = CV.doShuffleCrossValidation(kC, self.data.data, self.data.target) print('OrthogonalMatchingPursuit result: ' + str(meanScoreTimeTaken.meanScore) + ' Time taken:' + str(meanScoreTimeTaken.timeTaken) + ' seconds')