def main(): test_dataset = mock_Chinese_stock_price.get_stockset() v1 = test_dataset[0]['input'] v2 = test_dataset[1]['input'] print v1 print v2 print euclidean(v1, v2)
def main(): data_set = mock_Chinese_stock_price.get_stockset() cv_total_error_unweighted = cross_validate(data_set, algr = KNN.get_KNN, trails=200) cv_total_error_weighted = cross_validate(data_set, algr = KNN.get_weightedKNN, trails=200) print 'cross validation, using un-weighted KNN: ', cv_total_error_unweighted print 'cross validation, using weighted KNN: ', cv_total_error_weighted
def main(): data = mock_Chinese_stock_price.get_stockset() print prob_guess(data, (9, 2, 12), 10, 100) print prob_guess(data, (3, 2, 5), 10, 100) print prob_guess(data, (3, 2, 5), 1, 10) # plot using accumulative probability accumulative_plot(data, (9, 2, 12), 100) # plot using probabilities graph probabilitygraph(data, (9, 2, 12), 100)
def main(): data_set = mock_Chinese_stock_price.get_stockset() cv_total_error_unweighted = cross_validate(data_set, algr=KNN.get_KNN, trails=200) cv_total_error_weighted = cross_validate(data_set, algr=KNN.get_weightedKNN, trails=200) print 'cross validation, using un-weighted KNN: ', cv_total_error_unweighted print 'cross validation, using weighted KNN: ', cv_total_error_weighted
def main(): training_data = mock_Chinese_stock_price.get_stockset() # KNN without weight print 'using un-weighted KNN' print get_KNN(training_data, (9, 2, 12), k=3) print get_KNN(training_data, (5, 3, 7), k=3) # KNN with weight print 'weighted KNN using Gaussian function' print 'Gaussian Weight Function: ', get_weightedKNN( training_data, (9, 2, 12)) print 'Inverse Weight Function: ', get_weightedKNN(training_data, (9, 2, 12), weight_f=inverse_weight) print 'Subtract Weight Function: ', get_weightedKNN( training_data, (9, 2, 12), weight_f=subtract_weight)