Github user myui commented on a diff in the pull request:
https://github.com/apache/incubator-hivemall/pull/93#discussion_r125185167
--- Diff: core/src/main/java/hivemall/smile/utils/SmileExtUtils.java ---
@@ -78,6 +78,42 @@ private SmileExtUtils() {}
return attr;
}
+/**
+ * Q for {@link NumericAttribute}, C for {@link NominalAttribute}.
+ */
+ @Nullable
+ public static String resolveAttributes(@Nullable final Attribute[] opt)
+ throws UDFArgumentException {
+ if (opt == null) {
+ return null;
+ }
+
+ final int size = opt.length;
+ final String[] opts = new String[size];
+ final NumericAttribute immutableNumAttr = new NumericAttribute();
+
+ for (int i = 0; i < size; i++) {
+ final Attribute type = opt[i];
+ if (type.type == AttributeType.NUMERIC){
+ opts[i] = "Q";
+ } else if (type.type == AttributeType.NOMINAL) {
+ opts[i] = "C";
+ } else {
+ throw new UDFArgumentException("Unexpected type: " + type);
+ }
+ }
+
+ String opts_str = "";
--- End diff --
Better to use `StringBuilder` for `opts_str`.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---