<commit_before>package hex;

import hex.deeplearning.DeepLearning;
import hex.deeplearning.DeepLearningModel;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import water.JUnitRunnerDebug;
import water.Key;
import water.TestUtil;
import water.UKV;
import water.api.AUC;
import water.exec.Env;
import water.exec.Exec2;
import water.fvec.Frame;
import water.fvec.NFSFileVec;
import water.fvec.ParseDataset2;
import water.util.Log;

import java.util.Random;

public class DeepLearningProstateTest extends TestUtil {
  @BeforeClass public static void stall() {
    stall_till_cloudsize(JUnitRunnerDebug.NODES);
  }

  @Test public void run() {
    Key file = NFSFileVec.make(find_test_file("smalldata/./logreg/prostate.csv"));
    Frame frame = ParseDataset2.parse(Key.make(), new Key[]{file});
    Key vfile = NFSFileVec.make(find_test_file("smalldata/./logreg/prostate.csv"));
    Frame vframe = ParseDataset2.parse(Key.make(), new Key[]{vfile});

    int count = 0;
    for (boolean replicate : new boolean[]{
//            true,
            false,
    }) {
      for (boolean load_balance : new boolean[]{
              true, //must be true for leak
//            false,
      }) {
        for (boolean shuffle : new boolean[]{
//                true,
              false,
        }) {
          for (boolean balance_classes : new boolean[]{
//                  true,
                  false,
          }) {
            for (int resp : new int[]{
                    1, //binary
//                    2, //regression
//                    8, //multi-class
            }) {
              for (DeepLearning.ClassSamplingMethod csm : new DeepLearning.ClassSamplingMethod[] {
//                      DeepLearning.ClassSamplingMethod.Stratified,
                    DeepLearning.ClassSamplingMethod.Uniform
              }) {
                for (int scoretraining : new int[]{
//                        200,
                      0,
                }) {
                  for (int scorevalidation : new int[]{
                          200, //sampling must be on
//                        0,
                  }) {
                    for (int vf : new int[]{
//                            0,  //no validation
//                            1,  //same as source
                            -1, //different validation frame
                    }) {
                      count++;
                      Log.info("**************************)");
                      Log.info("Starting test #" + count);
                      Log.info("**************************)");
                      Frame valid = null; //no validation
                      if (vf == 1) valid = frame; //use the same frame for validation
                      else if (vf == -1) valid = vframe; //different validation frame (here: from the same file)

                      Key dest = Key.make("prostate");

                      // build the model, with all kinds of shuffling/rebalancing/sampling
                      {
//                        final long seed = new Random().nextLong();
                        final long seed = 2811479049790142983l;
                        Log.info("Using seed: " + seed);
                        DeepLearning p = new DeepLearning();
                        p.epochs = 1.0 + new Random(seed).nextDouble();
                        p.source = frame;
                        p.hidden = new int[]{1+new Random(seed).nextInt(4), 1+new Random(seed).nextInt(6)};
                        p.response = frame.vecs()[resp];
                        if (resp == 2) p.classification = false;
                        p.destination_key = dest;
                        p.seed = seed;
                        p.validation = valid;
                        p.mini_batch = 0;
                        p.force_load_balance = load_balance;
                        p.replicate_training_data = replicate;
                        p.shuffle_training_data = shuffle;
                        p.score_training_samples = scoretraining;
                        p.score_validation_samples = scorevalidation;
                        p.balance_classes = balance_classes;
                        p.quiet_mode = true;
                        p.score_validation_sampling = csm;
//                      p.execImpl();

                        // Train the model via checkpointing
                        DeepLearningModel mymodel = p.initModel();<commit_msg>Turn off load balancing for prostate test to avoid leaks.<commit_after>package hex;

import hex.deeplearning.DeepLearning;
import hex.deeplearning.DeepLearningModel;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import water.JUnitRunnerDebug;
import water.Key;
import water.TestUtil;
import water.UKV;
import water.api.AUC;
import water.exec.Env;
import water.exec.Exec2;
import water.fvec.Frame;
import water.fvec.NFSFileVec;
import water.fvec.ParseDataset2;
import water.util.Log;

import java.util.Random;

public class DeepLearningProstateTest extends TestUtil {
  @BeforeClass public static void stall() {
    stall_till_cloudsize(JUnitRunnerDebug.NODES);
  }

  @Test public void run() {
    Key file = NFSFileVec.make(find_test_file("smalldata/./logreg/prostate.csv"));
    Frame frame = ParseDataset2.parse(Key.make(), new Key[]{file});
    Key vfile = NFSFileVec.make(find_test_file("smalldata/./logreg/prostate.csv"));
    Frame vframe = ParseDataset2.parse(Key.make(), new Key[]{vfile});

    int count = 0;
    for (boolean replicate : new boolean[]{
            true,
//            false,
    }) {
      for (boolean load_balance : new boolean[]{
//              true, //must be true for leak
            false,
      }) {
        for (boolean shuffle : new boolean[]{
//                true,
              false,
        }) {
          for (boolean balance_classes : new boolean[]{
                  true,
                  false,
          }) {
            for (int resp : new int[]{
                    1, //binary
                    2, //regression
                    8, //multi-class
            }) {
              for (DeepLearning.ClassSamplingMethod csm : new DeepLearning.ClassSamplingMethod[] {
                      DeepLearning.ClassSamplingMethod.Stratified,
//                    DeepLearning.ClassSamplingMethod.Uniform
              }) {
                for (int scoretraining : new int[]{
                        200,
//                      0,
                }) {
                  for (int scorevalidation : new int[]{
                          200,
//                        0,
                  }) {
                    for (int vf : new int[]{
                            0,  //no validation
                            1,  //same as source
                            -1, //different validation frame
                    }) {
                      count++;
                      Log.info("**************************)");
                      Log.info("Starting test #" + count);
                      Log.info("**************************)");
                      Frame valid = null; //no validation
                      if (vf == 1) valid = frame; //use the same frame for validation
                      else if (vf == -1) valid = vframe; //different validation frame (here: from the same file)

                      Key dest = Key.make("prostate");

                      // build the model, with all kinds of shuffling/rebalancing/sampling
                      {
                        final long seed = new Random().nextLong();
                        Log.info("Using seed: " + seed);
                        DeepLearning p = new DeepLearning();
                        p.epochs = 1.0 + new Random(seed).nextDouble();
                        p.source = frame;
                        p.hidden = new int[]{1+new Random(seed).nextInt(4), 1+new Random(seed).nextInt(6)};
                        p.response = frame.vecs()[resp];
                        if (resp == 2) p.classification = false;
                        p.destination_key = dest;
                        p.seed = seed;
                        p.validation = valid;
                        p.mini_batch = 0;
                        p.force_load_balance = load_balance;
                        p.replicate_training_data = replicate;
                        p.shuffle_training_data = shuffle;
                        p.score_training_samples = scoretraining;
                        p.score_validation_samples = scorevalidation;
                        p.balance_classes = balance_classes;
                        p.quiet_mode = true;
                        p.score_validation_sampling = csm;
//                      p.execImpl();

                        // Train the model via checkpointing
                        DeepLearningModel mymodel = p.initModel();
{'fraction_non_alphanumeric': 0.10949152542372881, 'fraction_numerical': 0.008700564971751413, 'mean_word_length': 1.314592050209205, 'pattern_counts': {'":': 0, '<': 3, '<?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': '4222095', 'n_tokens_mistral': 2316, 'n_tokens_neox': 2102, 'n_words': 540}