Search in sources :

Example 16 with AkkaActorInputMessage

use of ml.shifu.shifu.message.AkkaActorInputMessage in project shifu by ShifuML.

the class EvalModelActorTest method testActor.

// @Test
public void testActor() throws IOException, InterruptedException {
    Environment.setProperty(Environment.SHIFU_HOME, ".");
    File tmpModels = new File("models");
    File tmpCommon = new File("common");
    File models = new File("src/test/resources/example/cancer-judgement/ModelStore/ModelSet1/models");
    FileUtils.copyDirectory(models, tmpModels);
    File tmpEvalA = new File("evals");
    FileUtils.forceMkdir(tmpEvalA);
    ActorRef modelEvalRef = actorSystem.actorOf(new Props(new UntypedActorFactory() {

        private static final long serialVersionUID = -1437127862571741369L;

        public UntypedActor create() {
            return new EvalModelActor(modelConfig, columnConfigList, new AkkaExecStatus(true), evalConfig);
        }
    }), "model-evaluator");
    List<Scanner> scanners = ShifuFileUtils.getDataScanners("src/test/resources/example/cancer-judgement/DataStore/EvalSet1", SourceType.LOCAL);
    modelEvalRef.tell(new AkkaActorInputMessage(scanners), modelEvalRef);
    while (!modelEvalRef.isTerminated()) {
        Thread.sleep(5000);
    }
    File outputFile = new File("evals/EvalA/EvalScore");
    Assert.assertTrue(outputFile.exists());
    FileUtils.deleteDirectory(tmpModels);
    FileUtils.deleteDirectory(tmpCommon);
    FileUtils.deleteDirectory(tmpEvalA);
}
Also used : Scanner(java.util.Scanner) AkkaActorInputMessage(ml.shifu.shifu.message.AkkaActorInputMessage) UntypedActorFactory(akka.actor.UntypedActorFactory) ActorRef(akka.actor.ActorRef) Props(akka.actor.Props) File(java.io.File)

Example 17 with AkkaActorInputMessage

use of ml.shifu.shifu.message.AkkaActorInputMessage in project shifu by ShifuML.

the class PostTrainActorTest method testActor.

// @Test
public void testActor() throws IOException, InterruptedException {
    File tmpModels = new File("models");
    File tmpCommon = new File("common");
    File models = new File("src/test/resources/example/cancer-judgement/ModelStore/ModelSet1/models");
    FileUtils.copyDirectory(models, tmpModels);
    ActorRef postTrainRef = actorSystem.actorOf(new Props(new UntypedActorFactory() {

        private static final long serialVersionUID = 6777309320338075269L;

        public UntypedActor create() {
            return new PostTrainActor(modelConfig, columnConfigList, new AkkaExecStatus(true));
        }
    }), "post-trainer");
    List<Scanner> scanners = ShifuFileUtils.getDataScanners("src/test/resources/example/cancer-judgement/DataStore/DataSet1", SourceType.LOCAL);
    postTrainRef.tell(new AkkaActorInputMessage(scanners), postTrainRef);
    while (!postTrainRef.isTerminated()) {
        Thread.sleep(5000);
    }
    File file = new File("./ColumnConfig.json");
    Assert.assertTrue(file.exists());
    FileUtils.deleteQuietly(file);
    FileUtils.deleteDirectory(tmpModels);
    FileUtils.deleteDirectory(tmpCommon);
}
Also used : Scanner(java.util.Scanner) AkkaActorInputMessage(ml.shifu.shifu.message.AkkaActorInputMessage) UntypedActorFactory(akka.actor.UntypedActorFactory) ActorRef(akka.actor.ActorRef) Props(akka.actor.Props) File(java.io.File)

Aggregations

AkkaActorInputMessage (ml.shifu.shifu.message.AkkaActorInputMessage)17 Scanner (java.util.Scanner)11 File (java.io.File)7 ExceptionMessage (ml.shifu.shifu.message.ExceptionMessage)6 ActorRef (akka.actor.ActorRef)3 Props (akka.actor.Props)3 UntypedActorFactory (akka.actor.UntypedActorFactory)3 ColumnConfig (ml.shifu.shifu.container.obj.ColumnConfig)2 PathFinder (ml.shifu.shifu.fs.PathFinder)2 ScanEvalDataMessage (ml.shifu.shifu.message.ScanEvalDataMessage)2 ScanStatsRawDataMessage (ml.shifu.shifu.message.ScanStatsRawDataMessage)2 StatsResultMessage (ml.shifu.shifu.message.StatsResultMessage)2 TrainResultMessage (ml.shifu.shifu.message.TrainResultMessage)2 Test (org.testng.annotations.Test)2 ArrayList (java.util.ArrayList)1 AbstractTrainer (ml.shifu.shifu.core.AbstractTrainer)1 LogisticRegressionTrainer (ml.shifu.shifu.core.alg.LogisticRegressionTrainer)1 NNTrainer (ml.shifu.shifu.core.alg.NNTrainer)1 SVMTrainer (ml.shifu.shifu.core.alg.SVMTrainer)1 EvalResultMessage (ml.shifu.shifu.message.EvalResultMessage)1