丁云鹏 преди 8 месеца
родител
ревизия
50af2dc710
променени са 1 файла, в които са добавени 3 реда и са изтрити 3 реда
  1. 3 3
      recommend-model-produce/src/main/java/com/tzld/piaoquan/recommend/model/produce/xgboost/XGBoostTrain.java

+ 3 - 3
recommend-model-produce/src/main/java/com/tzld/piaoquan/recommend/model/produce/xgboost/XGBoostTrain.java

@@ -77,13 +77,13 @@ public class XGBoostTrain {
                     String[] fv = StringUtils.split(":");
                     map.put(fv[0], NumberUtils.toDouble(fv[1], 0.0));
                 }
+
+                int[] indices = new int[features.length];
+                double[] values = new double[features.length];
                 for (int i = 0; i < features.size(); i++) {
                     indices[i] = i;
                     values[i] = map.getOrDefault(features.get(i), 0.0);
                 }
-
-                int[] indices = new int[features.length];
-                double[] values = new double[features.length];
                 SparseVector vector = new SparseVector(indices.length, indices, values);
                 return RowFactory.create(label, vector);
             });