use of ml.shifu.shifu.core.dvarsel.VarSelWorkerResult in project shifu by ShifuML.
the class CandidateGenerator method getIndividual.
private List<CandidatePerf> getIndividual(Iterable<VarSelWorkerResult> workerResults) {
Map<Integer, List<Double>> errorMap = new HashMap<Integer, List<Double>>();
for (VarSelWorkerResult workerResult : workerResults) {
List<CandidatePerf> seedPerfList = workerResult.getSeedPerfList();
for (CandidatePerf perf : seedPerfList) {
if (!errorMap.containsKey(perf.getId())) {
errorMap.put(perf.getId(), new ArrayList<Double>());
}
errorMap.get(perf.getId()).add(perf.getVerror());
}
}
List<CandidatePerf> perfs = new ArrayList<CandidatePerf>(errorMap.size());
for (Entry<Integer, List<Double>> entry : errorMap.entrySet()) {
double vError = mean(entry.getValue());
perfs.add(new CandidatePerf(entry.getKey(), vError));
}
return perfs;
}
use of ml.shifu.shifu.core.dvarsel.VarSelWorkerResult in project shifu by ShifuML.
the class CandidateGeneratorTest method generateNext.
private CandidatePopulation generateNext(CandidatePopulation seed, Random random) {
List<VarSelWorkerResult> workerResults = new ArrayList<VarSelWorkerResult>();
workerResults.add(new VarSelWorkerResult(getCandidatePerfs(random, seed)));
workerResults.add(new VarSelWorkerResult(getCandidatePerfs(random, seed)));
workerResults.add(new VarSelWorkerResult(getCandidatePerfs(random, seed)));
final List<VarSelWorkerResult> workerResultList = Collections.unmodifiableList(workerResults);
Iterable<VarSelWorkerResult> results = new Iterable<VarSelWorkerResult>() {
@Override
public Iterator<VarSelWorkerResult> iterator() {
return workerResultList.iterator();
}
};
return generator.nextGeneration(results, seed);
}
use of ml.shifu.shifu.core.dvarsel.VarSelWorkerResult in project shifu by ShifuML.
the class WrapperWorkerConductorTest method testWrapperConductor.
@Test
public void testWrapperConductor() throws IOException {
ModelConfig modelConfig = CommonUtils.loadModelConfig("src/test/resources/example/cancer-judgement/ModelStore/ModelSet1/ModelConfig.json", RawSourceData.SourceType.LOCAL);
List<ColumnConfig> columnConfigList = CommonUtils.loadColumnConfigList("src/test/resources/example/cancer-judgement/ModelStore/ModelSet1/ColumnConfig.json", RawSourceData.SourceType.LOCAL);
WrapperWorkerConductor wrapper = new WrapperWorkerConductor(modelConfig, columnConfigList);
TrainingDataSet trainingDataSet = genTrainingDataSet(modelConfig, columnConfigList);
wrapper.retainData(trainingDataSet);
List<Integer> columnIdList = new ArrayList<Integer>();
for (int i = 2; i < 30; i++) {
columnIdList.add(i);
}
List<CandidateSeed> seedList = new ArrayList<CandidateSeed>();
for (int i = 0; i < 10; i++) {
seedList.add(new CandidateSeed(0, columnIdList.subList(i + 1, i + 7)));
}
wrapper.consumeMasterResult(new VarSelMasterResult(seedList));
VarSelWorkerResult workerResult = wrapper.generateVarSelResult();
Assert.assertNotNull(workerResult);
Assert.assertTrue(workerResult.getSeedPerfList().size() > 0);
}
use of ml.shifu.shifu.core.dvarsel.VarSelWorkerResult in project shifu by ShifuML.
the class VotedVarSelTest method testLrApp.
// @Test
public void testLrApp() throws IOException {
Properties props = new Properties();
props.setProperty(GuaguaConstants.MASTER_COMPUTABLE_CLASS, VarSelWorker.class.getName());
props.setProperty(GuaguaConstants.WORKER_COMPUTABLE_CLASS, VarSelMaster.class.getName());
props.setProperty(GuaguaConstants.GUAGUA_ITERATION_COUNT, "20");
props.setProperty(GuaguaConstants.GUAGUA_MASTER_RESULT_CLASS, VarSelMasterResult.class.getName());
props.setProperty(GuaguaConstants.GUAGUA_WORKER_RESULT_CLASS, VarSelWorkerResult.class.getName());
props.setProperty(GuaguaConstants.GUAGUA_INPUT_DIR, getClass().getResource("/example/cancer-judgement/DataStore/DataSet1/part-00").toString());
GuaguaUnitDriver<VarSelMasterResult, VarSelWorkerResult> driver = new GuaguaMRUnitDriver<VarSelMasterResult, VarSelWorkerResult>(props);
driver.run();
}
Aggregations