pyEDM, rEDM
  • Home

Getting Started

  • EDM Framework
  • Installation

Documentation

  • API Reference
  • Parameters
  • Simplex
  • SMap
  • CCM
  • Multiview
  • EmbedDimension
  • PredictInterval
  • PredictNonlinear
  • Embed
  • MakeBlock
  • ComputeError

Embedding Parameters

  • Embedding

Examples

  • Basic EDM Examples

EDM Algorithms

  • EDM Algorithms in Depth
  • S-map First Principles
  • S-map Custom Solvers
  • Conditional Embedding
pyEDM, rEDM
  • EDM Algorithms
  • S-map Custom Solvers

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 consists of 200 points (199 intervals) from 0 to 4π the analytical answer for SMap coefficients is C0 = 0; ∂x/∂x = 0.998; ∂x/∂y = 0.0632.

In [1]:
Copied!
from sklearn.linear_model import Ridge, Lasso, ElasticNet
from sklearn.linear_model import RidgeCV, LassoCV, ElasticNetCV
import pyEDM

import matplotlib.pyplot as plt
plt.rcParams["figure.figsize"] = (7, 3.5)
from sklearn.linear_model import Ridge, Lasso, ElasticNet from sklearn.linear_model import RidgeCV, LassoCV, ElasticNetCV import pyEDM import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = (7, 3.5)
In [2]:
Copied!
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 )
}
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 ) }
In [3]:
Copied!
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 ] )
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
No description has been provided for this image
No description has been provided for this image
Ridge
No description has been provided for this image
No description has been provided for this image
Lasso
No description has been provided for this image
No description has been provided for this image
ElasticNet
No description has been provided for this image
No description has been provided for this image
RidgeCV
No description has been provided for this image
No description has been provided for this image
LassoCV
No description has been provided for this image
No description has been provided for this image
ElasticNetCV
No description has been provided for this image
No description has been provided for this image
In [ ]:
Copied!

Previous Next

Built with MkDocs using a theme provided by Read the Docs.
« Previous Next »