Modernize Python 2 code to get ready for Python 3

This commit is contained in:
cclauss
2017-11-25 10:23:50 +01:00
parent a03b2eafc0
commit 4e06949072
95 changed files with 580 additions and 521 deletions

View File

@ -3,6 +3,7 @@ Implementation of a basic regression decision tree.
Input data set: The input data set must be 1-dimensional with continuous labels.
Output: The decision tree maps a real number input to a real number output.
"""
from __future__ import print_function
import numpy as np

View File

@ -1,6 +1,7 @@
"""
Implementation of gradient descent algorithm for minimizing cost of a linear hypothesis function.
"""
from __future__ import print_function
import numpy
# List of input, output pairs
@ -106,13 +107,13 @@ def run_gradient_descent():
atol=absolute_error_limit, rtol=relative_error_limit):
break
parameter_vector = temp_parameter_vector
print("Number of iterations:", j)
print(("Number of iterations:", j))
def test_gradient_descent():
for i in range(len(test_data)):
print("Actual output value:", output(i, 'test'))
print("Hypothesis output:", calculate_hypothesis_value(i, 'test'))
print(("Actual output value:", output(i, 'test')))
print(("Hypothesis output:", calculate_hypothesis_value(i, 'test')))
if __name__ == '__main__':

View File

@ -7,6 +7,7 @@ We try to set these Feature weights, over many iterations, so that they best
fits our dataset. In this particular code, i had used a CSGO dataset (ADR vs
Rating). We try to best fit a line through dataset and estimate the parameters.
"""
from __future__ import print_function
import requests
import numpy as np

View File

@ -9,6 +9,7 @@
p2 = 1
'''
from __future__ import print_function
import random
@ -52,7 +53,7 @@ class Perceptron:
epoch_count = epoch_count + 1
# if you want controle the epoch or just by erro
if erro == False:
print('\nEpoch:\n',epoch_count)
print(('\nEpoch:\n',epoch_count))
print('------------------------\n')
#if epoch_count > self.epoch_number or not erro:
break
@ -66,10 +67,10 @@ class Perceptron:
y = self.sign(u)
if y == -1:
print('Sample: ', sample)
print(('Sample: ', sample))
print('classification: P1')
else:
print('Sample: ', sample)
print(('Sample: ', sample))
print('classification: P2')
def sign(self, u):

View File

@ -1,4 +1,4 @@
import numpy
import numpy as np
""" Here I implemented the scoring functions.
MAE, MSE, RMSE, RMSLE are included.