// Path: src/main/java/RFLogger.java
// public class RFLogger {
// 
//     private String fileName = "./classes/log.properties";
//     private static java.util.logging.Logger logger = null;
//     
//     private static ConsoleHandler consoleHandler;
//     
//     private static SimpleFormatter simpleFormatter;
// 
//     private RFLogger() {
// 
//         // Create the logger.
//         logger = java.util.logging.Logger.getLogger(RFLogger.class.getName());
// 
//         try {
//             java.util.logging.LogManager.getLogManager().readConfiguration(new FileInputStream(fileName));
// 
//         }
//         catch (IOException e) {
//             System.out.println("Unable to configure logging for " + fileName);
// 
//             e.printStackTrace();
// 
//             System.out.println("Resorting to console handler.");
// 
//         
//             //Create consoleHandler.
//             consoleHandler = new ConsoleHandler();
//         
//             //Assigning handler to logger object.
//             logger.addHandler(consoleHandler);
//         
//             //Setting levels to handler and logger.
//             consoleHandler.setLevel(Level.INFO);
//             logger.setLevel(Level.ALL);
//         
//             // Creating SimpleFormatter for human readable format.
//             simpleFormatter = new SimpleFormatter();
// 
//             // Setting formatter to all handlers.
//             consoleHandler.setFormatter(simpleFormatter);
// 
//             // Remove parent handlers in order to respect our formatting only.
//             // logger.setUseParentHandlers(false);
//         }
//     }
//     
//     private static java.util.logging.Logger getLogger() {
//         if(logger == null){
//             new RFLogger();
//         }
//         return logger;
//     }
//     
//     public static void log(Level level, String msg, Throwable thrown){
//         getLogger().log(level, msg, thrown);
//     }
//     
//     public static void log(Level level, String msg){
//         getLogger().log(level, msg);
//     }
// 
// }


import com.kogalur.randomforest.RFLogger;
import java.util.logging.Level;
import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.types.DataTypes;
import org.apache.spark.sql.types.DataType;
import org.apache.spark.sql.types.StructField;
import org.apache.spark.sql.types.StructType;
import org.apache.spark.sql.Row;
import org.apache.spark.ml.feature.StringIndexer;
import java.lang.Math;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import java.util.Random;
import java.util.Vector;

        mode = new String("grow");        

        this.dataset = dataset;
        this.formula = formula;

        // Extract the column names from the dataset.
        columnName = dataset.columns();

        setDefaultModelArg();

        ensembleArg = new EnsembleArg(mode, family);
    }

    

    private void parseFormula() {

        boolean bigRFlag, complementFlag;
        
        formula = formula.replaceAll("\\ ", "");
      
        formulaU = formula.split("~");

        // ytry can be set via the RF-U formula.  Thus we set the
        // default and user specified values here, directly.
        ytry = 0;
        
        if (formulaU.length != 2) {
            // Bad Formula.  Throw exception.
// Path: src/main/java/RFLogger.java
// public class RFLogger {
// 
//     private String fileName = "./classes/log.properties";
//     private static java.util.logging.Logger logger = null;
//     
//     private static ConsoleHandler consoleHandler;
//     
//     private static SimpleFormatter simpleFormatter;
// 
//     private RFLogger() {
// 
//         // Create the logger.
//         logger = java.util.logging.Logger.getLogger(RFLogger.class.getName());
// 
//         try {
//             java.util.logging.LogManager.getLogManager().readConfiguration(new FileInputStream(fileName));
// 
//         }
//         catch (IOException e) {
//             System.out.println("Unable to configure logging for " + fileName);
// 
//             e.printStackTrace();
// 
//             System.out.println("Resorting to console handler.");
// 
//         
//             //Create consoleHandler.
//             consoleHandler = new ConsoleHandler();
//         
//             //Assigning handler to logger object.
//             logger.addHandler(consoleHandler);
//         
//             //Setting levels to handler and logger.
//             consoleHandler.setLevel(Level.INFO);
//             logger.setLevel(Level.ALL);
//         
//             // Creating SimpleFormatter for human readable format.
//             simpleFormatter = new SimpleFormatter();
// 
//             // Setting formatter to all handlers.
//             consoleHandler.setFormatter(simpleFormatter);
// 
//             // Remove parent handlers in order to respect our formatting only.
//             // logger.setUseParentHandlers(false);
//         }
//     }
//     
//     private static java.util.logging.Logger getLogger() {
//         if(logger == null){
//             new RFLogger();
//         }
//         return logger;
//     }
//     
//     public static void log(Level level, String msg, Throwable thrown){
//         getLogger().log(level, msg, thrown);
//     }
//     
//     public static void log(Level level, String msg){
//         getLogger().log(level, msg);
//     }
// 
// }


// Path: src/main/java/ModelArg.java
import com.kogalur.randomforest.RFLogger;
import java.util.logging.Level;
import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.types.DataTypes;
import org.apache.spark.sql.types.DataType;
import org.apache.spark.sql.types.StructField;
import org.apache.spark.sql.types.StructType;
import org.apache.spark.sql.Row;
import org.apache.spark.ml.feature.StringIndexer;
import java.lang.Math;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import java.util.Random;
import java.util.Vector;


        mode = new String("grow");        

        this.dataset = dataset;
        this.formula = formula;

        // Extract the column names from the dataset.
        columnName = dataset.columns();

        setDefaultModelArg();

        ensembleArg = new EnsembleArg(mode, family);
    }

    

    private void parseFormula() {

        boolean bigRFlag, complementFlag;
        
        formula = formula.replaceAll("\\ ", "");
      
        formulaU = formula.split("~");

        // ytry can be set via the RF-U formula.  Thus we set the
        // default and user specified values here, directly.
        ytry = 0;
        
        if (formulaU.length != 2) {
            // Bad Formula.  Throw exception.
            RFLogger.log(Level.SEVERE, "Unknown Formula Syntax:  " + formula);