Search in sources :

Example 21 with ModelConfig

use of ml.shifu.shifu.container.obj.ModelConfig in project shifu by ShifuML.

the class ModelInspectorTest method testValidateMeta.

@Test
public void testValidateMeta() throws Exception {
    ModelConfig config = CommonUtils.loadModelConfig();
    instance.checkMeta(config);
}
Also used : ModelConfig(ml.shifu.shifu.container.obj.ModelConfig) Test(org.testng.annotations.Test)

Example 22 with ModelConfig

use of ml.shifu.shifu.container.obj.ModelConfig in project shifu by ShifuML.

the class ModelInspectorTest method testValidateNullStep.

@Test
public void testValidateNullStep() throws Exception {
    ModelConfig config = CommonUtils.loadModelConfig();
    ValidateResult result = instance.probe(config, null);
    Assert.assertTrue(result.getStatus());
}
Also used : ModelConfig(ml.shifu.shifu.container.obj.ModelConfig) ValidateResult(ml.shifu.shifu.container.meta.ValidateResult) Test(org.testng.annotations.Test)

Example 23 with ModelConfig

use of ml.shifu.shifu.container.obj.ModelConfig in project shifu by ShifuML.

the class PigExecutorTest method test.

// @Test
public void test() throws IOException {
    PigExecutor exec = PigExecutor.getExecutor();
    ModelConfig modelConfig = CommonUtils.loadModelConfig("src/test/resources/example/cancer-judgement/ModelStore/ModelSet1/ModelConfig.json", SourceType.LOCAL);
    Environment.setProperty(Environment.SHIFU_HOME, ".");
    modelConfig.getDataSet().setSource(SourceType.LOCAL);
    exec.submitJob(modelConfig, "src/test/java/ml/shifu/shifu/pig/pigTest.pig");
    FileUtils.deleteQuietly(new File("ModelConfig.json"));
    FileUtils.deleteDirectory(new File("ModelSets"));
}
Also used : ModelConfig(ml.shifu.shifu.container.obj.ModelConfig) File(java.io.File)

Example 24 with ModelConfig

use of ml.shifu.shifu.container.obj.ModelConfig in project shifu by ShifuML.

the class CommonUtilsTest method syncTest.

// @Test
public void syncTest() throws IOException {
    ModelConfig config = ModelConfig.createInitModelConfig(".", ALGORITHM.NN, "test", false);
    config.setModelSetName("testModel");
    jsonMapper.writerWithDefaultPrettyPrinter().writeValue(new File("ModelConfig.json"), config);
    ColumnConfig col = new ColumnConfig();
    col.setColumnName("ColumnA");
    List<ColumnConfig> columnConfigList = new ArrayList<ColumnConfig>();
    columnConfigList.add(col);
    config.getDataSet().setSource(SourceType.LOCAL);
    ;
    jsonMapper.writerWithDefaultPrettyPrinter().writeValue(new File("ColumnConfig.json"), columnConfigList);
    File file = null;
    file = new File("models");
    if (!file.exists()) {
        FileUtils.forceMkdir(file);
    }
    file = new File("models/model1.nn");
    if (!file.exists()) {
        if (file.createNewFile()) {
            BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), Constants.DEFAULT_CHARSET));
            writer.write("test string");
            writer.close();
        } else {
            LOG.warn("Create file {} failed", file.getAbsolutePath());
        }
    }
    file = new File("EvalSets/test");
    if (!file.exists()) {
        FileUtils.forceMkdir(file);
    }
    file = new File("EvalSets/test/EvalConfig.json");
    if (!file.exists()) {
        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), Constants.DEFAULT_CHARSET));
        writer.write("test string");
        writer.close();
    }
    CommonUtils.copyConfFromLocalToHDFS(config, new PathFinder(config));
    file = new File("ModelSets");
    Assert.assertTrue(file.exists());
    file = new File("ModelSets/testModel");
    Assert.assertTrue(file.exists());
    file = new File("ModelSets/testModel/ModelConfig.json");
    Assert.assertTrue(file.exists());
    file = new File("ModelSets/testModel/ColumnConfig.json");
    Assert.assertTrue(file.exists());
    file = new File("ModelSets/testModel/ReasonCodeMap.json");
    Assert.assertTrue(file.exists());
    file = new File("ModelSets/testModel/models/model1.nn");
    Assert.assertTrue(file.exists());
    file = new File("ModelSets/testModel/EvalSets/test/EvalConfig.json");
    Assert.assertTrue(file.exists());
    file = new File("ModelSets");
    if (file.exists()) {
        FileUtils.deleteDirectory(file);
    }
    file = new File("ColumnConfig.json");
    FileUtils.deleteQuietly(file);
    file = new File("ModelConfig.json");
    FileUtils.deleteQuietly(file);
    FileUtils.deleteDirectory(new File("models"));
    FileUtils.deleteDirectory(new File("EvalSets"));
}
Also used : ModelConfig(ml.shifu.shifu.container.obj.ModelConfig) ColumnConfig(ml.shifu.shifu.container.obj.ColumnConfig) FileOutputStream(java.io.FileOutputStream) ArrayList(java.util.ArrayList) OutputStreamWriter(java.io.OutputStreamWriter) PathFinder(ml.shifu.shifu.fs.PathFinder) File(java.io.File) BufferedWriter(java.io.BufferedWriter)

Example 25 with ModelConfig

use of ml.shifu.shifu.container.obj.ModelConfig in project shifu by ShifuML.

the class CommonUtilsTest method updateColumnConfigFlagsTest.

// @Test
public void updateColumnConfigFlagsTest() throws IOException {
    ModelConfig config = ModelConfig.createInitModelConfig("test", ALGORITHM.NN, "test", false);
    config.getDataSet().setMetaColumnNameFile("./conf/meta_column_conf.txt");
    config.getVarSelect().setForceRemoveColumnNameFile("./conf/remove_column_list.txt");
    List<ColumnConfig> list = new ArrayList<ColumnConfig>();
    ColumnConfig e = new ColumnConfig();
    e.setColumnName("a");
    list.add(e);
    e = new ColumnConfig();
    e.setColumnName("c");
    list.add(e);
    e = new ColumnConfig();
    e.setColumnName("d");
    list.add(e);
    ColumnConfigUpdater.updateColumnConfigFlags(config, list, ModelInspector.ModelStep.VARSELECT);
    Assert.assertTrue(list.get(0).isMeta());
}
Also used : ModelConfig(ml.shifu.shifu.container.obj.ModelConfig) ColumnConfig(ml.shifu.shifu.container.obj.ColumnConfig) ArrayList(java.util.ArrayList)

Aggregations

ModelConfig (ml.shifu.shifu.container.obj.ModelConfig)33 Test (org.testng.annotations.Test)18 ArrayList (java.util.ArrayList)9 File (java.io.File)8 ValidateResult (ml.shifu.shifu.container.meta.ValidateResult)8 ColumnConfig (ml.shifu.shifu.container.obj.ColumnConfig)8 TrainingDataSet (ml.shifu.shifu.core.dvarsel.dataset.TrainingDataSet)4 IOException (java.io.IOException)3 EvalConfig (ml.shifu.shifu.container.obj.EvalConfig)3 NNTrainer (ml.shifu.shifu.core.alg.NNTrainer)3 BeforeClass (org.testng.annotations.BeforeClass)3 FileInputStream (java.io.FileInputStream)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Properties (java.util.Properties)2 RawSourceData (ml.shifu.shifu.container.obj.RawSourceData)2 PathFinder (ml.shifu.shifu.fs.PathFinder)2 MLDataPair (org.encog.ml.data.MLDataPair)2 BasicMLDataPair (org.encog.ml.data.basic.BasicMLDataPair)2