Add linear_regression jupyter notebook.

This commit is contained in:
Oleksii Trekhleb
2018-11-05 07:13:35 +02:00
parent d51a5c5b00
commit 40ddaf7696
4 changed files with 312 additions and 5 deletions
+1
View File
@@ -1,2 +1,3 @@
.idea
env
.ipynb_checkpoints
+1
View File
@@ -1,3 +1,4 @@
Size,Rooms,Price
2104,3,399900
1600,3,329900
2400,3,369000
1 2104 Size 3 Rooms 399900 Price
1 Size Rooms Price
2 2104 2104 3 3 399900 399900
3 1600 1600 3 3 329900 329900
4 2400 2400 3 3 369000 369000
+2 -5
View File
@@ -7,7 +7,7 @@ import matplotlib.pyplot as plot
from linear_regression import LinearRegression
# Load the data.
DATA = np.genfromtxt('./data/house-prices.csv', delimiter=',')
DATA = np.genfromtxt('./data/house-prices.csv', delimiter=',', skip_header=True)
# Split the by input and output.
X = DATA[:, 0:2]
@@ -17,7 +17,7 @@ Y = DATA[:, 2:]
LINEAR_REGRESSION = LinearRegression(X, Y)
# Train linear regression.
NUM_ITERATIONS = 30
NUM_ITERATIONS = 50
LAMBDA_PARAM = 0
ALPHA = 0.1
@@ -29,9 +29,6 @@ ALPHA = 0.1
COST_HISTORY
) = LINEAR_REGRESSION.train(ALPHA, LAMBDA_PARAM, NUM_ITERATIONS)
print(np.min(X[:, 0]))
print(np.min(X[:, 1]))
print('Initial cost: {0}\n'.format(COST_HISTORY[0]))
print('Optimized cost: {0}\n'.format(COST_HISTORY[-1:]))
File diff suppressed because one or more lines are too long