File tree 2 files changed +19
-3
lines changed
neanderthal/tech/v3/dataset
2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change 11
11
[org.tribuo.regression.xgboost XGBoostRegressionTrainer]))
12
12
13
13
14
-
15
14
(defn classification-example-ds
16
15
[x]
17
16
(let [x (if (integer? x)
80
79
(is (= " class org.tribuo.classification.dtree.CARTClassificationTrainer"
81
80
(str (class trainer))))))
82
81
82
+
83
+ (deftest test-keyword-name
84
+ (testing " string name (OK)"
85
+ (is (-> (ds/->dataset [{" a" 1 }] {:dataset-name " string name" })
86
+ (tribuo/make-regression-datasource " a" ))))
87
+ (testing " keyword name (Error)"
88
+ (is (-> (ds/->dataset [{" a" 1 }] {:dataset-name :keyword/name })
89
+ (tribuo/make-regression-datasource " a" )))))
Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ _unnamed [5 1]:
55
55
[org.tribuo.regression.evaluation RegressionEvaluator RegressionEvaluation]
56
56
[com.oracle.labs.mlrg.olcut.config ConfigurationManager]
57
57
[com.oracle.labs.mlrg.olcut.config.json JsonConfigFactory]))
58
-
58
+
59
59
60
60
(set! *warn-on-reflection* true )
61
61
@@ -157,13 +157,22 @@ _unnamed [5 1]:
157
157
cnames (->double-array (feat-data idx))))
158
158
(meta outputs))))
159
159
160
+ (defn- safe-str
161
+ [n]
162
+ (cond (string? n)
163
+ n
164
+ (or (keyword? n) (symbol? n))
165
+ (if-let [nn (namespace n)]
166
+ (str nn " /" (name n))
167
+ (str (name n)))))
168
+
160
169
161
170
(defn- ds->datasource
162
171
^DataSource [ds ds->outputs]
163
172
(let [examples (ds->examples ds ds->outputs)
164
173
{:keys [output-factory provenance]} (meta examples)
165
174
provenance (or provenance
166
- (SimpleDataSourceProvenance. (:name (meta ds)) output-factory))]
175
+ (SimpleDataSourceProvenance. (safe-str ( :name (meta ds) )) output-factory))]
167
176
(when-not output-factory
168
177
(throw (RuntimeException. " Output factory not present in example metadata" )))
169
178
(reify DataSource
You can’t perform that action at this time.
0 commit comments