File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed
Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change 130130 [:one :one ])))
131131
132132(deftest invert-cat--throws
133+
134+
135+ (is (thrown? Exception
136+ (=-invert-cat 1.0 2.0
137+ 1.0 2.0
138+ :float
139+ [:one :two ])
140+ ; ; => Execution error at tech.v3.dataset.categorical/invert-categorical-map$fn (categorical.clj:177).
141+ ; ; Unable to find src value for numeric value 1.0
142+ ))
143+
133144 (is (thrown? Exception
134145 (=-invert-cat 1 2
135146 4 5
146157; ; => Execution error at tech.v3.dataset.categorical/invert-categorical-map$fn (categorical.clj:177).
147158; ; Unable to find src value for numeric value 1
148159
160+
161+ (defn- is-roundtrip-ok [raw-model-prediction]
162+ (let [
163+ train-ds
164+ (->
165+ (ds/->dataset {:target [:a :b :c ]})
166+ (ds/categorical->number [:target ])
167+ )
168+ cat-map (-> train-ds :target meta :categorical-map )
169+
170+ prediction-ds
171+ (->
172+ (ds/->dataset {:target raw-model-prediction})
173+ (ds/assoc-metadata [:target ] :categorical-map cat-map)
174+ (ds-cat/reverse-map-categorical-xforms ))]
175+ (is (= [:c :a :b ] (:target prediction-ds)))
176+ ))
177+
178+
179+ (deftest round-trip
180+ ; ; only this should pass
181+ (is-roundtrip-ok [0 1 2 ])
182+
183+ ; ; currently these all pass, while I would like them to all fail
184+ (is-roundtrip-ok [0.0 1.2 2.2 ])
185+ (is-roundtrip-ok [0.9 1.9 2.9 ])
186+ (is-roundtrip-ok (float-array [0 1 2 ]))
187+ (is-roundtrip-ok (float-array [0 1.9 2.9 ]))
188+ (is-roundtrip-ok (double-array [0 1.5 2.2 ])))
189+
You can’t perform that action at this time.
0 commit comments