Created
October 9, 2017 21:32
-
-
Save neksa/4c8acf8b09a2db6c1cf4436cd0c9bbd9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# test the new generatd machine learning algorithm | |
def testAlgorithm(algorithm, trainSet, trainSetAnswers): | |
print("Type of trainSetAnswers is " + str(type(trainSetAnswers))) | |
for i in range(len(trainSetAnswers)): | |
y_predicted = algorithm.predict(trainSet[index]) | |
correctAnswer = trainSetAnswers[index] | |
print("Correct Answer is " + str(correctAnswer)) | |
correctAnswer = correctAnswer.reshape(1,-1) | |
print("Shape of CorrectAnswer is " + str(correctAnswer.shape)) | |
print("Y Predicted Value is from the trainSetAnswers is" + str(y_predicted)) | |
meanSquaredError = mean_squared_error(y_predicted, correctAnswer) | |
# This function will call the routine and validate the | |
# Train the testing set | |
classifier = RandomForestClassifier() | |
classifier.fit(testSet, testSetAnswers) | |
# Validate the testing set | |
# trainSet = trainSet.reshape(1,-1) | |
print("Set of Training Data is " + str(trainSet.shape)) | |
print("Set of Training Ansers are " + str(trainSetAnswers.shape)) | |
testAlgorithm(classifier, trainSet, trainSetAnswers) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment