/** * get a Double parameter * @param key * @param defaultValue * @return */ public double getDoubleParameter(String key, double defaultValue) { return getDoubleParameter(null, key, defaultValue); }
/** * Use the PluggableParameters directly... * @param key * @param defaultValue */ @Deprecated protected double getDoubleParam(String key, double defaultValue) { return trainingParameters.getDoubleParameter(key, defaultValue); }
if (trainingParameters.getDoubleParameter(OLD_LL_THRESHOLD_PARAM, -1.) > 0. ) { display("WARNING: the training parameter: " + OLD_LL_THRESHOLD_PARAM + " has been deprecated. Please use " + LOG_LIKELIHOOD_THRESHOLD_DEFAULT + " instead"); if (trainingParameters.getDoubleParameter(LOG_LIKELIHOOD_THRESHOLD_PARAM, -1.) < 0. ) { trainingParameters.put(LOG_LIKELIHOOD_THRESHOLD_PARAM, trainingParameters.getDoubleParameter(OLD_LL_THRESHOLD_PARAM, LOG_LIKELIHOOD_THRESHOLD_DEFAULT)); llThreshold = trainingParameters.getDoubleParameter(LOG_LIKELIHOOD_THRESHOLD_PARAM, LOG_LIKELIHOOD_THRESHOLD_DEFAULT); if (useSimpleSmoothing) { _smoothingObservation = trainingParameters.getDoubleParameter(SMOOTHING_OBSERVATION_PARAM, SMOOTHING_OBSERVATION); trainingParameters.getBooleanParameter(GAUSSIAN_SMOOTHING_PARAM, GAUSSIAN_SMOOTHING_DEFAULT); if (useGaussianSmoothing) { sigma = trainingParameters.getDoubleParameter( GAUSSIAN_SMOOTHING_SIGMA_PARAM, GAUSSIAN_SMOOTHING_SIGMA_DEFAULT);
@Override public void init(TrainingParameters trainingParameters, Map<String, String> reportMap) { super.init(trainingParameters,reportMap); this.m = trainingParameters.getIntParameter(M_PARAM, M_DEFAULT); this.maxFctEval = trainingParameters.getIntParameter(MAX_FCT_EVAL_PARAM, MAX_FCT_EVAL_DEFAULT); this.threads = trainingParameters.getIntParameter(THREADS_PARAM, THREADS_DEFAULT); this.l1Cost = trainingParameters.getDoubleParameter(L1COST_PARAM, L1COST_DEFAULT); this.l2Cost = trainingParameters.getDoubleParameter(L2COST_PARAM, L2COST_DEFAULT); }
public AbstractModel doTrain(DataIndexer indexer) throws IOException { int iterations = getIterations(); int cutoff = getCutoff(); AbstractModel model; boolean useAverage = trainingParameters.getBooleanParameter("UseAverage", true); boolean useSkippedAveraging = trainingParameters.getBooleanParameter("UseSkippedAveraging", false); // overwrite otherwise it might not work if (useSkippedAveraging) useAverage = true; double stepSizeDecrease = trainingParameters.getDoubleParameter("StepSizeDecrease", 0); double tolerance = trainingParameters.getDoubleParameter("Tolerance", PerceptronTrainer.TOLERANCE_DEFAULT); this.setSkippedAveraging(useSkippedAveraging); if (stepSizeDecrease > 0) this.setStepSizeDecrease(stepSizeDecrease); this.setTolerance(tolerance); model = this.trainModel(iterations, indexer, cutoff, useAverage); return model; }
/** * get a Double parameter * @param key * @param defaultValue * @return */ public double getDoubleParameter(String key, double defaultValue) { return getDoubleParameter(null, key, defaultValue); }
/** * get a Double parameter * @param key * @param defaultValue * @return */ public double getDoubleParameter(String key, double defaultValue) { return getDoubleParameter(null, key, defaultValue); }
/** * Use the PluggableParameters directly... * @param key * @param defaultValue */ @Deprecated protected double getDoubleParam(String key, double defaultValue) { return trainingParameters.getDoubleParameter(key, defaultValue); }
/** * Use the PluggableParameters directly... * @param key * @param defaultValue */ @Deprecated protected double getDoubleParam(String key, double defaultValue) { return trainingParameters.getDoubleParameter(key, defaultValue); }
@Test public void testPutGet() { TrainingParameters tp = build("k1=v1,int.k2=123,str.k2=v3,str.k3=v4,boolean.k4=false,double.k5=123.45,k21=234.5"); Assert.assertEquals("v1", tp.getStringParameter("k1", "def")); Assert.assertEquals("def", tp.getStringParameter("k2", "def")); Assert.assertEquals("v3", tp.getStringParameter("str", "k2", "def")); Assert.assertEquals("def", tp.getStringParameter("str", "k4", "def")); Assert.assertEquals(-100, tp.getIntParameter("k11", -100)); tp.put("k11", 234); Assert.assertEquals(234, tp.getIntParameter("k11", -100)); Assert.assertEquals(123, tp.getIntParameter("int", "k2", -100)); Assert.assertEquals(-100, tp.getIntParameter("int", "k4", -100)); Assert.assertEquals(234.5, tp.getDoubleParameter("k21", -100), 0.001); tp.put("k21", 345.6); Assert.assertEquals(345.6, tp.getDoubleParameter("k21", -100), 0.001); // should be changed tp.putIfAbsent("k21", 456.7); Assert.assertEquals(345.6, tp.getDoubleParameter("k21", -100), 0.001); // should be unchanged Assert.assertEquals(123.45, tp.getDoubleParameter("double", "k5", -100), 0.001); Assert.assertEquals(true, tp.getBooleanParameter("k31", true)); tp.put("k31", false); Assert.assertEquals(false, tp.getBooleanParameter("k31", true)); Assert.assertEquals(false, tp.getBooleanParameter("boolean", "k4", true)); }
if (trainingParameters.getDoubleParameter(OLD_LL_THRESHOLD_PARAM, -1.) > 0. ) { display("WARNING: the training parameter: " + OLD_LL_THRESHOLD_PARAM + " has been deprecated. Please use " + LOG_LIKELIHOOD_THRESHOLD_DEFAULT + " instead"); if (trainingParameters.getDoubleParameter(LOG_LIKELIHOOD_THRESHOLD_PARAM, -1.) < 0. ) { trainingParameters.put(LOG_LIKELIHOOD_THRESHOLD_PARAM, trainingParameters.getDoubleParameter(OLD_LL_THRESHOLD_PARAM, LOG_LIKELIHOOD_THRESHOLD_DEFAULT)); llThreshold = trainingParameters.getDoubleParameter(LOG_LIKELIHOOD_THRESHOLD_PARAM, LOG_LIKELIHOOD_THRESHOLD_DEFAULT); if (useSimpleSmoothing) { _smoothingObservation = trainingParameters.getDoubleParameter(SMOOTHING_OBSERVATION_PARAM, SMOOTHING_OBSERVATION); trainingParameters.getBooleanParameter(GAUSSIAN_SMOOTHING_PARAM, GAUSSIAN_SMOOTHING_DEFAULT); if (useGaussianSmoothing) { sigma = trainingParameters.getDoubleParameter( GAUSSIAN_SMOOTHING_SIGMA_PARAM, GAUSSIAN_SMOOTHING_SIGMA_DEFAULT);
if (trainingParameters.getDoubleParameter(OLD_LL_THRESHOLD_PARAM, -1.) > 0. ) { display("WARNING: the training parameter: " + OLD_LL_THRESHOLD_PARAM + " has been deprecated. Please use " + LOG_LIKELIHOOD_THRESHOLD_DEFAULT + " instead"); if (trainingParameters.getDoubleParameter(LOG_LIKELIHOOD_THRESHOLD_PARAM, -1.) < 0. ) { trainingParameters.put(LOG_LIKELIHOOD_THRESHOLD_PARAM, trainingParameters.getDoubleParameter(OLD_LL_THRESHOLD_PARAM, LOG_LIKELIHOOD_THRESHOLD_DEFAULT)); llThreshold = trainingParameters.getDoubleParameter(LOG_LIKELIHOOD_THRESHOLD_PARAM, LOG_LIKELIHOOD_THRESHOLD_DEFAULT); if (useSimpleSmoothing) { _smoothingObservation = trainingParameters.getDoubleParameter(SMOOTHING_OBSERVATION_PARAM, SMOOTHING_OBSERVATION); trainingParameters.getBooleanParameter(GAUSSIAN_SMOOTHING_PARAM, GAUSSIAN_SMOOTHING_DEFAULT); if (useGaussianSmoothing) { sigma = trainingParameters.getDoubleParameter( GAUSSIAN_SMOOTHING_SIGMA_PARAM, GAUSSIAN_SMOOTHING_SIGMA_DEFAULT);
@Override public void init(TrainingParameters trainingParameters, Map<String, String> reportMap) { super.init(trainingParameters,reportMap); this.m = trainingParameters.getIntParameter(M_PARAM, M_DEFAULT); this.maxFctEval = trainingParameters.getIntParameter(MAX_FCT_EVAL_PARAM, MAX_FCT_EVAL_DEFAULT); this.threads = trainingParameters.getIntParameter(THREADS_PARAM, THREADS_DEFAULT); this.l1Cost = trainingParameters.getDoubleParameter(L1COST_PARAM, L1COST_DEFAULT); this.l2Cost = trainingParameters.getDoubleParameter(L2COST_PARAM, L2COST_DEFAULT); }
@Override public void init(TrainingParameters trainingParameters, Map<String, String> reportMap) { super.init(trainingParameters,reportMap); this.m = trainingParameters.getIntParameter(M_PARAM, M_DEFAULT); this.maxFctEval = trainingParameters.getIntParameter(MAX_FCT_EVAL_PARAM, MAX_FCT_EVAL_DEFAULT); this.threads = trainingParameters.getIntParameter(THREADS_PARAM, THREADS_DEFAULT); this.l1Cost = trainingParameters.getDoubleParameter(L1COST_PARAM, L1COST_DEFAULT); this.l2Cost = trainingParameters.getDoubleParameter(L2COST_PARAM, L2COST_DEFAULT); }
public AbstractModel doTrain(DataIndexer indexer) throws IOException { int iterations = getIterations(); int cutoff = getCutoff(); AbstractModel model; boolean useAverage = trainingParameters.getBooleanParameter("UseAverage", true); boolean useSkippedAveraging = trainingParameters.getBooleanParameter("UseSkippedAveraging", false); // overwrite otherwise it might not work if (useSkippedAveraging) useAverage = true; double stepSizeDecrease = trainingParameters.getDoubleParameter("StepSizeDecrease", 0); double tolerance = trainingParameters.getDoubleParameter("Tolerance", PerceptronTrainer.TOLERANCE_DEFAULT); this.setSkippedAveraging(useSkippedAveraging); if (stepSizeDecrease > 0) this.setStepSizeDecrease(stepSizeDecrease); this.setTolerance(tolerance); model = this.trainModel(iterations, indexer, cutoff, useAverage); return model; }
public AbstractModel doTrain(DataIndexer indexer) throws IOException { int iterations = getIterations(); int cutoff = getCutoff(); AbstractModel model; boolean useAverage = trainingParameters.getBooleanParameter("UseAverage", true); boolean useSkippedAveraging = trainingParameters.getBooleanParameter("UseSkippedAveraging", false); // overwrite otherwise it might not work if (useSkippedAveraging) useAverage = true; double stepSizeDecrease = trainingParameters.getDoubleParameter("StepSizeDecrease", 0); double tolerance = trainingParameters.getDoubleParameter("Tolerance", PerceptronTrainer.TOLERANCE_DEFAULT); this.setSkippedAveraging(useSkippedAveraging); if (stepSizeDecrease > 0) this.setStepSizeDecrease(stepSizeDecrease); this.setTolerance(tolerance); model = this.trainModel(iterations, indexer, cutoff, useAverage); return model; }