-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
minor bug fixes and more unit tests.
- Loading branch information
1 parent
9971a53
commit 24b1020
Showing
57 changed files
with
536 additions
and
834 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
julia 0.2+ | ||
julia 0.3 | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Gadfly | ||
|
||
# Set the random seed to get consistent data | ||
srand(1) | ||
|
||
# Number of examples to use | ||
n = 100 | ||
|
||
# Specify the true value of the variable | ||
true_coeffs = [2; -2; 0.5]; | ||
|
||
# Generate data | ||
x_data = rand(n, 1) * 5; | ||
x_data_expanded = hcat([x_data .^ i for i in 1 : 3]...) | ||
y_data = x_data_expanded * true_coeffs + 0.5 * rand(n, 1) | ||
|
||
|
||
p = plot( | ||
x=x_data, y=y_data, Geom.point, | ||
Theme(panel_fill=color("white")) | ||
) | ||
draw(PNG("data.png", 16cm, 12cm), p) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Simple Linear Regression | ||
# Originally written by Keegan Go for lsqpy | ||
# Translated into LinearLeastSquares.jl by Karanveer Mohan and David Zeng | ||
|
||
using LinearLeastSquares | ||
using Gadfly | ||
# Set the random seed to get consistent data | ||
srand(1) | ||
|
||
# Number of examples to use | ||
n = 100 | ||
|
||
# Specify the true value of the variable | ||
true_coeffs = [2; -2; 0.5] | ||
|
||
# Generate data | ||
x_data = rand(n) * 5 | ||
x_data_expanded = hcat([x_data .^ i for i in 1 : 3]...) | ||
y_data = x_data_expanded * true_coeffs + 0.5 * rand(n) | ||
|
||
slope = Variable() | ||
offset = Variable() | ||
line = offset + x_data * slope | ||
residuals = line - y_data | ||
error = sum_squares(residuals) | ||
optval = minimize!(error) | ||
|
||
# plot the data and the line | ||
t = [0; 5; 0.1] | ||
p = plot( | ||
layer(x=x_data, y=y_data, Geom.point), | ||
layer(x=t, y=evaluate(slope) * t + evaluate(offset), Geom.line), | ||
Theme(panel_fill=color("white")) | ||
) | ||
# draw(PNG("linear_regression.png", 16cm, 12cm), p) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Oops, something went wrong.