Advertisement
Guest User

Untitled

a guest
Jan 2nd, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
OCaml 0.51 KB | None | 0 0
  1. open Owl
  2.  
  3. module R = Regression.D
  4.  
  5. (* input dim: lines indexed by samples, columns by dimension of input (here 1)*)
  6. let input =
  7.   Arr.uniform ~a:0.0 ~b:10.0 [| 30; 1 |]
  8.  
  9. let b = 2.0
  10.  
  11. let c = 4.0
  12.  
  13. (* the output as obtained from the true model *)
  14. let output =
  15.   Arr.map (fun x -> c *. x +. b) input
  16.  
  17. let _ =
  18.   Arr.print input
  19.  
  20. let _ =
  21.   Arr.print output
  22.  
  23. let w, bias =
  24.   let res = R.ols ~i:true input output in
  25.   res.(0), res.(1)
  26.  
  27. let _ =
  28.   Printf.printf "result: \n";
  29.   Arr.print w;
  30.   Arr.print bias
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement