@Test public void testGetParameters() { TrainingParameters tp = build("k1=v1,n1.k2=v2,n2.k3=v3,n1.k4=v4"); assertEquals(build("k1=v1"), tp.getParameters(null)); assertEquals(build("k2=v2,k4=v4"), tp.getParameters("n1")); assertEquals(build("k3=v3"), tp.getParameters("n2")); Assert.assertTrue(tp.getParameters("n3").getSettings().isEmpty()); }
public TrainingParameters getParameters(String namespace) { TrainingParameters params = new TrainingParameters(); Map<String, Object> settings = getObjectSettings(namespace); for (Entry<String, Object> entry: settings.entrySet()) { String key = entry.getKey(); Object value = entry.getValue();; if (value instanceof Integer) { params.put(key, (Integer)value); } else if (value instanceof Double) { params.put(key, (Double)value); } else if (value instanceof Boolean) { params.put(key, (Boolean)value); } else { params.put(key, (String)value); } } return params; }
TrainingParameters { public TrainingParameters getParameters(String namespace) { TrainingParameters params = new TrainingParameters(); Map<String, Object> settings = getObjectSettings(namespace); for (Entry<String, Object> entry: settings.entrySet()) { String key = entry.getKey(); Object value = entry.getValue();; if (value instanceof Integer) { params.put(key, (Integer)value); } else if (value instanceof Double) { params.put(key, (Double)value); } else if (value instanceof Boolean) { params.put(key, (Boolean)value); } else { params.put(key, (String)value); } } return params; } }
TrainingParameters { public TrainingParameters getParameters(String namespace) { TrainingParameters params = new TrainingParameters(); Map<String, Object> settings = getObjectSettings(namespace); for (Entry<String, Object> entry: settings.entrySet()) { String key = entry.getKey(); Object value = entry.getValue();; if (value instanceof Integer) { params.put(key, (Integer)value); } else if (value instanceof Double) { params.put(key, (Double)value); } else if (value instanceof Boolean) { params.put(key, (Boolean)value); } else { params.put(key, (String)value); } } return params; } TrainingParameters();  TrainingParameters(TrainingParameters trainingParameters);  TrainingParameters(Map<String,String> map);  TrainingParameters(InputStream in); }
TrainingParameters { public TrainingParameters getParameters(String namespace) { TrainingParameters params = new TrainingParameters(); Map<String, Object> settings = getObjectSettings(namespace); for (Entry<String, Object> entry: settings.entrySet()) { String key = entry.getKey(); Object value = entry.getValue();; if (value instanceof Integer) { params.put(key, (Integer)value); } else if (value instanceof Double) { params.put(key, (Double)value); } else if (value instanceof Boolean) { params.put(key, (Boolean)value); } else { params.put(key, (String)value); } } return params; } TrainingParameters();  TrainingParameters(TrainingParameters trainingParameters);  TrainingParameters(Map<String,String> map);  TrainingParameters(InputStream in); String algorithm(String namespace); String algorithm(); Map<String, String> getSettings(String namespace); Map<String, String> getSettings(); Map<String, Object> getObjectSettings(String namespace); Map<String, Object> getObjectSettings(); TrainingParameters getParameters(String namespace); void putIfAbsent(String namespace, String key, String value); void putIfAbsent(String key, String value); void putIfAbsent(String namespace, String key, int value); void putIfAbsent(String key, int value); void putIfAbsent(String namespace, String key, double value); void putIfAbsent(String key, double value); void putIfAbsent(String namespace, String key, boolean value); void putIfAbsent(String key, boolean value); void put(String namespace, String key, String value); void put(String key, String value); void put(String namespace, String key, int value); void put(String key, int value); void put(String namespace, String key, double value); void put(String key, double value); void put(String namespace, String key, boolean value); void put(String key, boolean value); void serialize(OutputStream out); String getStringParameter(String key, String defaultValue); String getStringParameter(String namespace, String key, String defaultValue); int getIntParameter(String key, int defaultValue); int getIntParameter(String namespace, String key, int defaultValue); double getDoubleParameter(String key, double defaultValue); double getDoubleParameter(String namespace, String key, double defaultValue); boolean getBooleanParameter(String key, boolean defaultValue); boolean getBooleanParameter(String namespace, String key, boolean defaultValue); static TrainingParameters defaultParams(); }
TrainingParameters { public TrainingParameters getParameters(String namespace) { TrainingParameters params = new TrainingParameters(); Map<String, Object> settings = getObjectSettings(namespace); for (Entry<String, Object> entry: settings.entrySet()) { String key = entry.getKey(); Object value = entry.getValue();; if (value instanceof Integer) { params.put(key, (Integer)value); } else if (value instanceof Double) { params.put(key, (Double)value); } else if (value instanceof Boolean) { params.put(key, (Boolean)value); } else { params.put(key, (String)value); } } return params; } TrainingParameters();  TrainingParameters(TrainingParameters trainingParameters);  TrainingParameters(Map<String,String> map);  TrainingParameters(InputStream in); String algorithm(String namespace); String algorithm(); Map<String, String> getSettings(String namespace); Map<String, String> getSettings(); Map<String, Object> getObjectSettings(String namespace); Map<String, Object> getObjectSettings(); TrainingParameters getParameters(String namespace); void putIfAbsent(String namespace, String key, String value); void putIfAbsent(String key, String value); void putIfAbsent(String namespace, String key, int value); void putIfAbsent(String key, int value); void putIfAbsent(String namespace, String key, double value); void putIfAbsent(String key, double value); void putIfAbsent(String namespace, String key, boolean value); void putIfAbsent(String key, boolean value); void put(String namespace, String key, String value); void put(String key, String value); void put(String namespace, String key, int value); void put(String key, int value); void put(String namespace, String key, double value); void put(String key, double value); void put(String namespace, String key, boolean value); void put(String key, boolean value); void serialize(OutputStream out); String getStringParameter(String key, String defaultValue); String getStringParameter(String namespace, String key, String defaultValue); int getIntParameter(String key, int defaultValue); int getIntParameter(String namespace, String key, int defaultValue); double getDoubleParameter(String key, double defaultValue); double getDoubleParameter(String namespace, String key, double defaultValue); boolean getBooleanParameter(String key, boolean defaultValue); boolean getBooleanParameter(String namespace, String key, boolean defaultValue); static TrainingParameters defaultParams(); static final String ALGORITHM_PARAM; static final String TRAINER_TYPE_PARAM; static final String ITERATIONS_PARAM; static final String CUTOFF_PARAM; static final String THREADS_PARAM; }