Skip to content

Commit 82b89f8

Browse files
committed
Refactor coordinate utils and linear regression
1 parent e8bf5ba commit 82b89f8

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

supervised/coordinate_utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ def bearing_to_vector(bearing):
1616
# Convert back to radians
1717
bearing = (bearing / 180.0) * math.pi
1818

19-
return (math.sin(bearing) * x_multiplier, math.cos(bearing) * y_multiplier)
19+
return (math.sin(bearing) * x_multiplier, math.cos(bearing) * y_multiplier)
20+

supervised/linear_regression.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ def modelRegression(data):
44
y_arr = data.split('|')
55

66
x_arr = []
7-
for x in range (0, len(y_arr)):
7+
for x in range(0, len(y_arr)):
88
x_arr.append(x)
99

1010
speeds_x_train = x_arr
@@ -30,12 +30,12 @@ def modelRegression(data):
3030
return '|'.join(str(v) for v in ans)
3131

3232

33-
def regularizeData(speedData):
33+
def regularizeData(speed_data):
3434
# Step #1: Run linear regression on speed data to regularize data
35-
y_arr = speedData.split('|')
35+
y_arr = speed_data.split('|')
3636

3737
x_arr = []
38-
for x in range (0, len(y_arr)):
38+
for x in range(0, len(y_arr)):
3939
x_arr.append(x)
4040

4141
speeds_x_train = x_arr
@@ -50,7 +50,7 @@ def regularizeData(speedData):
5050
m = regr.coef_[0]
5151
b = regr.intercept_
5252

53-
speeds = map(lambda x: float(x), speedData.split('|'))
53+
speeds = map(lambda x: float(x), speed_data.split('|'))
5454

5555
# Step #2: Regularize data
5656
for x in range(0, len(speeds)):
@@ -61,9 +61,9 @@ def regularizeData(speedData):
6161
return speeds
6262

6363

64-
def windRegression(speedData, correlationData, candidate):
64+
def windRegression(speed_data, correlationData, candidate):
6565
# Run linear regression on speed data to regularize data
66-
speeds = regularizeData(speedData)
66+
speeds = regularizeData(speed_data)
6767
correlations = correlationData.split('|')
6868
# Schwartzian Transform
6969
correlations, speeds = zip(*sorted(zip(correlations, speeds)))

0 commit comments

Comments
 (0)