Loading...

verticapy.machine_learning.vertica.linear_model.PoissonRegressor.predict

PoissonRegressor.predict(vdf: Annotated[str | vDataFrame, ''], X: Annotated[str | list[str], 'STRING representing one column or a list of columns'] | None = None, name: str | None = None, inplace: bool = True) → vDataFrame

Predicts using the input relation.

Parameters

vdf: SQLRelation

Object used to run the prediction. You can also specify a customized relation, but you must enclose it with an alias. For example, (SELECT 1) x is valid, whereas (SELECT 1) and SELECT 1 are invalid.

X: SQLColumns, optional

list of the columns used to deploy the models. If empty, the model predictors are used.

name: str, optional

Name of the added :py:class`vDataColumn`. If empty, a name is generated.

inplace: bool, optional

If set to True, the prediction is added to the :py:class`vDataFrame`.

Returns

vDataFrame

the input object.

Examples

We import verticapy:

import verticapy as vp

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

Divide your dataset into training and testing subsets.

data = vpd.load_winequality()
train, test = data.train_test_split(test_size = 0.2)

Let’s import the model:

from verticapy.machine_learning.vertica import LinearRegression

Then we can create the model:

model = LinearRegression(
    tol = 1e-6,
    max_iter = 100,
    solver = 'newton',
    fit_intercept = True,
)

We can now fit the model:

model.fit(
    train,
    [
        "fixed_acidity",
        "volatile_acidity",
        "citric_acid",
        "residual_sugar",
        "chlorides",
        "density",
    ],
    "quality",
    test,
)



=======
details
=======
   predictor    |coefficient|std_err | t_value |p_value 
----------------+-----------+--------+---------+--------
   Intercept    | 150.88602 | 6.89376|21.88734 | 0.00000
 fixed_acidity  |  0.14831  | 0.01244|11.91894 | 0.00000
volatile_acidity| -0.71179  | 0.08791|-8.09727 | 0.00000
  citric_acid   | -0.09086  | 0.09599|-0.94660 | 0.34389
 residual_sugar |  0.04657  | 0.00387|12.04549 | 0.00000
   chlorides    | -0.02024  | 0.38848|-0.05211 | 0.95844
    density     |-146.89734 | 7.01153|-20.95083| 0.00000


==============
regularization
==============
type| lambda 
----+--------
none| 1.00000


===========
call_string
===========
linear_reg('"public"."_verticapy_tmp_linearregression_v_mldb_fcccdbc4979911efa8720242ac120002_"', '"public"."_verticapy_tmp_view_v_mldb_fd222476979911efa8720242ac120002_"', '"quality"', '"fixed_acidity", "volatile_acidity", "citric_acid", "residual_sugar", "chlorides", "density"'
USING PARAMETERS optimizer='newton', epsilon=1e-06, max_iterations=100, regularization='none', lambda=1, alpha=0.5, fit_intercept=true)

===============
Additional Info
===============
       Name       |Value
------------------+-----
 iteration_count  |  1  
rejected_row_count|  0  
accepted_row_count|5193 

Prediction is straight-forward:

model.predict(
    test,
    [
        "fixed_acidity",
        "volatile_acidity",
        "citric_acid",
        "residual_sugar",
        "chlorides",
        "density",
    ],
    "prediction",
)
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)
123
prediction
Float(22)
14.80.130.321.20.04240.098.00.98983.420.6411.871white6.13234762827753
24.80.2250.381.20.07447.0130.00.991323.310.410.360white5.83534371057723
34.90.2350.2711.750.0334.0118.00.99543.070.59.460white5.74587997679663
44.90.3350.141.30.03669.0168.00.992123.470.4610.466666666666750white5.68159288597147
55.00.4550.181.90.03633.0106.00.987463.210.8314.071white6.31985583869766
65.10.310.30.90.03728.0152.00.9923.540.5610.160white5.7134924380112
75.20.3350.21.70.03317.074.00.990023.340.4812.360white6.04780609604683
85.20.440.041.40.03643.0119.00.98943.360.3312.181white6.06465161577049
95.40.30.31.20.02925.093.00.987423.310.413.671white6.45202534176269
105.60.120.332.90.04421.073.00.988963.170.3212.981white6.45972214086351
115.60.120.332.90.04421.073.00.988963.170.3212.981white6.45972214086351
125.60.250.192.40.04942.0166.00.9923.250.4310.460white5.90995748620654
135.60.350.46.30.02223.0174.00.99223.540.511.671white5.97247400116262
145.60.420.342.40.02234.097.00.989153.220.3812.871white6.19452710834176
155.60.6150.01.60.08916.059.00.99433.580.529.950red5.2914901244184
165.60.620.031.50.086.013.00.994983.660.6210.140red5.18084058804806
175.70.150.283.70.04557.0151.00.99133.220.2711.260white6.15123594044513
185.70.210.321.60.0333.0122.00.990443.330.5211.960white6.13373913955135
195.70.260.31.80.03930.0105.00.989953.480.5212.571white6.18107759434662
205.70.280.361.80.04138.090.00.990023.270.9811.971white6.15106661275428
215.80.120.211.30.05635.0121.00.99083.320.3311.460white6.15524720236164
225.80.310.324.50.02428.094.00.989063.250.5213.771white6.4152740757892
235.80.610.111.80.06618.028.00.994833.550.6610.960red5.24663959313975
245.90.120.274.80.0340.0110.00.992263.550.6812.160white6.11366608370852
255.90.140.21.60.0426.0114.00.991053.250.4511.460white6.13432062355452
265.90.210.311.80.03345.0142.00.989843.350.512.760white6.26170092770718
276.00.160.2712.00.0339.098.00.994023.150.3410.850white6.17676625051752
286.00.20.252.00.04130.095.00.990783.270.5611.160white6.16016963937335
296.00.220.281.10.03447.090.00.988623.220.3812.660white6.41873780532561
306.00.260.334.350.0415.080.00.989343.290.512.760white6.43117707931336
316.00.270.261.30.03832.0138.00.991253.460.4311.160white6.00785779149135
326.00.290.251.40.03330.0114.00.987943.080.4313.260white6.48551863623754
336.00.320.31.30.02518.0112.00.988023.070.6413.371white6.44337515752005
346.00.320.37.30.17446.0159.00.995193.180.499.450white5.66650502296534
356.00.350.460.90.0339.065.00.989343.240.3512.140white6.19479007360204
366.00.50.01.40.05715.026.00.994483.360.459.550red5.39756356726804
376.10.20.251.20.03834.0128.00.99213.240.4410.150white5.943903612463
386.10.210.381.50.03937.0122.00.989723.20.4312.060white6.28853882921791
396.10.220.56.60.04530.0122.00.994153.220.499.960white5.85713069097309
406.10.250.497.60.05267.0226.00.99563.160.478.950white5.67010937482917
416.10.310.342.80.04259.5162.00.991793.270.4710.860white5.97739253897873
426.10.320.241.50.03638.0124.00.98983.290.4212.471white6.21127144436412
436.10.320.3310.70.03627.098.00.995213.340.5210.260white5.83679262732932
446.10.40.189.00.05128.5259.00.99643.190.58.850white5.5392038743085
456.20.180.494.50.04717.090.00.99193.270.3711.660white6.13403060379792
466.20.250.313.20.0332.0150.00.990143.180.3112.060white6.29890731109523
476.20.250.547.00.04658.0176.00.994543.190.710.450white5.80828989408397
486.20.260.28.00.04735.0111.00.994453.110.4210.460white5.891832802333
496.20.280.4313.00.03964.0233.00.997453.080.388.950white5.6490016693952
506.20.320.167.00.04530.0136.00.99493.180.479.660white5.7401297648351
516.20.320.452.90.02937.094.00.989983.250.612.460white6.24591469744877
526.20.360.148.90.03638.0155.00.996223.270.59.450white5.60822972668427
536.20.360.148.90.03638.0155.00.996223.270.59.450white5.60822972668427
546.30.130.421.10.04363.0146.00.990663.130.7211.271white6.2147187301899
556.30.20.1810.60.04557.0159.00.996663.090.549.250white5.74765948818134
566.30.220.345.00.03236.093.00.990123.270.3613.571white6.41908375810681
576.30.260.255.20.04611.0133.00.992022.970.6811.060white6.12871474617245
586.30.260.257.80.05844.0166.00.99613.240.419.050white5.65020406841933
596.30.320.1717.750.0651.0190.00.999163.130.488.860white5.62855775039526
606.30.320.321.50.0324.0101.00.989233.210.4213.050white6.31751744299444
616.30.340.364.90.03531.0185.00.99463.150.499.750white5.66903384951843
626.30.390.081.70.0663.020.00.99543.340.589.450red5.3917271940347
636.30.40.245.10.03643.0131.00.991863.240.4411.360white6.04902169485305
646.40.1050.291.10.03544.0140.00.991423.170.5510.771white6.14767687927267
656.40.1250.295.850.04224.099.00.9923.230.3212.071white6.26929060710222
666.40.150.441.20.04367.0150.00.99073.140.7311.271white6.21227744312867
676.40.170.322.40.04841.0200.00.99383.50.59.760white5.80934227885953
686.40.220.327.20.02815.083.00.9933.130.5510.981white6.11519545763232
696.40.240.2520.20.08335.0157.00.999763.170.59.150white5.71854754415105
706.40.240.320.950.04123.0131.00.990333.250.3511.850white6.20187053329872
716.40.240.495.80.05325.0120.00.99423.010.9810.560white5.84353651733758
726.40.240.495.80.05325.0120.00.99423.010.9810.560white5.84353651733758
736.40.240.511.60.04760.0211.00.99663.180.579.350white5.76028250875322
746.40.250.418.60.04257.0173.00.99653.00.449.150white5.63643320502462
756.40.250.571.00.06221.0122.00.992383.00.49.550white5.87280036528665
766.40.270.497.30.04653.0206.00.99563.240.439.260white5.6865181886767
776.40.290.1815.00.0421.0116.00.997363.140.59.250white5.80059567946628
786.40.310.3112.90.04555.0161.00.995463.020.5910.250white5.95576122540115
796.40.330.281.10.03830.0110.00.99173.120.4210.560white5.94724008530568
806.40.430.271.10.0545.0110.00.99393.240.529.140white5.55347137127376
816.40.50.22.40.05919.0112.00.993143.180.49.260white5.68208375584143
826.40.570.021.80.0674.011.00.9973.460.689.550red5.05348801638158
836.50.130.371.00.03648.0114.00.99113.410.5111.581white6.17977426838314
846.50.160.334.80.04345.0114.00.9923.180.4411.260white6.20665911313964
856.50.180.331.40.02935.0138.00.991143.360.611.571white6.16071164750679
866.50.190.321.40.0431.0132.00.99223.360.5410.871white5.99856849387365
876.50.220.313.90.04617.0106.00.990983.150.3111.550white6.27363333555761
886.50.220.516.40.04836.0182.00.999043.020.498.860white5.65441978538234
896.50.250.457.80.04852.0188.00.995763.20.539.150white5.71895894929449
906.50.260.313.60.0336.092.00.990263.220.6212.681white6.3372815912264
916.50.370.32.20.03339.0107.00.988943.220.5313.571white6.38854338136832
926.50.370.333.50.03623.092.00.991363.180.3811.260white6.09080187731689
936.50.410.2414.00.04824.0113.00.99823.440.539.860white5.55443736489377
946.50.460.315.00.02715.072.00.991653.260.611.571white6.05598976701989
956.50.480.020.90.04332.099.00.992263.140.479.840white5.78724967697934
966.60.160.341.10.03741.0115.00.98993.010.6812.060white6.35689068521921
976.60.160.571.10.1358.0140.00.99273.120.399.371white5.92279682285789
986.60.170.31.10.03113.073.00.990953.170.5811.060white6.19928656074731
996.60.190.351.50.03737.0107.00.990063.180.6812.071white6.32975135627632
1006.60.210.295.350.02943.0106.00.991122.930.4311.571white6.34469982393324
Rows: 1-100 | Columns: 15

Important

For this example, a specific model is utilized, and it may not correspond exactly to the model you are working with. To see a comprehensive example specific to your class of interest, please refer to that particular class.