Search in sources :

Example 1 with WindowType

use of edu.iu.dsc.tws.task.window.constant.WindowType in project twister2 by DSC-SPIDAL.

the class SvmSgdOnlineRunner method getWindowSinkInstance.

private BaseWindowedSink getWindowSinkInstance() {
    BaseWindowedSink baseWindowedSink = new IterativeStreamingWindowedCompute(new ProcessWindowFunctionImpl(), OperationMode.STREAMING, this.svmJobParameters, this.binaryBatchModel, "online-training-graph");
    WindowArguments windowArguments = this.svmJobParameters.getWindowArguments();
    TimeUnit timeUnit = TimeUnit.MICROSECONDS;
    if (windowArguments != null) {
        WindowType windowType = windowArguments.getWindowType();
        if (windowArguments.isDuration()) {
            if (windowType.equals(WindowType.TUMBLING)) {
                baseWindowedSink.withTumblingDurationWindow(windowArguments.getWindowLength(), timeUnit);
            }
            if (windowType.equals(WindowType.SLIDING)) {
                baseWindowedSink.withSlidingDurationWindow(windowArguments.getWindowLength(), timeUnit, windowArguments.getSlidingLength(), timeUnit);
            }
        } else {
            if (windowType.equals(WindowType.TUMBLING)) {
                baseWindowedSink.withTumblingCountWindow(windowArguments.getWindowLength());
            }
            if (windowType.equals(WindowType.SLIDING)) {
                baseWindowedSink.withSlidingCountWindow(windowArguments.getWindowLength(), windowArguments.getSlidingLength());
            }
        }
    }
    return baseWindowedSink;
}
Also used : IterativeStreamingWindowedCompute(edu.iu.dsc.tws.examples.ml.svm.compute.window.IterativeStreamingWindowedCompute) BaseWindowedSink(edu.iu.dsc.tws.task.window.core.BaseWindowedSink) WindowArguments(edu.iu.dsc.tws.examples.ml.svm.util.WindowArguments) TimeUnit(java.util.concurrent.TimeUnit) WindowType(edu.iu.dsc.tws.task.window.constant.WindowType)

Example 2 with WindowType

use of edu.iu.dsc.tws.task.window.constant.WindowType in project twister2 by DSC-SPIDAL.

the class SVMJobParameters method build.

/**
 * Builds the Job Parameters relevant SVM Algorithm
 *
 * @param cfg : this must be initialized where Job is initialized.
 */
public static SVMJobParameters build(Config cfg) {
    SVMJobParameters svmJobParameters = new SVMJobParameters();
    svmJobParameters.features = cfg.getIntegerValue(MLDataObjectConstants.SgdSvmDataObjectConstants.FEATURES, 10);
    svmJobParameters.samples = cfg.getIntegerValue(MLDataObjectConstants.SgdSvmDataObjectConstants.SAMPLES, 1000);
    svmJobParameters.testingSamples = cfg.getIntegerValue(MLDataObjectConstants.SgdSvmDataObjectConstants.TESTING_SAMPLES, 1000);
    svmJobParameters.isStreaming = cfg.getBooleanValue(MLDataObjectConstants.STREAMING, false);
    svmJobParameters.isSplit = cfg.getBooleanValue(MLDataObjectConstants.SPLIT, false);
    svmJobParameters.trainingDataDir = cfg.getStringValue(MLDataObjectConstants.TRAINING_DATA_DIR);
    svmJobParameters.testingDataDir = cfg.getStringValue(MLDataObjectConstants.TESTING_DATA_DIR);
    svmJobParameters.weightVectorDataDir = cfg.getStringValue(MLDataObjectConstants.WEIGHT_VECTOR_DATA_DIR);
    svmJobParameters.crossValidationDataDir = cfg.getStringValue(MLDataObjectConstants.CROSS_VALIDATION_DATA_DIR);
    svmJobParameters.modelSaveDir = cfg.getStringValue(MLDataObjectConstants.MODEL_SAVE_PATH);
    svmJobParameters.iterations = cfg.getIntegerValue(MLDataObjectConstants.SgdSvmDataObjectConstants.ITERATIONS, 100);
    svmJobParameters.c = cfg.getDoubleValue(MLDataObjectConstants.SgdSvmDataObjectConstants.C, 1.0);
    svmJobParameters.alpha = cfg.getDoubleValue(MLDataObjectConstants.SgdSvmDataObjectConstants.ALPHA, 0.001);
    svmJobParameters.isDummy = cfg.getBooleanValue(MLDataObjectConstants.DUMMY, true);
    svmJobParameters.parallelism = cfg.getIntegerValue(WorkerConstants.PARALLELISM, 4);
    svmJobParameters.experimentName = cfg.getStringValue(MLDataObjectConstants.SgdSvmDataObjectConstants.EXP_NAME);
    // set up window params
    WindowType windowType = cfg.getStringValue(WindowingConstants.WINDOW_TYPE).equalsIgnoreCase("tumbling") ? WindowType.TUMBLING : WindowType.SLIDING;
    long windowLength = Long.parseLong(cfg.getStringValue(WindowingConstants.WINDOW_LENGTH));
    long slidingLength = 0;
    if (cfg.getStringValue(WindowingConstants.SLIDING_WINDOW_LENGTH) != null) {
        slidingLength = Long.parseLong(cfg.getStringValue(WindowingConstants.SLIDING_WINDOW_LENGTH));
    }
    WindowArguments windowArguments = new WindowArguments(windowType, windowLength, slidingLength, cfg.getBooleanValue(WindowingConstants.WINDOW_CAPACITY_TYPE));
    svmJobParameters.windowArguments = windowArguments;
    return svmJobParameters;
}
Also used : WindowType(edu.iu.dsc.tws.task.window.constant.WindowType)

Aggregations

WindowType (edu.iu.dsc.tws.task.window.constant.WindowType)2 IterativeStreamingWindowedCompute (edu.iu.dsc.tws.examples.ml.svm.compute.window.IterativeStreamingWindowedCompute)1 WindowArguments (edu.iu.dsc.tws.examples.ml.svm.util.WindowArguments)1 BaseWindowedSink (edu.iu.dsc.tws.task.window.core.BaseWindowedSink)1 TimeUnit (java.util.concurrent.TimeUnit)1