forked from McMasterU/HashedExpression
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLinearRegression.hs
More file actions
25 lines (22 loc) · 776 Bytes
/
LinearRegression.hs
File metadata and controls
25 lines (22 loc) · 776 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
module Examples.LinearRegression where
import HashedExpression
import System.FilePath ((</>))
import Prelude hiding ((^), (**))
import HashedExpression.Modeling.Typed
ex1_linearRegression :: OptimizationProblem
ex1_linearRegression =
let x = param1D @97 "x"
y = param1D @97 "y"
theta0 = variable "theta0"
theta1 = variable "theta1"
objective = norm2square ((theta0 *. 1) + (theta1 *. x) - y)
in OptimizationProblem
{ objective = objective,
constraints = [],
values =
[ x :-> VFile (TXT "x.txt"),
y :-> VFile (TXT "y.txt")
]
}
ex1 :: IO ()
ex1 = proceed ex1_linearRegression CSimpleConfig {output = OutputText, maxIteration = Nothing} ("examples" </> "LinearRegression")