ScikitLearnWrapper extends ASupervisedLearner<ILabeledInstance, ILabeledDataset<? extends ILabeledInstance>, P, B> implements ISupervisedLearner<ILabeledInstance, ILabeledDataset<? extends ILabeledInstance>> { public static String getImportString(final Collection<String> imports) { return (imports == null || imports.isEmpty()) ? "" : "import " + StringUtils.join(imports, "\nimport "); } ScikitLearnWrapper(final String constructInstruction, final String imports, final boolean withModelDump, final EScikitLearnProblemType problemType);  ScikitLearnWrapper(final String constructInstruction, final String imports, final EScikitLearnProblemType problemType);  ScikitLearnWrapper(final String constructInstruction, final String imports, final File trainedModelPath, final EScikitLearnProblemType problemType); EScikitLearnProblemType getProblemType(); IPythonConfig getPythonConfig(); void setPythonConfig(final IPythonConfig pythonConfig); @SuppressWarnings("unchecked") @Override void fit(final ILabeledDataset<? extends ILabeledInstance> data); @SuppressWarnings("unchecked") @Override P predict(final ILabeledInstance instance); @SuppressWarnings("unchecked") @Override B predict(final ILabeledInstance[] dTest); static String createImportStatementFromImportFolder(final File importsFolder, final boolean keepNamespace); static String getImportString(final Collection<String> imports); List<List<Double>> getRawLastClassificationResults(); void setProblemType(final EScikitLearnProblemType problemType); void setSeed(final long seed); void setTimeout(final Timeout timeout); void setTargets(final int... targetColumns); void setModelPath(final File modelFile); File getModelPath(); double[] distributionForInstance(final ILabeledInstance instance); @Override String toString();  }
@Test public void fitAndPredict() throws Exception { List<String> imports = Arrays.asList("sklearn", "sklearn.ensemble"); String constructInstruction = "sklearn.ensemble.RandomForestClassifier(n_estimators=100)"; ScikitLearnWrapper<ISingleLabelClassification, ISingleLabelClassificationPredictionBatch> slw = new ScikitLearnWrapper<>(constructInstruction, ScikitLearnWrapper.getImportString(imports), true, EScikitLearnProblemType.CLASSIFICATION); ILabeledDataset<ILabeledInstance> dataset = this.loadARFF(CLASSIFICATION_ARFF); RandomHoldoutSplitter<ILabeledDataset<ILabeledInstance>> splitter = new RandomHoldoutSplitter<>(new Random(), .7); IDatasetSplitSet<ILabeledDataset<ILabeledInstance>> set = splitter.nextSplitSet(dataset); long startTrain = System.currentTimeMillis(); ISingleLabelClassificationPredictionBatch preds = slw.fitAndPredict(set.getFolds(0).get(0), set.getFolds(0).get(1)); System.out.println("Call took: " + (System.currentTimeMillis() - startTrain) + "ms"); assertNotNull(preds); }