SMap Regularization

SMap() solves a locally weighted linear model for every prediction point. The default solver is the LAPACK SVD solver dgelss. In pyEDM the solver can be replaced with a class object instantiated from the python sklearn.linear_model class.

Users can provide custom regularization parameters for constraining the linear fit. Supported solvers include LinearRegression, Ridge, Lasso, ElasticNet, RidgeCV, LassoCV, ElasticNetCV.

Examples below apply each of the solvers to a toy dataset of a 2-D representation of a circle (x = sin, y = cos). Since the data set consists of 200 points (199 intervals) from 0 to 4π, the analytical answer for SMap coefficients is C0 = 0; ∂x/∂x = 0.998; ∂y/∂x = 0.0632.

from sklearn.linear_model import Ridge, Lasso, ElasticNet
from sklearn.linear_model import RidgeCV, LassoCV, ElasticNetCV
import pyEDM
circle = pyEDM.sampleData['circle']

lmSolvers = {
    'SVD'          : None, 
    'Ridge'        : Ridge( alpha = 0.05 ),
    'Lasso'        : Lasso( alpha = 0.005 ),
    'ElasticNet'   : ElasticNet( alpha = 0.001, l1_ratio = 0.001 ),
    'RidgeCV'      : RidgeCV(),
    'LassoCV'      : LassoCV( cv = 5 ),
    'ElasticNetCV' : ElasticNetCV( l1_ratio = [.05,.1,.5,.7,.9,.95,1], cv = 5 )
}
for solverName in lmSolvers.keys() :
    print( solverName )
    result = pyEDM.SMap( dataFrame = circle,
                         lib = "1 100", pred = "101 198",
                         embedded = True, E = 2, theta = 3.14,
                         columns = "x y", target = "x", showPlot = True,
                         solver = lmSolvers[ solverName ] )
SVD

Ridge

Lasso

ElasticNet

RidgeCV

LassoCV

ElasticNetCV