Source

ollio / main.ml

let get_input_filename default = 
  if Array.length Sys.argv > 1 then 
    Array.get Sys.argv 1
  else default;;

let usage() =
  print_endline "usage: ./mlml <algorithm> <training data file> <test data file>";;

let _ =
  if Array.length Sys.argv != 4 then
    usage()
  else begin
    let algorithm = Array.get Sys.argv 1 in
    let trainfile = Array.get Sys.argv 2 in
    let testfile  = Array.get Sys.argv 3 in
    Printf.printf "algorithm\t%s\n" algorithm;
    Printf.printf "traindata\t%s\n" trainfile;
    Printf.printf "testdata\t%s\n" testfile;
    let w = Oll.train algorithm trainfile in
    print_endline "train done";
    let r = Oll.test w algorithm testfile in
    Oll.print_result r;
  end;;

(*
let _ =
  let w = Vector.newv() in
  let x = [(1,234.0)] in
  Vector.print_vector w;
  Vector.print_vector x;
  Vector.print_vector (Vector.add w x);; *)

(*
  INPUT: aggressiveness parameter C > 0
  INITIALIZE: w1 = (0,...,0)
  For	t = 1,2,...
    • receive instance: xt ∈ Rn
    • predict: yˆt = sign(wt · xt )
    • receive correct label: yt ∈ {−1, +1}
    • suffer loss: lt = max{0 , 1−yt(wt ·xt)}
  • update:
    1. set:
       τt = lt / |x_t|^2	(PA) ∥xt∥
       τt =min C, lt/∥xt∥2	(PA-I)
       τ= lt / (|xt|^2 + 1/2C)  (PA-II)
    2.update: wt+1=wt+τtytxt
*)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.