Loading...

verticapy.machine_learning.vertica.decomposition.SVD

class verticapy.machine_learning.vertica.decomposition.SVD(name: str = None, overwrite_model: bool = False, n_components: int = 0, method: Literal['lapack'] = 'lapack')

Creates an SVD (Singular Value Decomposition) object using the Vertica SVD algorithm.

Parameters

name: str, optional

Name of the model. The model is stored in the database.

overwrite_model: bool, optional

If set to True, training a model with the same name as an existing model overwrites the existing model.

n_components: int, optional

The number of components to keep in the model. If this value is not provided, all components are kept. The maximum number of components is the number of non-zero singular values returned by the internal call to SVD. This number is less than or equal to SVD (number of columns, number of rows).

method: str, optional

The method used to calculate SVD.

  • lapack:

    Lapack definition.

Attributes

Many attributes are created during the fitting phase.

values_: numpy.array

Matrix of the right singular vectors.

values_: numpy.array

Array of the singular values for each input feature.

Note

All attributes can be accessed using the get_attributes() method.

Note

Several other attributes can be accessed by using the get_vertica_attributes() method.

Examples

The following examples provide a basic understanding of usage. For more detailed examples, please refer to the Machine Learning or the Examples section on the website.

Load data for machine learning

We import verticapy:

import verticapy as vp

Hint

By assigning an alias to verticapy, we mitigate the risk of code collisions with other libraries. This precaution is necessary because verticapy uses commonly known function names like “average” and “median”, which can potentially lead to naming conflicts. The use of an alias ensures that the functions from verticapy are used as intended without interfering with functions from other libraries.

For this example, we will use the winequality dataset.

import verticapy.datasets as vpd

data = vpd.load_winequality()
123
fixed_acidity
Numeric(8)
123
volatile_acidity
Numeric(9)
123
citric_acid
Numeric(8)
123
residual_sugar
Numeric(9)
123
chlorides
Float(22)
123
free_sulfur_dioxide
Numeric(9)
123
total_sulfur_dioxide
Numeric(9)
123
density
Float(22)
123
pH
Numeric(8)
123
sulphates
Numeric(8)
123
alcohol
Float(22)
123
quality
Integer
123
good
Integer
Abc
color
Varchar(20)
13.90.2250.44.20.0329.0118.00.9893.570.3612.881white
24.70.3350.141.30.03669.0168.00.992123.470.4610.550white
34.70.4550.181.90.03633.0106.00.987463.210.8314.071white
44.70.7850.03.40.03623.0134.00.989813.530.9213.860white
54.90.3450.341.00.06832.0143.00.991383.240.410.150white
64.90.3450.341.00.06832.0143.00.991383.240.410.150white
74.90.420.02.10.04816.042.00.991543.710.7414.071red
85.00.270.41.20.07642.0124.00.992043.320.4710.160white
95.00.310.06.40.04643.0166.00.9943.30.639.960white
105.00.40.54.30.04629.080.00.99023.490.6613.660red
115.00.440.0418.60.03938.0128.00.99853.370.5710.260white
125.10.110.321.60.02812.090.00.990083.570.5212.260white
135.10.140.250.70.03915.089.00.99193.220.439.260white
145.10.1650.225.70.04742.0146.00.99343.180.559.960white
155.10.330.221.60.02718.089.00.98933.510.3812.571white
165.10.330.221.60.02718.089.00.98933.510.3812.571white
175.10.330.221.60.02718.089.00.98933.510.3812.571white
185.10.390.211.70.02715.072.00.98943.50.4512.560white
195.20.20.273.20.04716.093.00.992353.440.5310.171white
205.20.210.311.70.04817.061.00.989533.240.3712.071white
215.20.220.466.20.06641.0187.00.993623.190.429.7333333333333350white
225.20.310.22.40.02727.0117.00.988863.560.4513.071white
235.20.320.251.80.10313.050.00.99573.380.559.250red
245.20.340.376.20.03142.0133.00.990763.250.4112.560white
255.20.360.021.60.03124.0104.00.98963.440.3512.260white
265.20.3650.0813.50.04137.0142.00.9973.460.399.960white
275.20.480.041.60.05419.0106.00.99273.540.6212.271red
285.20.50.182.00.03623.0129.00.989493.360.7713.471white
295.30.160.391.00.02840.0101.00.991563.570.5910.660white
305.30.160.391.00.02840.0101.00.991563.570.5910.660white
315.30.1650.241.10.05125.0105.00.99253.320.479.150white
325.30.230.560.90.04146.0141.00.991193.160.629.750white
335.30.30.31.20.02925.093.00.987423.310.413.671white
345.30.330.31.20.04825.0119.00.990453.320.6211.360white
355.30.360.276.30.02840.0132.00.991863.370.411.660white
365.30.360.276.30.02840.0132.00.991863.370.411.660white
375.30.40.253.90.03145.0130.00.990723.310.5811.7571white
385.30.470.112.20.04816.089.00.991823.540.8813.671red
395.30.470.112.20.04816.089.00.991823.540.8813.566666666666771red
405.30.7150.191.50.1617.062.00.993953.620.6111.050red
415.40.220.291.20.04569.0152.00.991783.760.6311.071white
425.40.5950.12.80.04226.080.00.99323.360.389.350white
435.40.740.091.70.08916.026.00.994023.670.5611.660red
445.50.120.331.00.03823.0131.00.991643.250.459.850white
455.50.120.331.00.03823.0131.00.991643.250.459.850white
465.50.140.274.60.02922.0104.00.99493.340.449.050white
475.50.140.274.60.02922.0104.00.99493.340.449.050white
485.50.160.311.20.02631.068.00.98983.330.4411.6560white
495.50.160.311.20.02631.068.00.98983.330.4411.633333333333360white
505.50.180.225.50.03710.086.00.991563.460.4412.250white
515.50.240.451.70.04622.0113.00.992243.220.4810.050white
525.50.290.31.10.02220.0110.00.988693.340.3812.871white
535.50.310.293.00.02716.0102.00.990673.230.5611.260white
545.50.320.454.90.02825.0191.00.99223.510.4911.571white
555.50.350.351.10.04514.0167.00.9923.340.689.960white
565.50.3750.381.70.03617.098.00.991423.290.3910.560white
575.60.150.265.550.05151.0139.00.993363.470.511.060white
585.60.150.315.30.0388.079.00.99233.30.3910.560white
595.60.160.271.40.04453.0168.00.99183.280.3710.160white
605.60.1750.290.80.04320.067.00.991123.280.489.960white
615.60.1850.197.10.04836.0110.00.994383.260.419.560white
625.60.1850.197.10.04836.0110.00.994383.260.419.560white
635.60.220.321.20.02429.097.00.988233.20.4613.0571white
645.60.260.181.40.03418.0135.00.991743.320.3510.260white
655.60.260.265.70.03112.080.00.99233.250.3810.850white
665.60.260.511.40.02925.093.00.994283.230.4910.560white
675.60.280.284.20.04452.0158.00.9923.350.4410.771white
685.60.30.16.40.04334.0142.00.993823.140.489.850white
695.60.350.145.00.04648.0198.00.99373.30.7110.350white
705.60.490.134.50.03917.0116.00.99073.420.913.771white
715.60.490.134.50.03917.0116.00.99073.420.913.771white
725.60.660.02.20.0873.011.00.993783.710.6312.871red
735.60.660.02.20.0873.011.00.993783.710.6312.871red
745.70.150.4711.40.03549.0128.00.994563.030.3410.581white
755.70.180.262.20.02321.095.00.98933.070.5412.360white
765.70.180.361.20.0469.071.00.991993.70.6810.971white
775.70.20.32.50.04638.0125.00.992763.340.59.960white
785.70.210.320.90.03838.0121.00.990743.240.4610.660white
795.70.210.374.50.0458.0140.00.993323.290.6210.660white
805.70.220.216.00.04441.0113.00.998623.220.468.960white
815.70.220.216.00.04441.0113.00.998623.220.468.960white
825.70.220.216.00.04441.0113.00.998623.220.468.960white
835.70.220.216.00.04441.0113.00.998623.220.468.960white
845.70.220.216.00.04441.0113.00.998623.220.468.960white
855.70.220.293.50.0427.0146.00.989993.170.3612.160white
865.70.230.289.650.02526.0121.00.99253.280.3811.360white
875.70.250.2612.50.04952.5106.00.996913.080.459.460white
885.70.250.2612.50.04952.5120.00.996913.080.459.460white
895.70.250.2711.50.0424.0120.00.994113.330.3110.860white
905.70.260.2417.80.05923.0124.00.997733.30.510.150white
915.70.260.2417.80.05923.0124.00.997733.30.510.150white
925.70.260.2417.80.05923.0124.00.997733.30.510.150white
935.70.270.321.20.04620.0155.00.99343.80.4110.260white
945.70.280.2417.50.04460.0167.00.99893.310.449.450white
955.70.320.181.40.02926.0104.00.99063.440.3711.060white
965.70.320.384.750.03323.094.00.9913.420.4211.871white
975.70.360.344.20.02621.077.00.99073.410.4511.960white
985.80.140.156.10.04227.0123.00.993623.060.69.960white
995.80.150.321.20.03714.0119.00.991373.190.510.260white
1005.80.170.341.80.04596.0170.00.990353.380.911.881white
Rows: 1-100 | Columns: 14

We can drop the “color” column as it is varchar type.

data.drop("color")

Note

VerticaPy offers a wide range of sample datasets that are ideal for training and testing purposes. You can explore the full list of available datasets in the Datasets, which provides detailed information on each dataset and how to use them effectively. These datasets are invaluable resources for honing your data analysis and machine learning skills within the VerticaPy environment.

Model Initialization

First we import the SVD model:

from verticapy.machine_learning.vertica import SVD

Then we can create the model:

model = SVD(
    n_components = 3,
)

You can select the number of components by the n_component parameter. If it is not provided, then all are considered.

Hint

In verticapy 1.0.x and higher, you do not need to specify the model name, as the name is automatically assigned. If you need to re-use the model, you can fetch the model name from the model’s attributes.

Important

The model name is crucial for the model management system and versioning. It’s highly recommended to provide a name if you plan to reuse the model later.

Model Training

We can now fit the model:

model.fit(data)


=======
columns
=======
index|        name        
-----+--------------------
  1  |   fixed_acidity    
  2  |  volatile_acidity  
  3  |    citric_acid     
  4  |   residual_sugar   
  5  |     chlorides      
  6  |free_sulfur_dioxide 
  7  |total_sulfur_dioxide
  8  |      density       
  9  |         ph         
 10  |     sulphates      
 11  |      alcohol       
 12  |      quality       
 13  |        good        


===============
singular_values
===============
index|   value   |explained_variance|accumulated_explained_variance
-----+-----------+------------------+------------------------------
  1  |10781.47113|      0.98836     |            0.98836           
  2  | 974.23648 |      0.00807     |            0.99643           
  3  | 541.13928 |      0.00249     |            0.99892           


======================
right_singular_vectors
======================
index|vector1 |vector2 |vector3 
-----+--------+--------+--------
  1  | 0.04727| 0.03964| 0.52192
  2  | 0.00207| 0.00189| 0.02995
  3  | 0.00224| 0.00120| 0.01739
  4  | 0.04440| 0.01975| 0.01309
  5  | 0.00035| 0.00048| 0.00461
  6  | 0.24921| 0.96168|-0.11007
  7  | 0.96268|-0.25865|-0.07057
  8  | 0.00671| 0.00545| 0.06231
  9  | 0.02158| 0.01869| 0.20599
 10  | 0.00345| 0.00374| 0.03886
 11  | 0.06974| 0.06456| 0.71942
 12  | 0.03914| 0.04152| 0.37864
 13  | 0.00127| 0.00394| 0.01877


========
counters
========
   counter_name   |counter_value
------------------+-------------
accepted_row_count|    6497     
rejected_row_count|      0      
 iteration_count  |      1      


===========
call_string
===========
SELECT SVD('"public"."_verticapy_tmp_svd_v_mldb_9649885e979711efa8720242ac120002_"', '"public"."_verticapy_tmp_view_v_mldb_967a90e8979711efa8720242ac120002_"', '"fixed_acidity", "volatile_acidity", "citric_acid", "residual_sugar", "chlorides", "free_sulfur_dioxide", "total_sulfur_dioxide", "density", "pH", "sulphates", "alcohol", "quality", "good"'
USING PARAMETERS num_components=3);

Important

To train a model, you can directly use the vDataFrame or the name of the relation stored in the database.

Scores

The decomposition score on the dataset for each transformed column can be calculated by:

model.score()
Out[4]: 
None                                   Score  
fixed_acidity               3.19669356683238  
volatile_acidity           0.264348755504044  
citric_acid                0.228932614877664  
residual_sugar              5.38039944191312  
chlorides                 0.0427139489873566  
free_sulfur_dioxide         2.10040482930185  
total_sulfur_dioxide        4.73074234245674  
density                    0.309070644222815  
pH                          1.14052266015885  
sulphates                  0.304887828479003  
alcohol                     3.19983025734727  
quality                     2.33115583120493  
good                       0.352765059376178  
Rows: 1-13 | Columns: 2

For more details on the function, check out score()

You can also fetch the explained variance by:

model.explained_variance_
Out[5]: array([0.9883586 , 0.00807026, 0.00248987])

Principal Components

To get the transformed dataset in the form of principal components:

model.transform(data)
Out[6]: 
None                  col1                     col2                    col3  
1       0.0166627178211831       0.0504421228529202      -0.013344560552529  
2       0.0156076978382921       0.0224989559819784     -0.0151162620266151  
3       0.0163554466085546       0.0466574148608037     -0.0189083140020647  
4       0.0162665231231895      -0.0352134384874341    -0.00229993058464557  
5      0.00981065936878354       0.0148445654146031     0.00584151877390349  
6       0.0105589692445995     -0.00637543518725687     0.00714797062666492  
7       0.0105691701583817      -0.0113629436261072     0.00952468977202701  
8       0.0128160451773933        0.013109827216752     -0.0025356496114282  
9       0.0170823856441917     -0.00894566848931371    -0.00511840498754079  
10        0.01148166275695      0.00361722019279731    0.000741660518064574  
11      0.0144487952276349      0.00024278733309064     0.00295673168007066  
12      0.0167162120544499       0.0247153778951737     -0.0122822601942572  
13      0.0167162120544499       0.0247153778951737     -0.0122822601942572  
14      0.0148611056419884       0.0061308952609764    -0.00358340879790028  
15      0.0168497956817113      0.00888850199443394    -0.00497628224283744  
16      0.0148159331848086      -0.0176893913881306     0.00119415364309952  
17      0.0103808460535981      0.00597608952054056     0.00930357835576713  
18     0.00461567673665519       0.0049791934244293       0.018138757313459  
19     0.00704632805117089     -0.00125311656786212      0.0133444561329969  
20      0.0143405642039511      -0.0114881981132763    -0.00142287511458726  
21       0.012689743611027       0.0106316956818193    0.000312629430421607  
22     0.00982671259866448    -0.000974362410638911     0.00930281068428659  
23     0.00786669266643752      0.00980318166512077     0.00588189636259572  
24     0.00759694685748644      0.00644547936960487     0.00873790743769186  
25     0.00746567931633152     0.000580293432369368      0.0110374354934679  
26     0.00913821037224146     -0.00619404051276112      0.0133172050281699  
27     0.00713915669203781     -0.00147626901033191      0.0139435588532038  
28     0.00766585574596053     -0.00733264255115155       0.013044853454326  
29     0.00982186154519613     -0.00610044600219932     0.00953957549822287  
30      0.0117630356588413       0.0123113194977316     0.00394473005468317  
31      0.0117630356588413       0.0123113194977316     0.00394473005468317  
32      0.0062625552222831      -0.0055006986357797      0.0122314271845807  
33      0.0109806291910484     -0.00120336535627242     0.00501126433948926  
34      0.0069851910897219     -0.00755805549704856      0.0124509445455597  
35     0.00556912516109348      -0.0115356581477962      0.0196220352844239  
36      0.0100644386992172      0.00131547361500665     0.00539601949020896  
37      0.0107975829765916      0.00765119025354379     0.00194143463687917  
38     0.00853354432493088      0.00412057394934463      0.0117034037043015  
39      0.0126558160360363       0.0423486272590535    -0.00312577080242463  
40      0.0103856303007436      0.00177412645780564     0.00945355385725723  
41     0.00903149479937041      0.00150626041835165      0.0124657052635593  
42      0.0140475821485117      0.00840551221277986      -0.004608497262778  
43      0.0104195563585142    -0.000537882454022647     0.00830982305095836  
44     0.00558814828594127      0.00956099194815167       0.016322500746599  
45     0.00461743056708228      0.00499546872504762      0.0185245483547168  
46     0.00875096711402058      -0.0103713468437911      0.0142634641711807  
47     0.00724430200053943    -0.000819287310697858      0.0125466006016753  
48      0.0114965524755585     0.000558345635808813      0.0079760342384512  
49     0.00949751509796975      -0.0183035784661458     0.00752797466264932  
50     0.00857471859687872      0.00615122546302568      0.0140852505457725  
51     0.00920474133494145      -0.0067745211493323     0.00636506242060123  
52     0.00715987191061613      0.00290318034738615      0.0158229788910861  
53     0.00715987191061613      0.00290318034738615      0.0158229788910861  
54     0.00992788293510493      -0.0046321495407913     0.00534278816556469  
55     0.00650027761342404       0.0002518023306758      0.0125288979875086  
56      0.0145389772109947      -0.0152637651083441    -0.00148627501289218  
57      0.0116603488567791      -0.0161204938061663     0.00489916163863051  
58     0.00698213326744077     -0.00415537009300246      0.0147639464775544  
59      0.0159238868675167     -0.00132116295361841    -0.00530550641046172  
60      0.0103879947895724      -0.0150512197248635      0.0106826508532783  
61      0.0101595023710441        0.013687851330626     0.00377990863531279  
62     0.00892564310757659    -0.000186425942651864     0.00870090957104276  
63     0.00921648672303232     0.000896089735417004     0.00847604569533058  
64     0.00921648672303232     0.000896089735417004     0.00847604569533058  
65     0.00863245300180869     0.000504677407110386     0.00965340172716782  
66      0.0162272743393317      -0.0219887449948917    6.75072234815565e-05  
67      0.0095971753666285      0.00930625490267071     0.00924409662983734  
68     0.00140815966249489      0.00279527766643168      0.0229879402130233  
69     0.00140815966249489      0.00279527766643168      0.0229879402130233  
70     0.00575938015638363      0.00133669205867381       0.012700407074592  
71     0.00141831849431529      0.00364874034592818      0.0203361836071961  
72     0.00164558017749426      0.00435048306567297      0.0242630196619369  
73     0.00946569736637315     -0.00423153360402477     0.00715471670080586  
74      0.0149420958951146       0.0175500738589989    -0.00523461898273193  
75      0.0149420958951146       0.0175500738589989    -0.00523461898273193  
76      0.0108808120470814     -0.00102285428969076     0.00391604302246656  
77     0.00823529917153261      -0.0154500518288816       0.012027438850318  
78      0.0183926133854933       0.0103315279006879      -0.012098374653085  
79      0.0183926133854933       0.0103315279006879      -0.012098374653085  
80      0.0117941234099257       0.0015656348045772     0.00437321643388602  
81      0.0179988502107907       0.0506091538108886     -0.0165849155545074  
82      0.0108194451524607      0.00873811921846562     0.00577501476653969  
83     0.00947203277315955     0.000114681525119134       0.010531982769587  
84     0.00541352591341548     -0.00679212978833105      0.0159364926788033  
85      0.0102155978186162      0.00321107285522031     0.00879663376326423  
86      0.0146132428240696      0.00704590454733349    -0.00251472784943461  
87      0.0146132428240696      0.00704590454733349    -0.00251472784943461  
88      0.0108095748535132       0.0035495045454257      0.0041954863279059  
89      0.0108095748535132       0.0035495045454257      0.0041954863279059  
90     0.00905701501282419       0.0150484470352413     0.00828405316257603  
91     0.00833807787024743     0.000348390495919757      0.0118211843078814  
92     0.00909086365511396      0.00435154691663435     0.00969683017045655  
93      0.0106381154224292      -0.0117365728020144     0.00951598261532732  
94      0.0106381154224292      -0.0117365728020144     0.00951598261532732  
95      0.0162584836396806      -0.0167607105529164    -0.00032876694519059  
96      0.0159197115977615      -0.0131421418650892    -0.00623628882664583  
97      0.0117469104552609      0.00376899278297677     0.00349557208238807  
98      0.0170775916463106      -0.0232983402539546    -0.00167013652288743  
99      0.0170775916463106      -0.0232983402539546    -0.00167013652288743  
100    0.00935079373998315     -0.00413825670835599      0.0056855667486921  
Rows: 1-100 | Columns: 3

Please refer to transform() for more details on transforming a vDataFrame.

Similarly, you can perform the inverse tranform to get the original features using:

model.inverse_transform(data_transformed)

The variable data_transformed includes the PCA components.

Plots - SVD

You can plot the first two dimensions conveniently using:

model.plot()

Plots - Scree

You can also plot the Scree plot:

model.plot_scree()
Loading....

Parameter Modification

In order to see the parameters:

model.get_params()
Out[7]: {'n_components': 3, 'method': 'lapack'}

And to manually change some of the parameters:

model.set_params({'n_components': 3})

Model Register

In order to register the model for tracking and versioning:

model.register("model_v1")

Please refer to /notebooks/ml/model_tracking_versioning/index.ipynb for more details on model tracking and versioning.

Model Exporting

To Memmodel

model.to_memmodel()

Note

MemModel objects serve as in-memory representations of machine learning models. They can be used for both in-database and in-memory prediction tasks. These objects can be pickled in the same way that you would pickle a scikit-learn model.

The preceding methods for exporting the model use MemModel, and it is recommended to use MemModel directly.

SQL

To get the SQL query use below:

model.to_sql()
Out[9]: 
['"fixed_acidity" * 0.0472721802865271 / 10781.471128853 + "volatile_acidity" * 0.00206840925765328 / 10781.471128853 + "citric_acid" * 0.00224024758641517 / 10781.471128853 + "residual_sugar" * 0.044395714039541 / 10781.471128853 + "chlorides" * 0.000346326837712132 / 10781.471128853 + "free_sulfur_dioxide" * 0.249206286239206 / 10781.471128853 + "total_sulfur_dioxide" * 0.962684441178257 / 10781.471128853 + "density" * 0.00670829104944216 / 10781.471128853 + "pH" * 0.0215818136774093 / 10781.471128853 + "sulphates" * 0.00345087841775058 / 10781.471128853 + "alcohol" * 0.0697381862438041 / 10781.471128853 + "quality" * 0.0391425145196623 / 10781.471128853 + "good" * 0.00126598337328779 / 10781.471128853',
 '"fixed_acidity" * 0.0396399788533407 / 974.23647729684 + "volatile_acidity" * 0.00188557954207477 / 974.23647729684 + "citric_acid" * 0.00119732121820963 / 974.23647729684 + "residual_sugar" * 0.0197505553836925 / 974.23647729684 + "chlorides" * 0.000483104744026939 / 974.23647729684 + "free_sulfur_dioxide" * 0.961682217712392 / 974.23647729684 + "total_sulfur_dioxide" * -0.258651563180512 / 974.23647729684 + "density" * 0.00544627404807704 / 974.23647729684 + "pH" * 0.018692335692342 / 974.23647729684 + "sulphates" * 0.003738649322261 / 974.23647729684 + "alcohol" * 0.0645579238733929 / 974.23647729684 + "quality" * 0.0415184345466082 / 974.23647729684 + "good" * 0.00393668701479983 / 974.23647729684',
 '"fixed_acidity" * 0.521916714261153 / 541.139278464763 + "volatile_acidity" * 0.0299488656760591 / 541.139278464763 + "citric_acid" * 0.0173905391926743 / 541.139278464763 + "residual_sugar" * 0.0130884723973556 / 541.139278464763 + "chlorides" * 0.00460654396890657 / 541.139278464763 + "free_sulfur_dioxide" * -0.110072060878328 / 541.139278464763 + "total_sulfur_dioxide" * -0.0705721810950697 / 541.139278464763 + "density" * 0.0623122781813199 / 541.139278464763 + "pH" * 0.205991789180222 / 541.139278464763 + "sulphates" * 0.0388553814537632 / 541.139278464763 + "alcohol" * 0.719424850273745 / 541.139278464763 + "quality" * 0.378635713837341 / 541.139278464763 + "good" * 0.0187739554796354 / 541.139278464763']

To Python

To obtain the prediction function in Python syntax, use the following code:

X = [[3.8, 0.3, 0.02, 11, 0.03, 20, 113, 0.99, 3, 0.4, 12, 6, 0]]

model.to_python()(X)
Out[11]: array([[ 0.0107203 , -0.00876453,  0.0065801 ]])

Hint

The to_python() method is used to retrieve the Principal Component values. For specific details on how to use this method for different model types, refer to the relevant documentation for each model.

__init__(name: str = None, overwrite_model: bool = False, n_components: int = 0, method: Literal['lapack'] = 'lapack') None

Must be overridden in the child class

Methods

__init__([name, overwrite_model, ...])

Must be overridden in the child class

contour([nbins, chart])

Draws the model's contour plot.

deployInverseSQL([key_columns, ...])

Returns the SQL code needed to deploy the inverse model.

deploySQL([X, n_components, cutoff, ...])

Returns the SQL code needed to deploy the model.

does_model_exists(name[, raise_error, ...])

Checks whether the model is stored in the Vertica database.

drop()

Drops the model from the Vertica database.

export_models(name, path[, kind])

Exports machine learning models.

fit(input_relation[, X, return_report])

Trains the model.

get_attributes([attr_name])

Returns the model attributes.

get_match_index(x, col_list[, str_check])

Returns the matching index.

get_params()

Returns the parameters of the model.

get_plotting_lib([class_name, chart, ...])

Returns the first available library (Plotly, Matplotlib, or Highcharts) to draw a specific graphic.

get_vertica_attributes([attr_name])

Returns the model Vertica attributes.

import_models(path[, schema, kind])

Imports machine learning models.

inverse_transform(vdf[, X])

Applies the Inverse Model on a vDataFrame.

plot([dimensions, chart])

Draws a decomposition scatter plot.

plot_circle([dimensions, chart])

Draws a decomposition circle.

plot_scree([chart])

Draws a decomposition scree plot.

register(registered_name[, raise_error])

Registers the model and adds it to in-DB Model versioning environment with a status of 'under_review'.

score([X, input_relation, metric, p])

Returns the decomposition score on a dataset for each transformed column.

set_params([parameters])

Sets the parameters of the model.

summarize()

Summarizes the model.

to_binary(path)

Exports the model to the Vertica Binary format.

to_memmodel()

Converts the model to an InMemory object that can be used for different types of predictions.

to_pmml(path)

Exports the model to PMML.

to_python([return_proba, ...])

Returns the Python function needed for in-memory scoring without using built-in Vertica functions.

to_sql([X, return_proba, ...])

Returns the SQL code needed to deploy the model without using built-in Vertica functions.

to_tf(path)

Exports the model to the Frozen Graph format (TensorFlow).

transform([vdf, X, n_components, cutoff])

Applies the model on a vDataFrame.

Attributes