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'])¶
InMemoryModelimplementation of theSVDAlgorithm.- Parameters:
vectors (ArrayLike) – Matrix of the right singular vectors.
values (ArrayLike) – List of the singular values for each input feature.
note:: (..) –
SVDare defined entirely by their attributes. For example,vectorsandvaluesdefine 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
SVDmodel 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
SVDmodel.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)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
SVDmodel to the input matrix.Transforms and returns the SQL needed to deploy the
SVDmodel.Attributes
Must be overridden in child class