public static Object createObject(String cliString, Class<?> requiredType) throws Exception { return cliStringToObject(cliString, requiredType, null); }
@Override public void prepareForUseImpl(TaskMonitor monitor, ObjectRepository repository) { this.fileSource = sourceTypeOption.getValue(); this.hasStarted = false; } }
public static String objectToCLIString(Object obj, Class<?> requiredType) { if (obj == null) { return ""; } if (obj instanceof File) { return (FILE_PREFIX_STRING + ((File) obj).getPath()); } if (obj instanceof String) { return (INMEM_PREFIX_STRING + obj); } String className = classToCLIString(obj.getClass(), requiredType); if (obj instanceof Configurable) { //Add cli parser JavaCLIParser config = new JavaCLIParser(obj, ""); String subOptions = config.getOptions().getAsCLIString(); //String subOptions = ((Configurable) obj).getOptions().getAsCLIString(); if (subOptions.length() > 0) { return (className + " " + subOptions); } } return className; }
@Override public void setValueViaCLIString(String s) { if ((this.nullString != null) && ((s == null) || (s.length() == 0) || s.equals(this.nullString))) { this.currentValue = null; } else { try { this.currentValue = cliStringToObject(s, this.requiredType, null); } catch (Exception e) { throw new IllegalArgumentException("Problems with option: " + getName(), e); } } }
for (int i = 0; i < ensembleSize; i++) { try { ensemble[i] = (AdaptiveLearner) ClassOption.createObject(baseLearnerOption.getValueAsCLIString(), baseLearnerOption.getRequiredType()); } catch (Exception e) { logger.error("Unable to create members of the ensemble. Please check your CLI parameters"); throw new IllegalArgumentException(e); ensemble[i].setChangeDetector((ChangeDetector) this.driftDetectionMethodOption.getValue()); ensemble[i].init(builder, this.dataset, 1); // sequential
for (int i = 0; i < ensembleSize; i++) { try { ensemble[i] = (Learner) ClassOption.createObject(baseLearnerOption.getValueAsCLIString(), baseLearnerOption.getRequiredType()); } catch (Exception e) { logger.error("Unable to create members of the ensemble. Please check your CLI parameters");
@Override public String getValueAsCLIString() { if ((this.currentValue == null) && (this.nullString != null)) { return this.nullString; } return objectToCLIString(this.currentValue, this.requiredType); }
/** * Prepares the options of this class. * */ public void prepareClassOptions() { this.classOptionNamesToPreparedObjects = null; Option[] optionArray = getOptions().getOptionArray(); for (Option option : optionArray) { if (option instanceof ClassOption) { ClassOption classOption = (ClassOption) option; Object optionObj = classOption.materializeObject(); //monitor, if (optionObj instanceof Configurable) { JavaCLIParser config = new JavaCLIParser(optionObj, ""); } if (this.classOptionNamesToPreparedObjects == null) { this.classOptionNamesToPreparedObjects = new HashMap<String, Object>(); } this.classOptionNamesToPreparedObjects.put(option.getName(), optionObj); } } }
/** * Gets a prepared option of this class. * * @param opt the class option to get * @return an option stored in the dictionary */ public Object getPreparedClassOption(ClassOption opt) { return this.classOptionNamesToPreparedObjects.get(opt.getName()); }
public static void main(String[] args) throws Exception { //Main main = ClassOption.createObject(args, Main.class); DoTask main = ClassOption.createObject("DoTask -s 5 -l (Task1 -s 3 -l (Task2 -s 1))", DoTask.class); main.init(); }
for (int i = 0; i < ensembleSize; i++) { try { ensemble[i] = (AdaptiveLearner) ClassOption.createObject(baseLearnerOption.getValueAsCLIString(), baseLearnerOption.getRequiredType()); } catch (Exception e) { logger.error("Unable to create members of the ensemble. Please check your CLI parameters"); throw new IllegalArgumentException(e); ensemble[i].setChangeDetector((ChangeDetector) this.driftDetectionMethodOption.getValue()); ensemble[i].init(builder, this.dataset, 1); // sequential
@Override public void setValueViaCLIString(String s) { if ((this.nullString != null) && ((s == null) || (s.length() == 0) || s.equals(this.nullString))) { this.currentValue = null; } else { try { this.currentValue = cliStringToObject(s, this.requiredType, null); } catch (Exception e) { throw new IllegalArgumentException("Problems with option: " + getName(), e); } } }
for (int i = 0; i < ensembleSize; i++) { try { ensemble[i] = (Learner) ClassOption.createObject(baseLearnerOption.getValueAsCLIString(), baseLearnerOption.getRequiredType()); } catch (Exception e) { logger.error("Unable to create members of the ensemble. Please check your CLI parameters");
@Override public String getValueAsCLIString() { if ((this.currentValue == null) && (this.nullString != null)) { return this.nullString; } return objectToCLIString(this.currentValue, this.requiredType); }
Object optionObj = classOption.materializeObject(); //monitor,
@Override public void prepareForUseImpl(TaskMonitor monitor, ObjectRepository repository) { this.fileSource = sourceTypeOption.getValue(); this.hasStarted = false; } }
preqSource.setStreamSource((InstanceStream) this.streamTrainOption.getValue()); preqSource.setMaxNumInstances(instanceLimitOption.getValue()); preqSource.setSourceDelay(sourceDelayOption.getValue()); for (int i = 0; i < foldNumber; i++) { try { ensemble[i] = (Learner) ClassOption.createObject(learnerOption.getValueAsCLIString(), learnerOption.getRequiredType()); } catch (Exception e) { logger.error("Unable to create classifiers for the distributed evaluation. Please check your CLI parameters"); PerformanceEvaluator evaluatorOptionValue = this.evaluatorOption.getValue(); if (!PrequentialCVEvaluation.isLearnerAndEvaluatorCompatible(ensemble[0], evaluatorOptionValue)) { evaluatorOptionValue = getDefaultPerformanceEvaluatorForLearner(ensemble[0]);
public static <T> T createObject(String cliString, Class<T> requiredType) throws Exception { return cliStringToObject(cliString, requiredType, null); }
for (int i = 0; i < ensembleSize; i++) { try { ensemble[i] = (Learner) ClassOption.createObject(baseLearnerOption.getValueAsCLIString(), baseLearnerOption.getRequiredType()); } catch (Exception e) { logger.error("Unable to create members of the ensemble. Please check your CLI parameters");
public static String objectToCLIString(Object obj, Class<?> requiredType) { if (obj == null) { return ""; } if (obj instanceof File) { return (FILE_PREFIX_STRING + ((File) obj).getPath()); } if (obj instanceof String) { return (INMEM_PREFIX_STRING + obj); } String className = classToCLIString(obj.getClass(), requiredType); if (obj instanceof Configurable) { //String subOptions = ((Configurable) obj).getOptions().getAsCLIString(); //Add cli parser JavaCLIParser config = new JavaCLIParser(obj, ""); String subOptions = config.getOptions().getAsCLIString(); if (subOptions.length() > 0) { return (className + " " + subOptions); } } return className; }