(ns code.privacy.priv_exp001 (:use (code.utils utils preprocess)) (:use (code.pls cliff ncliff)) (:use (code.data data)) (:use (code.defect utils search1 cliff_java)) (:use (code.privacy privacy)) (:use (incanter core stats))) (defn tenbyten1 [data num sav] (let [all (apply concat (map #(folds num %) (make-random-data data num)))] (loop [tt all result []] (if (empty? tt) result (recur (rest tt) (conj result (let [orig-train (:train (first tt)) private-train0 (ourprivatize-data1 orig-train sav 0.3501) private-train1 (private-swap-attributes 0.1 orig-train [10 20]) private-train2 (private-swap-attributes 0.2 orig-train [10 20]) private-train4 (private-swap-attributes 0.4 orig-train [10 20]) allnew ;(bin-data [orig-train private-train0 private-train1 private-train2 private-train4 (:test (first tt))];) allnew1 {:orig-train (nth allnew 0) :private-train0 (nth allnew 1) :private-train1 (nth allnew 2) :private-train2 (nth allnew 3) :private-train4 (nth allnew 4) :test (nth allnew 5)}] allnew1))))))) (defn priv-worker001 [data num data_file att-name sav] (let [priv10x10 (tenbyten1 data num sav)] (loop [p10 priv10x10 i 1 result []] (if (empty? p10) result (recur (rest p10) (inc i) (conj result [(c-arff (str "./results/privacy-exp/exp0010-data/"att-name"/orig_train"i".arff") (:orig-train (first p10)) (bind-rows (:test (first p10)) (:private-train4 (first p10)) (:private-train2 (first p10)) (:private-train1 (first p10)) (:private-train0 (first p10)) (:orig-train (first p10))) (str att-name"."(+ 100 i))) (c-arff (str "./results/privacy-exp/exp0010-data/"att-name"/private0_train"i".arff") (:private-train0 (first p10)) (bind-rows (:test (first p10)) (:private-train4 (first p10)) (:private-train2 (first p10)) (:private-train1 (first p10)) (:private-train0 (first p10)) (:orig-train (first p10))) (str att-name"."(+ 100 i))) (c-arff (str "./results/privacy-exp/exp0010-data/"att-name"/private1_train"i".arff") (:private-train1 (first p10)) (bind-rows (:test (first p10)) (:private-train4 (first p10)) (:private-train2 (first p10)) (:private-train1 (first p10)) (:private-train0 (first p10)) (:orig-train (first p10))) (str att-name"."(+ 100 i))) (c-arff (str "./results/privacy-exp/exp0010-data/"att-name"/private2_train"i".arff") (:private-train2 (first p10)) (bind-rows (:test (first p10)) (:private-train4 (first p10)) (:private-train2 (first p10)) (:private-train1 (first p10)) (:private-train0 (first p10)) (:orig-train (first p10))) (str att-name"."(+ 100 i))) (c-arff (str "./results/privacy-exp/exp0010-data/"att-name"/private4_train"i".arff") (:private-train4 (first p10)) (bind-rows (:test (first p10)) (:private-train4 (first p10)) (:private-train2 (first p10)) (:private-train1 (first p10)) (:private-train0 (first p10)) (:orig-train (first p10))) (str att-name"."(+ 100 i))) (c-arff (str "./results/privacy-exp/exp0010-data/"att-name"/test"i".arff") (:test (first p10)) (bind-rows (:test (first p10)) (:private-train4 (first p10)) (:private-train2 (first p10)) (:private-train1 (first p10)) (:private-train0 (first p10)) (:orig-train (first p10))) (str att-name"."(+ 100 i)))])))))) (defn priv100 [sav] [(priv-worker001 (pre-data ant13) 10 'ant13-result 'ant13 sav) (priv-worker001 (pre-data arc) 10 'arc-result 'arc sav) (priv-worker001 (pre-data camel10) 10 'camel10-result 'camel10 sav) (priv-worker001 (pre-data poi15) 10 'poi15-result 'poi15 sav)]) (defn priv101 [sav] [(priv-worker001 (pre-data xerces12) 10 'xerces12-result 'xerces12 sav) (priv-worker001 (pre-data tomcat) 10 'tomcat-result 'tomcat sav)]) (defn priv102 [sav] [(priv-worker001 (pre-data skarbonka) 10 'skarbonka-result 'skarbonka sav) (priv-worker001 (pre-data velocity14) 10 'velocity14-result 'velocity14 sav)]) (defn priv103 [sav] [(priv-worker001 (pre-data redaktor) 10 'redaktor-result 'redaktor sav) (priv-worker001 (pre-data xalan24) 10 'xalan24-result 'xalan24 sav)]) ;util fnc (defn get-acc [want-got] (let [n (/ (nrow (to-vect want-got)) 2) want (apply vector (take n want-got)) got (apply vector (drop n want-got)) together (map #(vector %1 %2) want got)] (loop [t together result 0] (if (empty? t) (* (/ result (* 2 n)) 100.0) (recur (rest t) (if (= (first (first t)) (second (first t))) (inc result) result)))))) (defn priv-worker002 [sav n att data datastring b] ;att = 10 (loc) n 1 sav [10 20] "n is the size of the query" (let [mybin (bind-columns (trans (butlast (efb2 data))) (sel data :cols (dec (ncol data)))) m (to-vect (trans mybin)) p (to-vect (trans data)) data1 (loop [i 0 result []] (if (= i (ncol data)) (trans result) (recur (inc i) (conj result (if (member? i (butlast sav)) (nth m i) (nth p i)))))) npriv (ourprivatize-data1 data1 sav b) ; p (to-vect (trans opriv)) ; npriv (loop [i 0 result []] ; (if (= i (ncol opriv)) ; (trans result) ; (recur ; (inc i) ; (conj result (if (member? i (butlast sav)) ; (nth m i) ; (nth p i)))))) que (get-queries mybin 1000 n sav) ans (bind-rows (query-scores que mybin mybin query-score1 att n 4) (query-scores que mybin npriv query-score3 att n 10))] [;(save (get-acc (sel ans :cols 3)) (str "./results/privacy-measure/"datastring"/priv5/"datastring"-query-results-" n ".dat")) (file-result (str "./results/privacy-measure/"datastring"/priv5/"datastring"-query-results-" n ".dat") (vector (get-acc (sel ans :cols 3)))) (save ans (str "./results/privacy-measure/"datastring"/priv5/"datastring"-query-results-" n ".csv") :delim \,)])) (defn priv104 [n b] [(priv-worker002 [10 20] n 10 ant13 'ant13 b) (priv-worker002 [10 20] n 10 arc 'arc b) (priv-worker002 [10 20] n 10 camel10 'camel10 b) (priv-worker002 [10 20] n 10 poi15 'poi15 b)]) (defn priv105 [n b] [(priv-worker002 [10 20] n 10 skarbonka 'skarbonka b) (priv-worker002 [10 20] n 10 velocity14 'velocity14 b) (priv-worker002 [10 20] n 10 redaktor 'redaktor b)]) (defn priv106 [n b] (priv-worker002 [10 20] n 10 xerces12 'xerces12 b)) (defn priv107 [n b] (priv-worker002 [10 20] n 10 xalan24 'xalan24 b)) (defn priv108 [n b] (priv-worker002 [10 20] n 10 tomcat 'tomcat b))