Search in sources :

Example 1 with RunModelDataMessage

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

the class DataLoadWorker method splitDataIntoMultiMessages.

private long splitDataIntoMultiMessages(int streamId, int totalStreamCnt, Scanner scanner, int recordCntPerMsg) {
    long recordCnt = 0;
    int msgId = 0;
    List<String> rawDataList = new LinkedList<String>();
    while (scanner.hasNextLine()) {
        String raw = scanner.nextLine();
        recordCnt++;
        rawDataList.add(raw);
        if (recordCnt % recordCntPerMsg == 0) {
            log.info("Read " + recordCnt + " Records.");
            nextActorRef.tell(new RunModelDataMessage(streamId, totalStreamCnt, (++msgId), false, rawDataList), getSelf());
            rawDataList = new LinkedList<String>();
        }
    }
    log.info("Totally read " + recordCnt + " Records.");
    // anyhow, sent the last message to let next actor know - it's done
    nextActorRef.tell(new RunModelDataMessage(streamId, totalStreamCnt, (++msgId), true, rawDataList), getSelf());
    return recordCnt;
}
Also used : LinkedList(java.util.LinkedList) RunModelDataMessage(ml.shifu.shifu.message.RunModelDataMessage)

Example 2 with RunModelDataMessage

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

the class RunModelWorker method handleMsg.

/*
     * (non-Javadoc)
     * 
     * @see akka.actor.UntypedActor#onReceive(java.lang.Object)
     */
@Override
public void handleMsg(Object message) {
    if (message instanceof RunModelDataMessage) {
        RunModelDataMessage msg = (RunModelDataMessage) message;
        List<String> evalDataList = msg.getEvalDataList();
        List<CaseScoreResult> scoreDataList = new ArrayList<CaseScoreResult>(evalDataList.size());
        for (String evalData : evalDataList) {
            CaseScoreResult scoreData = calculateModelScore(evalData);
            if (scoreData != null) {
                scoreData.setInputData(evalData);
                scoreDataList.add(scoreData);
            }
        }
        nextActorRef.tell(new RunModelResultMessage(msg.getStreamId(), msg.getTotalStreamCnt(), msg.getMsgId(), msg.isLastMsg(), scoreDataList), getSelf());
    } else {
        unhandled(message);
    }
}
Also used : CaseScoreResult(ml.shifu.shifu.container.CaseScoreResult) ArrayList(java.util.ArrayList) RunModelResultMessage(ml.shifu.shifu.message.RunModelResultMessage) RunModelDataMessage(ml.shifu.shifu.message.RunModelDataMessage)

Example 3 with RunModelDataMessage

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

the class DataFilterWorker method handleMsg.

/* (non-Javadoc)
     * @see ml.shifu.shifu.actor.worker.AbstractWorkerActor#handleMsg(java.lang.Object)

     */
@Override
public void handleMsg(Object message) throws Exception {
    if (message instanceof StatsPartRawDataMessage) {
        StatsPartRawDataMessage msg = (StatsPartRawDataMessage) message;
        purifyData(msg.getRawDataList());
        nextActorRef.tell(msg, getSelf());
    } else if (message instanceof NormPartRawDataMessage) {
        NormPartRawDataMessage msg = (NormPartRawDataMessage) message;
        purifyData(msg.getRawDataList());
        nextActorRef.tell(msg, getSelf());
    } else if (message instanceof RunModelDataMessage) {
        RunModelDataMessage msg = (RunModelDataMessage) message;
        purifyData(msg.getEvalDataList());
        nextActorRef.tell(msg, getSelf());
    } else {
        unhandled(message);
    }
}
Also used : StatsPartRawDataMessage(ml.shifu.shifu.message.StatsPartRawDataMessage) NormPartRawDataMessage(ml.shifu.shifu.message.NormPartRawDataMessage) RunModelDataMessage(ml.shifu.shifu.message.RunModelDataMessage)

Aggregations

RunModelDataMessage (ml.shifu.shifu.message.RunModelDataMessage)3 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 CaseScoreResult (ml.shifu.shifu.container.CaseScoreResult)1 NormPartRawDataMessage (ml.shifu.shifu.message.NormPartRawDataMessage)1 RunModelResultMessage (ml.shifu.shifu.message.RunModelResultMessage)1 StatsPartRawDataMessage (ml.shifu.shifu.message.StatsPartRawDataMessage)1