(ns code.experiments.enclave ;(:import (javaapplication1 Main)) ;(:import (weightedscore Main)) (:use (code.utils utils preprocess)) (:use (code.pls cliff ncliff)) (:use (code.data data)) (:use (code.privacy privacy)) (:use (code.experiments within)) (:use (incanter io core stats))) (defn enclave-experiment [treatments data-sets test-name distance-fn result-pathname & options] (let [opts (when options (apply assoc {} options)) sav (or (:sav opts) [10 20]) num (or (:num opts) 10) n (or (:n opts) 10) r (or (:r opts) [0.1501 0.3501]) pro (or (:pro opts) ncliff) opro (or (:opro opts) ocliff) train0 (map pre-data (map eval (filter #(not= % test-name) data-sets))) train1 (matrix (apply concat train0)) cabal (fn [treatment] (matrix (apply concat (map #((eval treatment) n % sav r pro opro distance-fn) train0)))) trains (map cabal treatments) train (save train1 (str result-pathname test-name "/train.csv") :header (eval (symbol (str test-name"-header")))) test (save (pre-data (eval test-name)) (str result-pathname test-name "/test.csv") :header (eval (symbol (str test-name"-header")))) allnew (loop [treatment treatments t trains result " "] (if (empty? treatment) 'done (recur (rest treatment) (rest t) (save (first t) (str result-pathname test-name "/" (first treatment) ".csv") :header (eval (symbol (str test-name"-header")))))))] allnew)) (defn run-enclave-experiment [test-name] (enclave-experiment ['morph1 'morph3 'morph10 'morph20 'morph40 'swap10 'swap20 'swap40 'datafly2 'datafly4] ['ant13 'arc 'camel10 'poi15 'redaktor 'skarbonka 'tomcat 'velocity14 'xalan24 'xerces12] test-name numeric "/home/fayola/ourprivacy/results/enclave/")) (defn enclave-weka [treatments data result-pathname & options] "Treatments are a vector of symbols n is initialized to 1: in the unit its a digit between 1-100 klassifier is a number representing a classifier from weka klassifier-name is the name representing a classifier from weka (This has not been used but we leave it to know what the numbers mean) The klassifier and klassifier-name must correspond data is a symbol result-pathname /home/ourprivacy/results/within/ For the treatment unit, within the code may need to add 'train' to treatments vector Example: (within-weka ['train 'morph1 'morph3 'morph10 'morph20 'morph40 'swap10 'swap20 'swap40 'datafly2 'datafly4] 'ant13 /home/fayola/ourprivacy/results/enclave/)" (let [opts (when options (apply assoc {} options)) klassifiers (or (:klassifiers opts) [0 3 4 5]) klassifier-names (or (:klassifier-names opts) ["nb" "lr" "rf" "knn"]) klassifier (or (:klassifier opts) 4) treatment-unit (fn [treatment klassifier] (let [base_dir result-pathname dir (str base_dir data "/") train_file (str dir treatment".csv.arff") test_file (str dir "test.csv.arff") prefix (str data","klassifier","(FindPos1 treatment treatments 0)",")] (. exp1 start_single_experiment train_file test_file prefix klassifier))) treatment-units (fn [klassifier] (loop [treatment treatments result []] (if (empty? treatment) result (recur (rest treatment) (conj result (treatment-unit (first treatment) klassifier))))))] [(treatment-units klassifier) (. exp1 uci_output_result (str data))])) (defn run-enclave-weka [data result-pathname & options] (let [opts (when options (apply assoc {} options)) klassifiers (if (true? (:klassifiers opts)) (:klassifiers opts) [0 3 4 5])] (enclave-weka ['train 'morph1 'morph3 'morph10 'morph20 'morph40 'swap10 'swap20 'swap40 'datafly2 'datafly4] data result-pathname :klassifier 0) (. exp1 clear_experiment))) ;(defn enclave-extract1 [result-csv-name a performance-name] ;a =4 for pd, 7 for pf ; (let [result (trans (report-file result-csv-name)) ; result1 (sel result :rows a)] ; result1)) (defn enclave-extract [result-csv-name result-pathname test-name a performance-name] ;a =4 for pd, 7 for pf (let [result (report-file result-csv-name) result1 (sel result :cols a) result2 (bind-columns (matrix (range (nrow result))) result1)] (save result2 (str result-pathname performance-name"-"test-name"-nb.txt") :delim \space))) (def enclave-rcns ["/home/fayola/ourprivacy/results/enclave/results/nb/ant13-output-result.csv" "/home/fayola/ourprivacy/results/enclave/results/nb/arc-output-result.csv" "/home/fayola/ourprivacy/results/enclave/results/nb/camel10-output-result.csv" "/home/fayola/ourprivacy/results/enclave/results/nb/poi15-output-result.csv" "/home/fayola/ourprivacy/results/enclave/results/nb/redaktor-output-result.csv" "/home/fayola/ourprivacy/results/enclave/results/nb/skarbonka-output-result.csv" "/home/fayola/ourprivacy/results/enclave/results/nb/tomcat-output-result.csv" "/home/fayola/ourprivacy/results/enclave/results/nb/velocity14-output-result.csv" "/home/fayola/ourprivacy/results/enclave/results/nb/xalan24-output-result.csv" "/home/fayola/ourprivacy/results/enclave/results/nb/xerces12-output-result.csv"]) (def test-names ['ant13 'arc 'camel10 'poi15 'redaktor 'skarbonka 'tomcat 'velocity14 'xalan24 'xerces12]) ;(run-enclave-extract "/home/fayola/ourprivacy/results/enclave/results/nb/" 4 'pd) (defn run-enclave-extract [result-pathname a performance-name] (map #(enclave-extract %1 result-pathname %2 a performance-name) enclave-rcns test-names))