⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 timeseries.java

📁 MacroWeka扩展了著名数据挖掘工具weka
💻 JAVA
字号:
package chen.macroweka.timeseries;

import weka.core.Instances;
import weka.core.SerializedObject;
import weka.core.Utils;

import java.io.Serializable;

/**
 * Implementation of class TimeSeries
 * 
 */
public abstract class TimeSeries implements Cloneable, Serializable
{
    /**
     * Analyzes time series data. Must initialize all fields of the timeseries
     * that are not being set via options (ie. multiple calls of analyze
     * must always lead to the same result). Must not change the dataset
     * in any way.
     *
     * @param data set of instances serving as training data
     * @throws Exception if the analysis has not been
     *                   done successfully
     */
    public abstract void analyze(Instances data) throws Exception;

    /**
     * Creates a new instance of a timeseries analyzer given it's class name and
     * (optional) arguments to pass to it's setOptions method. If the
     * associator implements OptionHandler and the options parameter is
     * non-null, the associator will have it's options set.
     *
     * @param analyzerName the fully qualified class name of the timeseries analyzer
     * @param options        an array of options suitable for passing to setOptions. May
     *                       be null.
     * @return the newly created associator, ready for use.
     * @throws Exception if the associator name is invalid, or the options
     *                   supplied are not acceptable to the associator
     */
    public static TimeSeries forName(String analyzerName,
                                     String[] options) throws Exception
    {
        return (TimeSeries) Utils.forName( TimeSeries.class,
                                           analyzerName,
                                           options );
    }

    /**
     * Creates copies of the current timeseries. Note that this method
     * now uses Serialization to perform a deep copy, so the TimeSeries
     * object must be fully Serializable. Any currently built model will
     * now be copied as well.
     *
     * @param model an example associator to copy
     * @param num   the number of associators copies to create.
     * @return an array of associators.
     * @throws Exception if an error occurs
     */
    public static TimeSeries[] makeCopies(TimeSeries model,
                                          int num) throws Exception
    {
        if ( model == null ) {
            throw new Exception( "No model time series analysis set" );
        }
        TimeSeries[] analyzers = new TimeSeries[num];
        SerializedObject so = new SerializedObject( model );
        for ( int i = 0; i < analyzers.length; i++ ) {
            analyzers[i] = (TimeSeries) so.getObject();
        }
        return analyzers;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -