All Products
Search
Document Center

Platform For AI:Lasso Regression Prediction

Last Updated:Aug 26, 2024

The Lasso Regression Prediction component supports sparse and dense data. You can use this component to estimate values of numeric variables, such as loan limits and temperatures. This topic describes how to configure the Lasso Regression Prediction component.

Limits

You can use the Ridge Regression Training component based only on one of the following computing resources: MaxCompute, Realtime Compute for Apache Flink, or Deep Learning Containers (DLC) of Platform for AI (PAI).

How LASSO works

LASSO creates a penalty function to obtain a more refined model. LASSO can shrink some regression coefficients and set specific regression coefficients to zero. If a coefficient is shrunk, the sum of the absolute values of the coefficient is less than a fixed value. This way, LASSO retains the beneficial features of subset shrinkage and implements biased estimation on multicollinearity data.

Configure the component in the PAI console

  • Input ports

    Input port (left-to-right)

    Type

    Recommended upstream component

    Required

    Input model of the prediction

    None

    Lasso Regression Training

    Yes

    Input data of the prediction

    None

    Yes

  • Parameter settings

    Tab

    Parameter

    Description

    Field Setting

    reservedCols

    The columns to be reserved by the algorithm.

    vectorCol

    The name of the vector column.

    Parameter Setting

    predictionCol

    The name of the prediction column.

    numThreads

    The number of threads of the component. Default value: 1.

    Execution Tuning

    Number of Workers

    The number of workers. This parameter must be used together with the Memory per worker, unit MB parameter. The value of this parameter must be a positive integer. Valid values: [1,9999].

    Memory per worker, unit MB

    The memory size of each worker. Valid values: 1024 to 64 × 1024. Unit: MB.

Configure the component by coding

You can copy the following code to the code editor of the PyAlink Script component. This way, the PyAlink Script component can work like the Lasso Regression Prediction component.

from pyalink.alink import *

def main(sources, sinks, parameter):
    model = sources[0]
    batchData = sources[1]

    predictor = LassoRegPredictBatchOp()\
        .setPredictionCol("pred")
    result = predictor.linkFrom(model, batchData)
    result.link(sinks[0])
    BatchOperator.execute()