test_class.file: modules/ml/src/test/java/org/apache/ignite/ml/recommendation/RecommendationTrainerTest.java
test_class.identifier: RecommendationTrainerTest
test_case.body: @Test
      public void testFit() {
          int size = 100;
          Random rnd = new Random(0L);
          Double[][] ratings = new Double[size][size];
          // Quadrant I contains "0", quadrant II contains "1", quadrant III contains "0", quadrant IV contains "1".
          for (int i = 0; i < size; i++) {
              for (int j = 0; j < size; j++) {
                  if (rnd.nextBoolean())
                      ratings[i][j] = ((i > size / 2) ^ (j > size / 2)) ? 1.0 : 0.0;
              }
          }
  
          int seq = 0;
          Map<Integer, ObjectSubjectRatingTriplet<Integer, Integer>> data = new HashMap<>();
          for (ObjectSubjectRatingTriplet<Integer, Integer> triplet : toList(ratings))
              data.put(seq++, triplet);
  
          RecommendationTrainer trainer = new RecommendationTrainer()
              .withLearningRate(50.0)
              .withBatchSize(10)
              .withK(2)
              .withMaxIterations(-1)
              .withMinMdlImprovement(0.5)
              .withLearningEnvironmentBuilder(LearningEnvironmentBuilder.defaultBuilder().withRNGSeed(1))
              .withTrainerEnvironment(LearningEnvironmentBuilder.defaultBuilder().withRNGSeed(1).buildForTrainer());
  
          RecommendationModel<Integer, Integer> mdl = trainer.fit(new LocalDatasetBuilder<>(data, 10));
  
          int incorrect = 0;
          for (ObjectSubjectRatingTriplet<Integer, Integer> triplet : toList(ratings)) {
              double prediction = Math.round(mdl.predict(triplet));
              if (Math.abs(prediction - triplet.getRating()) >= 1e-5) incorrect++;
          }
  
          assertEquals(0, incorrect);
      }
test_case.class_method_signature: RecommendationTrainerTest.testFit()
test_case.full_signature: @Test public void testFit()
test_case.identifier: testFit
test_case.invocations: nextBoolean toList put withTrainerEnvironment withLearningEnvironmentBuilder withMinMdlImprovement withMaxIterations withK withBatchSize withLearningRate withRNGSeed defaultBuilder buildForTrainer withRNGSeed defaultBuilder fit toList round predict abs getRating assertEquals
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testFit()
focal_class.declarator: environmentBuilder = LearningEnvironmentBuilder.defaultBuilder()
focal_class.modifier: private
focal_class.original_string: private LearningEnvironmentBuilder environmentBuilder = LearningEnvironmentBuilder.defaultBuilder();
focal_class.type: LearningEnvironmentBuilder
focal_class.var_name: environmentBuilder
focal_class.declarator: trainerEnvironment = environmentBuilder.buildForTrainer()
focal_class.modifier: private
focal_class.original_string: private LearningEnvironment trainerEnvironment = environmentBuilder.buildForTrainer();
focal_class.type: LearningEnvironment
focal_class.var_name: trainerEnvironment
focal_class.declarator: batchSize = 1000
focal_class.modifier: private
focal_class.original_string: private int batchSize = 1000;
focal_class.type: int
focal_class.var_name: batchSize
focal_class.declarator: regParam = 0.0
focal_class.modifier: private
focal_class.original_string: private double regParam = 0.0;
focal_class.type: double
focal_class.var_name: regParam
focal_class.declarator: learningRate = 10.0
focal_class.modifier: private
focal_class.original_string: private double learningRate = 10.0;
focal_class.type: double
focal_class.var_name: learningRate
focal_class.declarator: maxIterations = 1000
focal_class.modifier: private
focal_class.original_string: private int maxIterations = 1000;
focal_class.type: int
focal_class.var_name: maxIterations
focal_class.declarator: minMdlImprovement = 0.0
focal_class.modifier: private
focal_class.original_string: private double minMdlImprovement = 0.0;
focal_class.type: double
focal_class.var_name: minMdlImprovement
focal_class.declarator: k = 10
focal_class.modifier: private
focal_class.original_string: private int k = 10;
focal_class.type: int
focal_class.var_name: k
focal_class.file: modules/ml/src/main/java/org/apache/ignite/ml/recommendation/RecommendationTrainer.java
focal_class.identifier: RecommendationTrainer
focal_class.class_method_signature: RecommendationTrainer.fit(DatasetBuilder<Object, BinaryObject> datasetBuilder,
          String objFieldName, String subjFieldName, String ratingFieldName)
focal_class.full_signature: public RecommendationModel<Serializable, Serializable> fit(DatasetBuilder<Object, BinaryObject> datasetBuilder,
          String objFieldName, String subjFieldName, String ratingFieldName)
focal_class.identifier: fit
focal_class.modifiers: public
focal_class.parameters: (DatasetBuilder<Object, BinaryObject> datasetBuilder,
          String objFieldName, String subjFieldName, String ratingFieldName)
focal_class.return: RecommendationModel<Serializable, Serializable>
focal_class.signature: RecommendationModel<Serializable, Serializable> fit(DatasetBuilder<Object, BinaryObject> datasetBuilder,
          String objFieldName, String subjFieldName, String ratingFieldName)
focal_class.class_method_signature: RecommendationTrainer.fit(
          DatasetBuilder<K, ? extends ObjectSubjectRatingTriplet<O, S>> datasetBuilder)
focal_class.full_signature: public RecommendationModel<O, S> fit(
          DatasetBuilder<K, ? extends ObjectSubjectRatingTriplet<O, S>> datasetBuilder)
focal_class.identifier: fit
focal_class.modifiers: public
focal_class.parameters: (
          DatasetBuilder<K, ? extends ObjectSubjectRatingTriplet<O, S>> datasetBuilder)
focal_class.return: RecommendationModel<O, S>
focal_class.signature: RecommendationModel<O, S> fit(
          DatasetBuilder<K, ? extends ObjectSubjectRatingTriplet<O, S>> datasetBuilder)
focal_class.class_method_signature: RecommendationTrainer.train(
          Dataset<EmptyContext, RecommendationDatasetData<O, S>> dataset)
focal_class.full_signature: private RecommendationModel<O, S> train(
          Dataset<EmptyContext, RecommendationDatasetData<O, S>> dataset)
focal_class.identifier: train
focal_class.modifiers: private
focal_class.parameters: (
          Dataset<EmptyContext, RecommendationDatasetData<O, S>> dataset)
focal_class.return: RecommendationModel<O, S>
focal_class.signature: RecommendationModel<O, S> train(
          Dataset<EmptyContext, RecommendationDatasetData<O, S>> dataset)
focal_class.class_method_signature: RecommendationTrainer.calculateImprovement(MatrixFactorizationGradient<O, S> grad)
focal_class.full_signature: private double calculateImprovement(MatrixFactorizationGradient<O, S> grad)
focal_class.identifier: calculateImprovement
focal_class.modifiers: private
focal_class.parameters: (MatrixFactorizationGradient<O, S> grad)
focal_class.return: double
focal_class.signature: double calculateImprovement(MatrixFactorizationGradient<O, S> grad)
focal_class.class_method_signature: RecommendationTrainer.generateRandomVectorForEach(Collection<T> objects, Random rnd)
focal_class.full_signature: private Map<T, Vector> generateRandomVectorForEach(Collection<T> objects, Random rnd)
focal_class.identifier: generateRandomVectorForEach
focal_class.modifiers: private
focal_class.parameters: (Collection<T> objects, Random rnd)
focal_class.return: Map<T, Vector>
focal_class.signature: Map<T, Vector> generateRandomVectorForEach(Collection<T> objects, Random rnd)
focal_class.class_method_signature: RecommendationTrainer.join(Set<T> a, Set<T> b)
focal_class.full_signature: private static Set<T> join(Set<T> a, Set<T> b)
focal_class.identifier: join
focal_class.modifiers: private static
focal_class.parameters: (Set<T> a, Set<T> b)
focal_class.return: Set<T>
focal_class.signature: Set<T> join(Set<T> a, Set<T> b)
focal_class.class_method_signature: RecommendationTrainer.withLearningEnvironmentBuilder(LearningEnvironmentBuilder environmentBuilder)
focal_class.full_signature: public RecommendationTrainer withLearningEnvironmentBuilder(LearningEnvironmentBuilder environmentBuilder)
focal_class.identifier: withLearningEnvironmentBuilder
focal_class.modifiers: public
focal_class.parameters: (LearningEnvironmentBuilder environmentBuilder)
focal_class.return: RecommendationTrainer
focal_class.signature: RecommendationTrainer withLearningEnvironmentBuilder(LearningEnvironmentBuilder environmentBuilder)
focal_class.class_method_signature: RecommendationTrainer.withTrainerEnvironment(LearningEnvironment trainerEnvironment)
focal_class.full_signature: public RecommendationTrainer withTrainerEnvironment(LearningEnvironment trainerEnvironment)
focal_class.identifier: withTrainerEnvironment
focal_class.modifiers: public
focal_class.parameters: (LearningEnvironment trainerEnvironment)
focal_class.return: RecommendationTrainer
focal_class.signature: RecommendationTrainer withTrainerEnvironment(LearningEnvironment trainerEnvironment)
focal_class.class_method_signature: RecommendationTrainer.withBatchSize(int batchSize)
focal_class.full_signature: public RecommendationTrainer withBatchSize(int batchSize)
focal_class.identifier: withBatchSize
focal_class.modifiers: public
focal_class.parameters: (int batchSize)
focal_class.return: RecommendationTrainer
focal_class.signature: RecommendationTrainer withBatchSize(int batchSize)
focal_class.class_method_signature: RecommendationTrainer.withRegularizer(double regParam)
focal_class.full_signature: public RecommendationTrainer withRegularizer(double regParam)
focal_class.identifier: withRegularizer
focal_class.modifiers: public
focal_class.parameters: (double regParam)
focal_class.return: RecommendationTrainer
focal_class.signature: RecommendationTrainer withRegularizer(double regParam)
focal_class.class_method_signature: RecommendationTrainer.withLearningRate(double learningRate)
focal_class.full_signature: public RecommendationTrainer withLearningRate(double learningRate)
focal_class.identifier: withLearningRate
focal_class.modifiers: public
focal_class.parameters: (double learningRate)
focal_class.return: RecommendationTrainer
focal_class.signature: RecommendationTrainer withLearningRate(double learningRate)
focal_class.class_method_signature: RecommendationTrainer.withMaxIterations(int maxIterations)
focal_class.full_signature: public RecommendationTrainer withMaxIterations(int maxIterations)
focal_class.identifier: withMaxIterations
focal_class.modifiers: public
focal_class.parameters: (int maxIterations)
focal_class.return: RecommendationTrainer
focal_class.signature: RecommendationTrainer withMaxIterations(int maxIterations)
focal_class.class_method_signature: RecommendationTrainer.withMinMdlImprovement(double minMdlImprovement)
focal_class.full_signature: public RecommendationTrainer withMinMdlImprovement(double minMdlImprovement)
focal_class.identifier: withMinMdlImprovement
focal_class.modifiers: public
focal_class.parameters: (double minMdlImprovement)
focal_class.return: RecommendationTrainer
focal_class.signature: RecommendationTrainer withMinMdlImprovement(double minMdlImprovement)
focal_class.class_method_signature: RecommendationTrainer.withK(int k)
focal_class.full_signature: public RecommendationTrainer withK(int k)
focal_class.identifier: withK
focal_class.modifiers: public
focal_class.parameters: (int k)
focal_class.return: RecommendationTrainer
focal_class.signature: RecommendationTrainer withK(int k)
focal_class.class_method_signature: RecommendationTrainer.sum(
          MatrixFactorizationGradient<O, S> a,
          MatrixFactorizationGradient<O, S> b)
focal_class.full_signature: private static MatrixFactorizationGradient<O, S> sum(
          MatrixFactorizationGradient<O, S> a,
          MatrixFactorizationGradient<O, S> b)
focal_class.identifier: sum
focal_class.modifiers: private static
focal_class.parameters: (
          MatrixFactorizationGradient<O, S> a,
          MatrixFactorizationGradient<O, S> b)
focal_class.return: MatrixFactorizationGradient<O, S>
focal_class.signature: MatrixFactorizationGradient<O, S> sum(
          MatrixFactorizationGradient<O, S> a,
          MatrixFactorizationGradient<O, S> b)
focal_class.class_method_signature: RecommendationTrainer.sum(Map<T, Vector> a, Map<T, Vector> b)
focal_class.full_signature: private static Map<T, Vector> sum(Map<T, Vector> a, Map<T, Vector> b)
focal_class.identifier: sum
focal_class.modifiers: private static
focal_class.parameters: (Map<T, Vector> a, Map<T, Vector> b)
focal_class.return: Map<T, Vector>
focal_class.signature: Map<T, Vector> sum(Map<T, Vector> a, Map<T, Vector> b)
focal_class.class_method_signature: RecommendationTrainer.randomVector(int k, Random rnd)
focal_class.full_signature: private static Vector randomVector(int k, Random rnd)
focal_class.identifier: randomVector
focal_class.modifiers: private static
focal_class.parameters: (int k, Random rnd)
focal_class.return: Vector
focal_class.signature: Vector randomVector(int k, Random rnd)
focal_method.body: public RecommendationModel<Serializable, Serializable> fit(DatasetBuilder<Object, BinaryObject> datasetBuilder,
          String objFieldName, String subjFieldName, String ratingFieldName) {
          try (Dataset<EmptyContext, RecommendationDatasetData<Serializable, Serializable>> dataset = datasetBuilder.build(
              environmentBuilder,
              new EmptyContextBuilder<>(),
              new RecommendationBinaryDatasetDataBuilder(objFieldName, subjFieldName, ratingFieldName),
              trainerEnvironment
          )) {
              return train(dataset);
          }
          catch (Exception e) {
              throw new RuntimeException(e);
          }
      }
focal_method.class_method_signature: RecommendationTrainer.fit(DatasetBuilder<Object, BinaryObject> datasetBuilder,
          String objFieldName, String subjFieldName, String ratingFieldName)
focal_method.full_signature: public RecommendationModel<Serializable, Serializable> fit(DatasetBuilder<Object, BinaryObject> datasetBuilder,
          String objFieldName, String subjFieldName, String ratingFieldName)
focal_method.identifier: fit
focal_method.invocations: build train
focal_method.modifiers: public
focal_method.parameters: (DatasetBuilder<Object, BinaryObject> datasetBuilder,
          String objFieldName, String subjFieldName, String ratingFieldName)
focal_method.return: RecommendationModel<Serializable, Serializable>
focal_method.signature: RecommendationModel<Serializable, Serializable> fit(DatasetBuilder<Object, BinaryObject> datasetBuilder,
          String objFieldName, String subjFieldName, String ratingFieldName)