From 72e21f6e7a8417ea66be44277ee3fa19c3a0e0c0 Mon Sep 17 00:00:00 2001 From: Joel 'Aaron' Cohen Date: Wed, 19 Mar 2014 19:18:32 -0400 Subject: [PATCH] Minimal changes to compile against Weka 3.7.10 There is a weird junit dependency being pulled in that I haven't figured out. --- project.clj | 11 ++++++++++- src/clj_ml/attribute_selection.clj | 3 ++- src/clj_ml/classifiers.clj | 4 ++-- src/clj_ml/data.clj | 5 ++--- test/clj_ml/data_test.clj | 9 +++------ test/clj_ml/filters_test.clj | 2 +- 6 files changed, 20 insertions(+), 14 deletions(-) diff --git a/project.clj b/project.clj index 2962c75..9db893a 100644 --- a/project.clj +++ b/project.clj @@ -4,7 +4,16 @@ :license {:name "MIT License" :url "http://opensource.org/licenses/MIT"} :url "https://github.com/joshuaeckroth/clj-ml" - :dependencies [[nz.ac.waikato.cms.weka/weka-stable "3.6.9"] + :dependencies [[nz.ac.waikato.cms.weka/weka-dev "3.7.10"] + [nz.ac.waikato.cms.weka/chiSquaredAttributeEval "1.0.3"] + [nz.ac.waikato.cms.weka/attributeSelectionSearchMethods "1.0.6"] + [nz.ac.waikato.cms.weka/linearForwardSelection "1.0.1"] + [nz.ac.waikato.cms.weka/rotationForest "1.0.3"] + [nz.ac.waikato.cms.weka/paceRegression "1.0.2"] + [nz.ac.waikato.cms.weka/SPegasos "1.0.2"] + [nz.ac.waikato.cms.weka/LibSVM "1.0.5"] + [org.clojars.remleduff/snowball "20051019-1"] + [junit/junit "4.11"] [tw.edu.ntu.csie/libsvm "3.1"] [org.clojure/data.xml "0.0.7"] [org.apache.lucene/lucene-analyzers-common "4.3.0"]] diff --git a/src/clj_ml/attribute_selection.clj b/src/clj_ml/attribute_selection.clj index e4b7219..b784516 100644 --- a/src/clj_ml/attribute_selection.clj +++ b/src/clj_ml/attribute_selection.clj @@ -9,7 +9,8 @@ SymmetricalUncertAttributeEval ChiSquaredAttributeEval AttributeSelection CfsSubsetEval ;; search - GreedyStepwise BestFirst GeneticSearch Ranker RankSearch LinearForwardSelection])) + GreedyStepwise BestFirst Ranker RankSearch LinearForwardSelection] + [weka.classifiers.bayes.net.search.local GeneticSearch])) (defmulti #^{:skip-wiki true} make-obj-options diff --git a/src/clj_ml/classifiers.clj b/src/clj_ml/classifiers.clj index bdd1b82..cf720c1 100644 --- a/src/clj_ml/classifiers.clj +++ b/src/clj_ml/classifiers.clj @@ -68,7 +68,7 @@ (weka.classifiers.meta LogitBoost AdditiveRegression RotationForest) (weka.classifiers.bayes NaiveBayes NaiveBayesUpdateable) (weka.classifiers.functions MultilayerPerceptron SMO LinearRegression Logistic PaceRegression SPegasos LibSVM) - (weka.classifiers Classifier Evaluation))) + (weka.classifiers AbstractClassifier Classifier Evaluation))) ;; Setting up classifier options @@ -544,7 +544,7 @@ (defn classifier-copy "Performs a deep copy of the classifier" [^Classifier classifier] - (Classifier/makeCopy classifier)) + (AbstractClassifier/makeCopy classifier)) (defn classifier-copy-and-train "Performs a deep copy of the classifier, trains the copy, and returns it." diff --git a/src/clj_ml/data.clj b/src/clj_ml/data.clj index f701e66..fb852ea 100644 --- a/src/clj_ml/data.clj +++ b/src/clj_ml/data.clj @@ -16,7 +16,7 @@ (:require [clojure.string :as str]) (:require [clojure.set :as set]) (:use [clojure.java.io :only [file]]) - (:import (weka.core Instance Instances FastVector Attribute) + (:import (weka.core Instance DenseInstance Instances FastVector Attribute) (cljml ClojureInstances))) (declare dataset-seq) @@ -134,8 +134,7 @@ ([dataset vector] (make-instance dataset 1 vector)) ([dataset weight vector] - (let [^Instance inst (new Instance - (count vector))] + (let [^Instance inst (DenseInstance. (count vector))] (do (.setDataset inst dataset) (loop [vs vector c 0] diff --git a/test/clj_ml/data_test.clj b/test/clj_ml/data_test.clj index d4ce413..7914def 100644 --- a/test/clj_ml/data_test.clj +++ b/test/clj_ml/data_test.clj @@ -7,8 +7,7 @@ [:a :b] 1) inst (make-instance dataset [1 2])] - (is (= (class inst) - weka.core.Instance)) + (is (instance? weka.core.Instance inst)) (is (= 2 (.numValues inst))) (is (= 1.0 (.value inst 0))) (is (= 2.0 (.value inst 1))))) @@ -18,8 +17,7 @@ [:a {:b [:b1 :b2]}] 1) inst (make-instance dataset [1 :b1])] - (is (= (class inst) - weka.core.Instance)) + (is (instance? weka.core.Instance inst)) (is (= 2 (.numValues inst))) (is (= 1.0 (.value inst 0))) (is (= "b1" (.stringValue inst 1))))) @@ -29,8 +27,7 @@ [:a :b] 1) inst (make-instance dataset [1 nil])] - (is (= (class inst) - weka.core.Instance)) + (is (instance? weka.core.Instance inst)) (is (= 2 (.numValues inst))) (is (= 1.0 (.value inst 0))) (is (Double/isNaN (.value inst 1))))) diff --git a/test/clj_ml/filters_test.clj b/test/clj_ml/filters_test.clj index 069e3d4..9bb2cdf 100644 --- a/test/clj_ml/filters_test.clj +++ b/test/clj_ml/filters_test.clj @@ -281,7 +281,7 @@ (-> instance instance-to-vector (conj (- a-max (.value instance 0))) - (#(weka.core.Instance. 1 (into-array Double/TYPE %))) + (#(weka.core.DenseInstance. 1 (into-array Double/TYPE %))) add-instance)) result)) res (clj-batch ds