Example #1
0
@dc.param(
    String(
        key="odType",
        default="IncToDec",
        help="The type of the overfitting detector to use.IncToDec,Iter",
    )
)
@dc.param(Int(key="randomSeed", default=0, help="The random seed used for training."))
@dc.param(
    Int(
        key="metricPeriod",
        default=1,
        help="The frequency of iterations to calculate the values of objectives and metrics. ",
    )
)
@dc.param(Bool(key="useBestModel", default=True, help="Use Best Model."))
@dc.param(
    Float(
        key="baggingTemperature",
        default=1,
        help="Defines the settings of the Bayesian bootstrap. ",
    )
)
@dc.param(
    String(
        key="evalMetric",
        default="MAE",
        help="""The metric used for overfitting detection and best model selection.
                MAE,MAPE,RMSE,Poisson,SMAPE,R2,MSLE,MedianAbsoluteError""",
    )
)
Example #2
0
# coding=utf-8
from __future__ import absolute_import, print_function

from suanpan.docker import DockerComponent as dc
from suanpan.docker.arguments import Int, Csv, String, Bool
import statsmodels.api as sm
import pandas as pd
from arguments import SklearnModel


@dc.input(Csv(key="inputData"))
@dc.column(Bool(key="timestampIndex", default=False))
@dc.column(String(key="timestampColumn", default="date"))
@dc.column(String(key="labelColumn", default="y"))
@dc.param(
    String(
        key="missing",
        default="none",
        help="Available options are ‘none’, ‘drop’, and ‘raise’.",
    ))
@dc.param(
    String(
        key="trend",
        default="c",
        help=
        "Whether to include a constant or not. ‘c’ includes constant, ‘nc’ no constant.",
    ))
@dc.param(String(key="method", default="cmle", help="‘cmle’, ‘mle’"))
@dc.param(
    Int(key="maxiter",
        default=35,
Example #3
0
        help="Subsample ratio of columns when constructing each tree.",
    ))
@dc.param(
    Float(key="regAlpha",
          default=0.0,
          help="L1 regularization term on weights."))
@dc.param(
    Float(key="regLambda",
          default=0.0,
          help="L2 regularization term on weights."))
@dc.param(Int(key="randomState", default=0, help="Random number seed."))
@dc.param(Int(key="nJobs", default=-1, help="Number of parallel threads."))
@dc.param(
    Bool(
        key="silent",
        default=True,
        help="Whether to print messages while running boosting.",
    ))
@dc.param(Bool(key="needTrain", default=True))
@dc.output(SklearnModel(key="outputModel"))
def SPLightGBMClassifier(context):
    # 从 Context 中获取相关数据
    args = context.args
    # 查看上一节点发送的 args.inputData 数据

    df = args.inputData

    featureColumns = args.featureColumns
    labelColumn = args.labelColumn

    features = df[featureColumns].values
Example #4
0
from statsmodels.tsa.arima_model import ARMAResultsWrapper, ARIMAResultsWrapper
from statsmodels.regression.linear_model import RegressionResultsWrapper
from statsmodels.discrete.discrete_model import (
    BinaryResultsWrapper,
    MultinomialResultsWrapper,
)
from arguments import SklearnModel


@dc.input(Csv(key="inputData"))
@dc.input(SklearnModel(key="inputModel"))
@dc.column(ListOfString(key="featureColumns", default=["a", "b", "c", "d"]))
@dc.column(String(key="predictColumn", default="prediction"))
@dc.param(String(key="start", default="2000-11-30"))
@dc.param(String(key="end", default="2001-05-31"))
@dc.param(Bool(key="dynamic", default=True))
@dc.output(Csv(key="outputData"))
def SPStatsPredict(context):
    args = context.args

    model = args.inputModel
    if isinstance(
            model,
        (
            ARResultsWrapper,
            ARMAResultsWrapper,
            ARIMAResultsWrapper,
            SARIMAXResultsWrapper,
        ),
    ):
        print("Time series model loaded")
Example #5
0
        default=[0.75, -0.25],
        help=
        "coefficient for autoregressive lag polynomial, including zero lag",
    ))
@dc.param(
    ListOfFloat(
        key="ma",
        default=[0.65, 0.35],
        help=
        "coefficient for moving-average lag polynomial, including zero lag",
    ))
@dc.param(
    Int(key="nsample", default=250, help="length of simulated time series"))
@dc.param(Float(key="sigma", default=1.0, help="standard deviation of noise"))
@dc.param(Int(key="randomSeed", default=12345, help="random seed"))
@dc.param(Bool(key="dateCol", default=True, help="date in dataset"))
@dc.param(
    String(
        key="startDate",
        default="19800131",
        help="The first abbreviated date, for instance, '1965q1' or '1965m1'",
    ))
@dc.param(String(key="freq", default="M", help="DateOffset"))
@dc.output(Csv(key="outputData"))
def SPARMASample(context):
    # 从 Context 中获取相关数据
    args = context.args
    # 查看上一节点发送的 args.inputData 数据
    np.random.seed(args.randomSeed)
    arparams = np.array(args.ar)
    maparams = np.array(args.ma)
Example #6
0
# coding=utf-8
from __future__ import absolute_import, print_function

from suanpan.docker import DockerComponent as dc
from suanpan.docker.arguments import Int, Csv, ListOfInt, String, Bool
import statsmodels.api as sm
import pandas as pd
from arguments import SklearnModel


@dc.input(Csv(key="inputData"))
@dc.column(Bool(key="timestampIndex", default=False))
@dc.column(String(key="timestampColumn", default="date"))
@dc.column(String(key="labelColumn", default="y"))
@dc.param(
    ListOfInt(
        key="order",
        default=[1, 0, 0],
        help="The (p,d,q) order of the model for the number of AR parameters, "
        "differences, and MA parameters.",
    )
)
@dc.param(
    ListOfInt(
        key="seasonalOrder",
        default=[0, 0, 0, 0],
        help="The (P,D,Q,s) order of the seasonal component of the model for the"
        " AR parameters, differences, MA parameters, and periodicity.",
    )
)
@dc.param(