Loading...

vastorbit.machine_learning.vast.svm.LinearSVC.predict_proba

LinearSVC.predict_proba(vdf: Annotated[str | VastFrame, ''], X: Annotated[str | list[str], 'STRING representing one column or a list of columns'] | None = None, name: str | None = None, pos_label: Annotated[bool | float | str | timedelta | datetime, 'Python Scalar'] | None = None, inplace: bool = True) VastFrame

Returns the model’s probabilities 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 VastColumn. If empty, a name is generated.

  • pos_label (PythonScalar, optional) – Class label. For binary classification, this can be either 1 or 0.

  • inplace (bool, optional) – If set to True, the prediction is added to the VastFrame.

Returns:

the input object.

Return type:

VastFrame

Examples

For this example, we will use the winequality dataset.

import vastorbit.datasets as vod

data = vod.load_winequality()
123
fixed_acidity
Decimal(6, 3)
123
volatile_acidity
Decimal(7, 4)
123
citric_acid
Decimal(6, 3)
123
residual_sugar
Decimal(7, 3)
123
chlorides
Double
123
free_sulfur_dioxide
Decimal(7, 2)
123
total_sulfur_dioxide
Decimal(7, 2)
123
density
Double
123
ph
Decimal(6, 3)
123
sulphates
Decimal(6, 3)
123
alcohol
Double
123
quality
Integer
123
good
Integer
Abc
color
Varchar(20)
16.30.670.4812.60.05257.0222.00.99793.170.529.360white
27.40.40.295.40.04431.0122.00.9943.30.511.181white
37.10.260.312.20.04429.0128.00.99373.340.6410.981white
49.00.310.486.60.04311.073.00.99382.90.3811.650white
56.30.390.246.90.0699.0117.00.99423.150.3510.240white
68.20.220.366.80.03412.090.00.99443.010.3810.581white
77.10.190.283.60.03316.078.00.9932.910.7811.460white
87.30.250.3613.10.0535.0200.00.99863.040.468.971white
97.90.20.341.20.0429.0118.00.99323.140.4110.660white
107.10.260.325.90.03739.097.00.99343.310.411.660white
117.00.20.345.70.03532.083.00.99283.190.4611.560white
126.90.30.334.10.03526.0155.00.99253.250.7912.381white
138.10.290.497.10.04222.0124.00.99443.140.4110.860white
145.80.170.31.40.03755.0130.00.99093.290.3811.360white
155.90.4150.020.80.03822.063.00.99323.360.369.350white
166.60.230.261.30.04516.0128.00.99343.360.610.060white
178.60.550.3515.550.05735.5366.51.00013.040.6311.030white
186.90.350.741.00.04418.0132.00.9923.130.5510.250white
197.60.140.741.60.0427.0103.00.99163.070.410.871white
209.20.280.4911.80.04229.0137.00.9983.10.3410.140white
216.20.180.494.50.04717.090.00.99193.270.3711.660white
225.30.1650.241.10.05125.0105.00.99253.320.479.150white
239.80.250.7410.00.05636.0225.00.99773.060.4310.040white
248.10.290.497.10.04222.0124.00.99443.140.4110.860white
256.80.220.490.90.05226.0128.00.9913.250.3511.460white
267.20.220.491.00.04534.0140.00.993.050.3412.760white
277.40.250.491.10.04235.0156.00.99173.130.5511.350white
288.20.180.491.10.03328.081.00.99233.00.6810.471white
296.10.220.491.50.05118.087.00.99283.30.469.650white
307.00.390.241.00.0488.0119.00.99233.00.3110.140white
316.10.220.491.50.05118.087.00.99283.30.469.650white
326.50.360.492.90.0316.094.00.99023.10.4912.171white
337.10.290.491.20.03132.099.00.98933.070.3312.260white
347.40.250.491.10.04235.0156.00.99173.130.5511.350white
356.90.230.2414.20.05319.094.00.99823.170.59.650white
368.50.560.7417.850.05151.0243.01.00052.990.79.250white
378.20.180.491.10.03328.081.00.99233.00.6810.471white
386.30.230.497.10.0567.0210.00.99513.230.349.550white
396.10.250.497.60.05267.0226.00.99563.160.478.950white
407.20.260.7413.60.0556.0162.00.9983.030.448.850white
417.20.310.241.40.05717.0117.00.99283.160.3510.550white
428.00.250.491.20.06127.0117.00.99383.080.349.450white
437.00.180.495.30.0434.0125.00.99143.240.412.260white
447.80.430.4913.00.03337.0158.00.99553.140.3511.360white
458.30.20.744.450.04433.0130.00.99243.250.4212.260white
466.30.270.491.20.06335.092.00.99113.380.4212.260white
477.40.160.491.20.05518.0150.00.99173.230.4711.260white
487.40.160.491.20.05518.0150.00.99173.230.4711.260white
496.90.190.496.60.03649.0172.00.99323.20.2711.560white
507.80.430.4913.00.03337.0158.00.99553.140.3511.360white
517.20.40.491.10.04811.0138.00.99293.010.429.350white
527.80.430.4913.00.03337.0158.00.99553.140.3511.360white
537.60.520.4914.00.03437.0156.00.99583.140.3811.871white
548.30.210.4919.80.05450.0231.01.00122.990.549.250white
556.90.340.7411.20.06944.0150.00.99683.00.819.250white
566.30.270.491.20.06335.092.00.99113.380.4212.260white
578.30.20.744.450.04433.0130.00.99243.250.4212.260white
587.10.220.742.70.04442.0144.00.9913.310.4112.260white
597.90.110.494.50.04827.0133.00.99463.240.4210.660white
608.50.170.743.60.0529.0128.00.99283.280.412.460white
616.40.1450.495.40.04854.0164.00.99463.560.4410.860white
627.40.160.491.20.05518.0150.00.99173.230.4711.260white
638.30.190.491.20.05111.0137.00.99183.060.4611.060white
648.00.440.499.10.03146.0151.00.99263.160.2712.781white
657.00.20.740.80.04419.0163.00.99313.460.5310.250white
666.90.190.496.60.03649.0172.00.99323.20.2711.560white
677.10.250.493.00.0330.096.00.99033.130.3912.371white
686.50.240.241.60.04615.060.00.99283.190.399.850white
697.20.40.491.10.04811.0138.00.99293.010.429.350white
707.60.520.4914.00.03437.0156.00.99583.140.3811.871white
717.80.430.4913.00.03337.0158.00.99553.140.3511.360white
727.80.210.491.350.0526.048.00.99113.150.2811.450white
737.00.20.495.90.03839.0128.00.99383.210.4810.860white
746.90.250.243.60.05713.085.00.99422.990.489.540white
757.20.080.491.30.0518.0148.00.99453.460.4410.260white
767.10.850.498.70.02840.0184.00.99623.220.3610.750white
777.60.510.241.20.0410.0104.00.9923.050.2910.860white
787.90.220.244.60.04439.0159.00.99272.990.2811.560white
797.70.160.492.00.05620.0124.00.99483.320.4910.760white
807.20.080.491.30.0518.0148.00.99453.460.4410.260white
816.60.250.241.70.04826.0124.00.99423.370.610.160white
826.70.160.492.40.04657.0187.00.99523.620.8110.460white
836.90.250.243.60.05713.085.00.99422.990.489.540white
847.50.320.244.60.0538.0134.00.99583.140.59.130white
857.40.280.491.50.03420.0126.00.99182.980.3910.660white
866.20.150.490.90.03317.051.00.99323.30.79.460white
876.70.250.7419.40.05444.0169.01.00043.510.459.860white
886.50.260.7413.30.04468.0224.00.99723.180.549.560white
897.90.160.7417.850.03752.0187.00.99982.990.419.350white
905.60.1850.491.10.0328.0117.00.99183.550.4510.360white
917.50.20.491.30.0318.097.00.99183.060.6211.150white
928.00.30.499.40.04647.0188.00.99643.140.4810.050white
938.00.340.499.00.03339.0180.00.99363.130.3812.381white
947.70.350.498.650.03342.0186.00.99313.140.3812.481white
957.60.290.499.60.0345.0197.00.99383.130.3812.371white
966.70.620.241.10.0396.062.00.99343.410.3210.450white
976.80.270.491.20.04435.0126.00.993.130.4812.171white
987.70.270.491.80.04123.086.00.99143.160.4212.560white
996.70.510.242.10.04314.0155.00.99043.220.613.060white
1007.40.190.499.30.0326.0132.00.9942.990.3211.071white
Rows: 1-100 | Columns: 14
train, test = data.train_test_split(test_size = 0.5)

Let’s import the model:

from vastorbit.machine_learning.vast import LogisticRegression

Then we can create the model:

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

We can now fit the model:

model.fit(
    train,
    [
        "fixed_acidity",
        "volatile_acidity",
        "citric_acid",
        "residual_sugar",
        "chlorides",
        "density",
    ],
    "good",
    test,
)
model.predict_proba(
    test,
    [
        "fixed_acidity",
        "volatile_acidity",
        "citric_acid",
        "residual_sugar",
        "chlorides",
        "density",
    ],
    "prediction",
)
123
fixed_acidity
Decimal(6, 3)
123
volatile_acidity
Decimal(7, 4)
123
citric_acid
Decimal(6, 3)
123
residual_sugar
Decimal(7, 3)
123
chlorides
Double
123
free_sulfur_dioxide
Decimal(7, 2)
123
total_sulfur_dioxide
Decimal(7, 2)
123
density
Double
123
ph
Decimal(6, 3)
123
sulphates
Decimal(6, 3)
123
alcohol
Double
123
quality
Integer
123
good
Integer
Abc
color
Varchar(20)
123
seedrand
Decimal(26, 6)
123
prediction_0
Double
123
prediction_1
Double
19.90.350.381.50.057999999999999931.047.00.996763.260.8210.671red0.140.80220983003062510.19779016996937496
29.10.290.332.050.06313.027.00.995163.260.8411.771red0.060.78628770269921670.21371229730078334
36.80.360.321.80.0674.08.00.99283.360.5512.871red0.260.79925900460850790.20074099539149215
48.20.430.291.60.08127.045.00.996033.250.5410.350red0.230.83884908435761850.16115091564238151
56.80.360.321.80.0674.08.00.99283.360.5512.871red0.490.79925900460850790.20074099539149215
68.90.350.43.60.1112.024.00.995493.230.712.071red0.150.84157134045095420.1584286595490459
78.90.280.451.70.0677.012.00.993543.250.5512.371red0.040.77033587175550470.2296641282444953
810.50.390.462.20.07514.027.00.995983.060.8411.460red0.420.83004809871108080.1699519012889193
98.00.180.370.90.04936.0109.00.990072.890.4412.760red0.460.70259261640766760.29740738359233243
107.00.50.141.80.07810.023.00.996363.530.6110.450red0.440.86255583226044360.1374441677395563
1111.30.360.662.40.1233.08.00.996423.20.5311.960red0.310.83749913943290180.16250086056709825
128.60.830.02.80.09517.043.00.998223.330.610.460red0.320.94571009357198270.05428990642801732
137.30.550.011.80.0939.015.00.995143.350.5811.071red0.380.88829196193065970.1117080380693403
148.10.820.04.10.0955.014.00.998543.360.539.650red0.020.9478033808014880.052196619198512074
157.50.570.082.60.08914.027.00.995923.30.5910.460red0.260.89430891713290110.10569108286709888
168.90.7450.182.50.07715.048.00.997393.20.479.760red0.180.92473386849448460.07526613150551544
1710.10.370.342.40.0855.017.00.996833.170.6510.671red0.20.83538140452358410.16461859547641583
187.30.910.11.80.07420.056.00.996723.350.569.250red0.00.94347473470516940.0565252652948306
198.70.410.416.20.07825.042.00.99533.240.7712.671red0.450.86463946749625020.13536053250374983
208.90.50.212.20.08821.039.00.996923.330.8311.160red0.460.8742058445871080.12579415541289193
217.40.9650.02.20.08816.032.00.997563.580.6710.250red0.150.95548243170046930.04451756829953066
226.90.490.191.70.07913.026.00.995473.380.649.860red0.090.85622742573348910.1437725742665109
238.90.50.212.20.08821.039.00.996923.330.8311.160red0.040.8742058445871080.12579415541289193
246.90.440.01.40.0732.038.00.994383.320.5811.460red0.060.8452354919327330.154764508067267
257.10.430.171.80.081999999999999927.051.00.996343.490.6410.450red0.440.84249730655656820.15750269344343185
269.30.490.361.70.0813.014.00.997023.270.7810.960red0.270.85919986174475920.14080013825524085
277.10.430.171.80.081999999999999927.051.00.996343.490.6410.450red0.050.84249730655656820.15750269344343185
288.50.460.591.40.41416.045.00.997023.031.349.250red0.390.9400772779584110.05992272204158895
295.60.6050.052.40.07319.025.00.992583.560.5512.950red0.170.88979761968796190.1102023803120381
307.60.420.253.90.10428.090.00.997843.150.579.150red0.170.86417082156453110.1358291784354689
319.90.530.572.40.09330.052.00.99713.190.7611.671red0.370.87227283876080210.12772716123919797
328.90.480.534.00.10099999999999993.010.00.995863.210.5912.171red0.020.8714250295326980.1285749704673021
3311.60.230.571.80.0743.08.00.99813.140.79.960red0.410.76417621868740250.2358237813125975
348.00.380.441.90.0986.015.00.99563.30.6411.460red0.170.82319858625928980.17680141374071023
3510.20.290.652.40.0756.017.00.995653.220.6311.860red0.430.78076153079498880.21923846920501125
368.20.740.092.00.0675.010.00.994183.280.5711.860red0.260.91985690543739860.08014309456260135
377.70.610.182.40.0836.020.00.99633.290.610.260red0.060.8966100384587440.10338996154125604
388.00.620.352.80.08628.052.00.9973.310.6210.850red0.10.89640157181622330.10359842818377671
399.30.330.451.50.05719.037.00.994983.180.8911.171red0.240.78512169226114890.21487830773885105
407.50.770.28.10.09830.092.00.998923.20.589.250red0.360.94980989990250670.050190100097493265
417.50.770.28.10.09830.092.00.998923.20.589.250red0.010.94980989990250670.050190100097493265
429.90.320.562.00.0733.08.00.995343.150.7311.460red0.210.79173656937347490.2082634306265251
438.60.370.656.40.083.08.00.998173.270.5811.050red0.080.84214344848536850.15785655151463146
448.60.370.656.40.083.08.00.998173.270.5811.050red0.070.84214344848536850.15785655151463146
457.90.30.688.30.0537.5278.00.993163.010.5112.371red0.420.81530361048147380.18469638951852618
4610.30.270.561.40.0473.08.00.994713.160.5111.860red0.080.75084597380641290.2491540261935871
477.90.30.688.30.0537.5289.00.993163.010.5112.371red0.150.81530361048147380.18469638951852618
487.20.380.31.80.07331.070.00.996853.420.599.560red0.130.81392936331358750.18607063668641255
498.70.420.452.40.07232.059.00.996173.330.7712.060red0.160.83142156865541340.16857843134458655
507.20.380.31.80.07331.070.00.996853.420.599.560red0.240.81392936331358750.18607063668641255
516.80.480.081.80.07440.064.00.995293.120.499.650red0.320.85736151596064510.14263848403935486
528.50.340.44.70.0553.09.00.997383.380.6611.671red0.140.81922999020588520.18077000979411484
537.90.190.421.60.05718.030.00.9943.290.6911.260red0.170.7177047643229280.2822952356770721
547.90.340.422.00.0868.019.00.995463.350.611.460red0.330.80431806187948170.19568193812051826
557.00.540.092.00.08110.016.00.994793.430.5911.560red0.050.87811757025561650.12188242974438349
569.20.310.362.20.07911.031.00.996153.330.8612.071red0.430.80322919411098590.19677080588901402
579.40.40.472.50.0876.020.00.997723.150.510.550red0.490.83563895369118830.16436104630881168
588.60.520.381.50.0965.018.00.996663.20.529.450red0.340.86801943505242040.13198056494757965
598.40.340.422.10.07223.036.00.993923.110.7812.460red0.110.80040790929177750.19959209070822248
607.40.490.272.10.07114.025.00.993883.350.6312.060red0.170.85386274047588040.14613725952411957
617.40.490.272.10.07114.025.00.993883.350.6312.060red0.20.85386274047588040.14613725952411957
628.30.530.01.40.076.014.00.995933.250.6410.060red0.340.8768200739196680.12317992608033197
638.90.240.391.60.0743.010.00.996983.120.599.560red0.180.76175297388223310.23824702611776688
645.00.40.54.30.04629.080.00.99023.490.6613.660red0.290.804704676807390.19529532319261003
657.00.690.072.50.09115.021.00.995723.380.611.360red0.060.9170938657631450.08290613423685499
667.00.690.072.50.09115.021.00.995723.380.611.360red0.060.9170938657631450.08290613423685499
677.00.690.072.50.09115.021.00.995723.380.611.360red0.190.9170938657631450.08290613423685499
685.60.660.02.50.0667.015.00.992563.520.5812.950red0.250.90216563446923970.09783436553076034
696.60.50.01.80.06221.028.00.993523.440.5512.360red0.310.86112706061492450.1388729393850755
706.50.580.02.20.0963.013.00.995573.620.6211.540red0.420.89610518024081340.10389481975918662
715.80.290.261.70.0633.011.00.99153.390.5413.560red0.260.76574847155149730.23425152844850278
7210.50.430.353.30.09224.070.00.997983.210.6910.560red0.230.86517450383560480.13482549616439518
735.90.190.211.70.04557.0135.00.993413.320.449.550red0.060.71364394825561160.2863560517443884
747.20.480.075.50.08910.018.00.996843.370.6811.271red0.230.89130832639344180.1086916736065582
758.50.280.351.70.0616.015.00.995243.30.7411.871red0.430.77181160868509220.22818839131490778
7610.40.520.452.00.086.013.00.997743.220.7611.460red0.490.8696288594613360.130371140538664
7710.40.520.452.00.086.013.00.997743.220.7611.460red0.440.8696288594613360.130371140538664
787.00.220.31.80.06516.020.00.996723.610.8210.060red0.40.74350287974655970.25649712025344024
797.30.320.232.30.06635.070.00.995883.430.6210.150red0.360.79833856463590790.20166143536409206
8010.00.410.456.20.0716.014.00.997023.210.4911.871red0.170.86557718773948530.13442281226051467
8110.00.350.472.00.0616.011.00.995853.230.5212.060red0.470.80329598468953290.1967040153104671
828.20.330.322.80.0674.012.00.994733.30.7612.871red0.430.80677449939682070.19322550060317936
838.30.60.252.20.1189.038.00.996163.150.539.850red0.060.90362565063470360.09637434936529649
845.10.510.182.10.04216.0101.00.99243.460.8712.971red0.080.84059412274196840.15940587725803151
858.50.320.422.30.07512.019.00.994343.140.7111.871red0.450.79725128501107230.2027487149889277
869.00.7850.241.70.07810.021.00.996923.290.6710.050red0.070.92635456500981750.07364543499018252
879.90.540.262.00.1117.060.00.997092.940.9810.250red0.450.89246222088018510.10753777911981484
889.20.360.341.60.0625.012.00.996673.20.6710.560red0.480.80769025421301530.19230974578698462
899.70.420.462.10.0745.016.00.996493.270.7412.360red0.270.83435622826786750.1656437717321325
906.50.610.02.20.09548.059.00.995413.610.711.560red0.310.9021706256396220.09782937436037796
917.10.660.02.40.0526.011.00.993183.350.6612.771red0.360.90228117248643640.0977188275135637
928.20.350.332.40.07611.047.00.995993.270.8111.060red0.240.81432130316806180.18567869683193816
939.80.390.431.650.0685.011.00.994783.190.4611.450red0.00.81937802552199370.18062197447800635
9410.20.40.42.50.06841.054.00.997543.380.8610.560red0.470.83479048485055090.16520951514944912
956.70.640.232.10.0811.0119.00.995383.360.710.950red0.280.89483337392396710.10516662607603285
967.00.430.32.00.0856.039.00.993463.330.4611.960red0.460.83732757469747130.1626724253025287
979.10.40.574.60.086.020.00.996523.280.5712.560red0.160.84309243827750160.15690756172249842
986.40.8850.02.30.1666.012.00.995513.560.5110.850red0.080.95765327039719750.042346729602802516
998.60.420.391.80.0686.012.00.995163.350.6911.781red0.30.82704089635423310.17295910364576697
1007.20.360.462.10.07424.044.00.995343.40.8511.071red0.070.79920443753167470.2007955624683253
Rows: 1-100 | Columns: 17

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.