<commit_before>package org.sameersingh.mf

import org.junit._
import Assert._
import scala.collection.mutable.ArrayBuffer
import org.sameersingh.mf.learner.{Trainer, BatchTrainer, SGDTrainer}
import scala.util.Random

@Test
class LearningTest {

  val random = new Random(0)

  def smallSingleMatrix(numComps: Int, noiseVar: Double = 0.0) = {
    val numRows = 10
    val numCols = 10
    val trainingProp = 0.5
    val rowFactors = new DoubleDenseMatrix("r_t", numComps)
    val colFactors = new DoubleDenseMatrix("c_t", numComps)
    for (k <- 0 until numComps) {
      for (i <- 0 until numRows) {
        rowFactors(SimpleID(i, "r"), k) = random.nextGaussian() / math.sqrt(numComps.toDouble)
      }
      for (j <- 0 until numCols) {
        colFactors(SimpleID(j, "c"), k) = random.nextGaussian() / math.sqrt(numComps.toDouble)
      }
    }
    //println("L2 R value     : " + new L2Regularization(rowFactors, new ParamDouble("w", 1.0)).value)
    //println("L2 C value     : " + new L2Regularization(colFactors, new ParamDouble("w", 1.0)).value)

    //println(rowFactors)
    //println(colFactors)

    val genCells = new ArrayBuffer[Cell]
    val matrix = new ObservedMatrix {
      val cells = genCells

      def name = "testMatrix"<commit_msg>minor fix<commit_after>package org.sameersingh.mf

import org.junit._
import Assert._
import scala.collection.mutable.ArrayBuffer
import org.sameersingh.mf.learner.{Trainer, BatchTrainer, SGDTrainer}
import scala.util.Random

@Test
class LearningTest {

  implicit val random = new Random(0)

  def smallSingleMatrix(numComps: Int, noiseVar: Double = 0.0) = {
    val numRows = 10
    val numCols = 10
    val trainingProp = 0.5
    val rowFactors = new DoubleDenseMatrix("r_t", numComps)
    val colFactors = new DoubleDenseMatrix("c_t", numComps)
    for (k <- 0 until numComps) {
      for (i <- 0 until numRows) {
        rowFactors(SimpleID(i, "r"), k) = random.nextGaussian() / math.sqrt(numComps.toDouble)
      }
      for (j <- 0 until numCols) {
        colFactors(SimpleID(j, "c"), k) = random.nextGaussian() / math.sqrt(numComps.toDouble)
      }
    }
    //println("L2 R value     : " + new L2Regularization(rowFactors, new ParamDouble("w", 1.0)).value)
    //println("L2 C value     : " + new L2Regularization(colFactors, new ParamDouble("w", 1.0)).value)

    //println(rowFactors)
    //println(colFactors)

    val genCells = new ArrayBuffer[Cell]
    val matrix = new ObservedMatrix {
      val cells = genCells

      def name = "testMatrix"
{'fraction_non_alphanumeric': 0.12395709177592372, 'fraction_numerical': 0.015891934843067144, 'mean_word_length': 3.2036727879799667, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5007322', 'n_tokens_mistral': 904, 'n_tokens_neox': 859, 'n_words': 207}