Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Logistic protocolとSVM protocolの呼び出し方を変えたので、テストも変更

  • Loading branch information...
commit c4b1511ca098335477d70fbf5d43c2316eb4b905 1 parent 6788ccb
@syou6162 authored
Showing with 18 additions and 20 deletions.
  1. +5 −6 test/fobos_clj/test/logistic.clj
  2. +13 −14 test/fobos_clj/test/svm.clj
View
11 test/fobos_clj/test/logistic.clj
@@ -1,4 +1,5 @@
(ns fobos_clj.test.logistic
+ (:use [fobos_clj.fobos])
(:use [fobos_clj.logistic])
(:use [clojure.test]))
@@ -15,14 +16,12 @@
(deftest test-update-weight
(let [examples [[1 [[1 1] [2 1]]]
[-1 [[1 2] [2 0]]]]
- init-weight {0 0.1, 1 0.2, 2 0.5, 3 -0.1}
- iter 10
eta 0.1
lambda 0.1
- logistic (fobos_clj.logistic.Logistic. examples init-weight eta lambda)]
- (.update-weight logistic iter)))
+ logistic (make-Logistic examples eta lambda)]
+ (update-weight logistic)))
(deftest test-classify
(let [weight {0 0.1, 1 0.2, 2 0.5, 3 -0.1}
- logistic (fobos_clj.logistic.Logistic. nil weight nil nil)]
- (is (= (.classify logistic [[1 1] [2 1]]) 1))))
+ logistic (assoc (make-Logistic) :weight weight)]
+ (is (= (classify logistic [[1 1] [2 1]]) 1))))
View
27 test/fobos_clj/test/svm.clj
@@ -1,6 +1,7 @@
(ns fobos_clj.test.svm
- (:use [fobos_clj.svm])
- (:use [clojure.test]))
+ (:use fobos_clj.fobos)
+ (:use fobos_clj.svm)
+ (:use clojure.test))
(deftest test-margin
(let [weight {0 0.1, 1 0.2, 2 0.5, 3 -0.1}
@@ -11,24 +12,22 @@
-0.7))))
(deftest test-muladd
- (let [weight {0 0.1, 1 0.2, 2 0.5, 3 -0.1}
- fv [[1 1] [2 1.0] [100 1]]]
- (is (= (muladd weight fv 1 1.0)
- {0 0.1, 1 1.2, 2 1.5, 3 -0.1, 100 1.0}))
- (is (= (muladd weight fv -1 1.0)
- {0 0.1, 1 -0.8, 2 -0.5, 3 -0.1, 100 -1.0}))))
+ (let [weight {0 0.1, 1 0.2, 2 0.5, 3 -0.1}
+ fv [[1 1] [2 1.0] [100 1]]]
+ (is (= (muladd weight fv 1 1.0)
+ {0 0.1, 1 1.2, 2 1.5, 3 -0.1, 100 1.0}))
+ (is (= (muladd weight fv -1 1.0)
+ {0 0.1, 1 -0.8, 2 -0.5, 3 -0.1, 100 -1.0}))))
(deftest test-update-weight
(let [examples [[1 [[1 1] [2 1]]]
[-1 [[1 2] [2 0]]]]
- init-weight {0 0.1, 1 0.2, 2 0.5, 3 -0.1}
- iter 10
eta 0.1
lambda 0.1
- svm (fobos_clj.svm.SVM. examples init-weight eta lambda)]
- (.update-weight svm iter)))
+ model (make-SVM examples eta lambda)]
+ (update-weight model)))
(deftest test-classify
(let [weight {0 0.1, 1 0.2, 2 0.5, 3 -0.1}
- svm (fobos_clj.svm.SVM. nil weight nil nil)]
- (is (= (.classify svm [[1 1] [2 1]]) 1))))
+ svm (assoc (make-SVM) :weight weight)]
+ (is (= (classify svm [[1 1] [2 1]]) 1))))
Please sign in to comment.
Something went wrong with that request. Please try again.