Commits

Oliver Gu committed 3c48ae6

Removed argument labels from functions in Stats module.

  • Participants
  • Parent commits a15511e

Comments (0)

Files changed (3)

examples/svm_cli.ml

             let expected = Svm.Problem.get_targets problem in
             match Option.value svm_type ~default:`C_SVC with
             | `C_SVC | `NU_SVC | `ONE_CLASS ->
-              let accuracy = Stats.calc_accuracy ~expected ~predicted in
+              let accuracy = Stats.calc_accuracy expected predicted in
               printf "Cross Validation Accuracy = %g%%\n" (100. *. accuracy)
             | `EPSILON_SVR | `NU_SVR ->
-              let mse = Stats.calc_mse ~expected ~predicted in
-              let scc = Stats.calc_scc ~expected ~predicted in
+              let mse = Stats.calc_mse expected predicted in
+              let scc = Stats.calc_scc expected predicted in
               printf "Cross Validation Mean squared error = %g\n" mse;
               printf "Cross Validation Squared correlation coefficient = %g\n" scc)
 
           done);
         match Svm.Model.get_svm_type model with
         | `C_SVC | `NU_SVC | `ONE_CLASS ->
-          let n_correct = Stats.calc_n_correct ~expected ~predicted in
+          let n_correct = Stats.calc_n_correct expected predicted in
           let accuracy = Float.(of_int n_correct / of_int n_samples * 100.) in
           printf "Accuracy = %g%% (%d/%d) (classification)\n" accuracy n_correct n_samples
         | `EPSILON_SVR | `NU_SVR ->
-          let mse = Stats.calc_mse ~expected ~predicted in
-          let scc = Stats.calc_scc ~expected ~predicted in
+          let mse = Stats.calc_mse expected predicted in
+          let scc = Stats.calc_scc expected predicted in
           printf "Mean squared error = %g (regression)\n" mse;
           printf "Squared correlation coefficient = %g (regression)\n" scc)
 
       invalid_argf "dimension mismatch in Stats.%s: %d <> %d" location dimx dimy ()
     else ()
 
-  let calc_n_correct ~expected ~predicted =
-    check_dimension expected predicted ~location:"calc_n_correct";
-    Vec.fold (fun count x -> count + if x = 0. then 1 else 0) 0
-      (Vec.sub expected predicted)
-
-  let calc_accuracy ~expected ~predicted =
-    check_dimension expected predicted ~location:"calc_accuracy";
-    let l = Vec.dim expected in
-    let n_correct = calc_n_correct ~expected ~predicted in
-    Float.(of_int n_correct / of_int l)
-
-  let calc_mse ~expected ~predicted =
-    check_dimension expected predicted ~location:"calc_mse";
-    let l = Vec.dim expected in
-    Vec.ssqr_diff predicted expected /. float l
-
-  let calc_scc ~expected ~predicted =
-    check_dimension expected predicted ~location:"calc_scc";
-    let l = Vec.dim expected in
-    let x = predicted in
-    let y = expected  in  (* true values *)
+  let calc_n_correct x y =
+    check_dimension x y ~location:"calc_n_correct";
+    Vec.fold (fun count x -> count + if x = 0. then 1 else 0) 0 (Vec.sub x y)
+
+  let calc_accuracy x y =
+    check_dimension x y ~location:"calc_accuracy";
+    let l = Vec.dim x in
+    let n_correct = calc_n_correct x y in
+    float n_correct /. float l
+
+  let calc_mse x y =
+    check_dimension x y ~location:"calc_mse";
+    let l = Vec.dim x in
+    Vec.ssqr_diff x y /. float l
+
+  let calc_scc x y =
+    check_dimension x y ~location:"calc_scc";
+    let l = Vec.dim x in
     let sum_x  = ref 0. in
     let sum_y  = ref 0. in
     let sum_xx = ref 0. in
       given test data set. For more details, have a look on page 8 in the
       {{:http://www.csie.ntu.edu.tw/~cjlin/papers/libsvm.pdf } LIBSVM paper} *)
 
-  (** [calc_n_correct expected actual] @return the number of correctly
+  (** [calc_n_correct expected predicted] @return the number of correctly
       predicted labels.
       @raise Invalid_argument if the vector dimensions do not match. *)
-  val calc_n_correct : expected:vec -> predicted:vec -> int
+  val calc_n_correct : vec -> vec -> int
 
   (** [calc_accuracy expected predicted] @return the ratio (in percent) of
       correctly predicted labels to the number of all labels.
       @raise Invalid_argument if the vector dimensions do not match. *)
-  val calc_accuracy : expected:vec -> predicted:vec -> float
+  val calc_accuracy : vec -> vec -> float
 
   (** [calc_mse expected predicted] @return the mean sum of squared errors.
       @raise Invalid_argument if the vector dimensions do not match. *)
-  val calc_mse : expected:vec -> predicted:vec -> float
+  val calc_mse : vec -> vec -> float
 
   (** [calc_scc expected predicted] @return the squared correlation coefficient.
       @raise Invalid_argument if the vector dimensions do not match. *)
-  val calc_scc : expected:vec -> predicted:vec -> float
+  val calc_scc : vec -> vec -> float
 end