Loading...

vastorbit.machine_learning.memmodel.decomposition.SVD

class vastorbit.machine_learning.memmodel.decomposition.SVD(vectors: Annotated[list | ndarray, 'Array Like Structure'], values: Annotated[list | ndarray, 'Array Like Structure'])

InMemoryModel implementation of the SVD Algorithm.

Parameters:
  • vectors (ArrayLike) – Matrix of the right singular vectors.

  • values (ArrayLike) – List of the singular values for each input feature.

  • note:: (..) – SVD are defined entirely by their attributes. For example, vectors and values define a SVD model.

Variables:
  • input (Attributes are identical to the)

  • underscore (parameters, followed by an)

  • ('_').

Examples

Initalization

Import the required module.

from vastorbit.machine_learning.memmodel.decomposition import SVD

A SVD model is defined by its vectors and values. In this example, we will use the following:

vectors = [
    [0.4, 0.5],
    [0.3, 0.2],
]
values = [0.1, 0.3]

Let’s create a SVD model.

model_svd = SVD(vectors, values)

Create a dataset.

data = [[0.3, 0.5]]

Making In-Memory Transformation

Use transform() method to do transformation.

model_svd.transform(data)

Deploy SQL Code

Let’s use the following column names:

cnames = ['col1', 'col2']

Use transform_sql() method to get the SQL code needed to deploy the model using its attributes.

model_svd.transform_sql(cnames)

Use get_attributes() method to check the attributes of the rotated model.

model_svd.get_attributes()

Hint

This object can be pickled and used in any in-memory environment, just like scikit-learn models.

__init__(vectors: Annotated[list | ndarray, 'Array Like Structure'], values: Annotated[list | ndarray, 'Array Like Structure']) None

Methods

__init__(vectors, values)

get_attributes()

Returns the model attributes.

inverse_transform_sql(X)

Returns the SQL needed to reconstruct the original features from the SVD components (inverse transform).

set_attributes(**kwargs)

Sets the model attributes.

transform(X)

Transforms and applies the SVD model to the input matrix.

transform_sql(X)

Transforms and returns the SQL needed to deploy the SVD model.

Attributes

object_type

Must be overridden in child class