Skip to content

Commit

Permalink
Add linear_regression jupyter notebook.
Browse files Browse the repository at this point in the history
  • Loading branch information
trekhleb committed Nov 5, 2018
1 parent d51a5c5 commit 40ddaf7
Show file tree
Hide file tree
Showing 4 changed files with 312 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.idea
env
.ipynb_checkpoints
1 change: 1 addition & 0 deletions data/house-prices.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Size,Rooms,Price
2104,3,399900
1600,3,329900
2400,3,369000
Expand Down
7 changes: 2 additions & 5 deletions src/linear_regression/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
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]
Expand All @@ -17,7 +17,7 @@
LINEAR_REGRESSION = LinearRegression(X, Y)

# Train linear regression.
NUM_ITERATIONS = 30
NUM_ITERATIONS = 50
LAMBDA_PARAM = 0
ALPHA = 0.1

Expand All @@ -29,9 +29,6 @@
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:]))

Expand Down
308 changes: 308 additions & 0 deletions src/linear_regression/linear_regression.ipynb

Large diffs are not rendered by default.

0 comments on commit 40ddaf7

Please sign in to comment.