2013-03-22 14:57:49 +00:00
|
|
|
(ns clj-ml.io-test
|
2013-09-21 23:53:54 +00:00
|
|
|
(:require [clojure.string :as str])
|
2013-03-22 14:57:49 +00:00
|
|
|
(:use [clj-ml io data] :reload-all)
|
|
|
|
(:use clojure.test midje.sweet))
|
|
|
|
|
2013-07-11 11:40:32 +00:00
|
|
|
(deftest test-load-instances-iris-arff-url
|
2013-09-22 00:01:31 +00:00
|
|
|
(let [ds (do (println "Loading instances from http://clj-ml.artifice.cc/iris.arff ...")
|
|
|
|
(load-instances :arff "http://clj-ml.artifice.cc/iris.arff"))]
|
2013-03-22 14:57:49 +00:00
|
|
|
(is (= 150 (dataset-count ds)))))
|
2013-07-11 11:40:32 +00:00
|
|
|
|
|
|
|
(deftest test-load-instances-iris-csv-url
|
2013-09-22 00:01:31 +00:00
|
|
|
(let [ds (do (println "Loading instances from http://clj-ml.artifice.cc/iris.csv ...")
|
|
|
|
(load-instances :csv "http://clj-ml.artifice.cc/iris.csv"))]
|
2013-07-11 11:40:32 +00:00
|
|
|
(is (= 150 (dataset-count ds)))))
|
|
|
|
|
|
|
|
(deftest test-save-instances
|
|
|
|
(let [ds (make-dataset "test" [:a :b {:c [:m :n]}] [[1 2 :m] [4 5 :m]])]
|
|
|
|
(is (= (do (save-instances :csv "test.csv" ds)
|
2013-09-21 23:53:54 +00:00
|
|
|
(str/replace (slurp "test.csv") #"\r\n" "\n"))
|
|
|
|
"a,b,c\n1,2,m\n4,5,m\n"))
|
2013-07-11 11:40:32 +00:00
|
|
|
(is (= (do (save-instances :arff "test.arff" ds)
|
2013-09-21 23:53:54 +00:00
|
|
|
(str/replace (slurp "test.arff") #"\r\n" "\n"))
|
|
|
|
"@relation test\n\n@attribute a numeric\n@attribute b numeric\n@attribute c {m,n}\n\n@data\n1,2,m\n4,5,m\n"))))
|
2013-07-11 11:40:32 +00:00
|
|
|
|