Package com.cloudera.oryx.ml.serving.als.model

Examples of com.cloudera.oryx.ml.serving.als.model.ALSServingModel


public final class PopularRepresentativeItems extends AbstractALSResource {

  @GET
  @Produces({CSVMessageBodyWriter.TEXT_CSV, MediaType.APPLICATION_JSON})
  public List<String> get() {
    ALSServingModel model = getALSServingModel();
    int features = model.getFeatures();
    List<String> items = new ArrayList<>(features);
    float[] unitVector = new float[features];
    for (int i = 0; i < features; i++) {
      unitVector[i] = 1.0f;
      List<Pair<String,Double>> topIDDot = model.topN(new DotsFunction(unitVector), 1, null);
      items.add(topIDDot.isEmpty() ? null : topIDDot.get(0).getFirst());
      unitVector[i] = 0.0f; // reset
    }
    return items;
  }
View Full Code Here

TOP

Related Classes of com.cloudera.oryx.ml.serving.als.model.ALSServingModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.