Loading...

vastorbit.machine_learning.vast.ensemble.GradientBoostingClassifier.predict

GradientBoostingClassifier.predict(vdf: Annotated[str | VastFrame, ''], X: Annotated[str | list[str], 'STRING representing one column or a list of columns'] | None = None, name: str | None = None, cutoff: Annotated[int | float | Decimal, 'Python Numbers'] | None = None, inplace: bool = True) VastFrame

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 VastColumn. If empty, a name is generated.

  • cutoff (PythonNumber, optional) – Cutoff for which the tested category is accepted as a prediction. This parameter is only used for binary classification.

  • 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 Iris dataset.

import vastorbit.datasets as vod
data = vod.load_iris()
train, test = data.train_test_split(test_size = 0.2)
123
sepallengthcm
Decimal(5, 2)
123
sepalwidthcm
Decimal(5, 2)
123
petallengthcm
Decimal(5, 2)
123
petalwidthcm
Decimal(5, 2)
Abc
species
Varchar(30)
15.13.51.40.2Iris-setosa
24.93.01.40.2Iris-setosa
34.73.21.30.2Iris-setosa
44.63.11.50.2Iris-setosa
55.03.61.40.2Iris-setosa
65.43.91.70.4Iris-setosa
74.63.41.40.3Iris-setosa
85.03.41.50.2Iris-setosa
94.42.91.40.2Iris-setosa
104.93.11.50.1Iris-setosa
115.43.71.50.2Iris-setosa
124.83.41.60.2Iris-setosa
134.83.01.40.1Iris-setosa
144.33.01.10.1Iris-setosa
155.84.01.20.2Iris-setosa
165.74.41.50.4Iris-setosa
175.43.91.30.4Iris-setosa
185.13.51.40.3Iris-setosa
195.73.81.70.3Iris-setosa
205.13.81.50.3Iris-setosa
215.43.41.70.2Iris-setosa
225.13.71.50.4Iris-setosa
234.63.61.00.2Iris-setosa
245.13.31.70.5Iris-setosa
254.83.41.90.2Iris-setosa
265.03.01.60.2Iris-setosa
275.03.41.60.4Iris-setosa
285.23.51.50.2Iris-setosa
295.23.41.40.2Iris-setosa
304.73.21.60.2Iris-setosa
314.83.11.60.2Iris-setosa
325.43.41.50.4Iris-setosa
335.24.11.50.1Iris-setosa
345.54.21.40.2Iris-setosa
354.93.11.50.1Iris-setosa
365.03.21.20.2Iris-setosa
375.53.51.30.2Iris-setosa
384.93.11.50.1Iris-setosa
394.43.01.30.2Iris-setosa
405.13.41.50.2Iris-setosa
415.03.51.30.3Iris-setosa
424.52.31.30.3Iris-setosa
434.43.21.30.2Iris-setosa
445.03.51.60.6Iris-setosa
455.13.81.90.4Iris-setosa
464.83.01.40.3Iris-setosa
475.13.81.60.2Iris-setosa
484.63.21.40.2Iris-setosa
495.33.71.50.2Iris-setosa
505.03.31.40.2Iris-setosa
517.03.24.71.4Iris-versicolor
526.43.24.51.5Iris-versicolor
536.93.14.91.5Iris-versicolor
545.52.34.01.3Iris-versicolor
556.52.84.61.5Iris-versicolor
565.72.84.51.3Iris-versicolor
576.33.34.71.6Iris-versicolor
584.92.43.31.0Iris-versicolor
596.62.94.61.3Iris-versicolor
605.22.73.91.4Iris-versicolor
615.02.03.51.0Iris-versicolor
625.93.04.21.5Iris-versicolor
636.02.24.01.0Iris-versicolor
646.12.94.71.4Iris-versicolor
655.62.93.61.3Iris-versicolor
666.73.14.41.4Iris-versicolor
675.63.04.51.5Iris-versicolor
685.82.74.11.0Iris-versicolor
696.22.24.51.5Iris-versicolor
705.62.53.91.1Iris-versicolor
715.93.24.81.8Iris-versicolor
726.12.84.01.3Iris-versicolor
736.32.54.91.5Iris-versicolor
746.12.84.71.2Iris-versicolor
756.42.94.31.3Iris-versicolor
766.63.04.41.4Iris-versicolor
776.82.84.81.4Iris-versicolor
786.73.05.01.7Iris-versicolor
796.02.94.51.5Iris-versicolor
805.72.63.51.0Iris-versicolor
815.52.43.81.1Iris-versicolor
825.52.43.71.0Iris-versicolor
835.82.73.91.2Iris-versicolor
846.02.75.11.6Iris-versicolor
855.43.04.51.5Iris-versicolor
866.03.44.51.6Iris-versicolor
876.73.14.71.5Iris-versicolor
886.32.34.41.3Iris-versicolor
895.63.04.11.3Iris-versicolor
905.52.54.01.3Iris-versicolor
915.52.64.41.2Iris-versicolor
926.13.04.61.4Iris-versicolor
935.82.64.01.2Iris-versicolor
945.02.33.31.0Iris-versicolor
955.62.74.21.3Iris-versicolor
965.73.04.21.2Iris-versicolor
975.72.94.21.3Iris-versicolor
986.22.94.31.3Iris-versicolor
995.12.53.01.1Iris-versicolor
1005.72.84.11.3Iris-versicolor
Rows: 1-100 | Columns: 5

Let’s import the model:

from vastorbit.machine_learning.vast import NearestCentroid

Then we can create the model:

model = NearestCentroid(p = 2)

We can now fit the model:

model.fit(
    train,
    [
        "SepalLengthCm",
        "SepalWidthCm",
        "PetalLengthCm",
        "PetalWidthCm",
    ],
    "Species",
    test,
)

We can then get the prediction:

model.predict(test, name = "prediction"
123
sepallengthcm
Decimal(5, 2)
123
sepalwidthcm
Decimal(5, 2)
123
petallengthcm
Decimal(5, 2)
123
petalwidthcm
Decimal(5, 2)
Abc
species
Varchar(30)
123
seedrand
Decimal(26, 6)
123
prediction_irissetosa
Double
123
prediction_irisversicolor
Double
123
prediction_irisvirginica
Double
14.63.41.40.3Iris-setosa0.180.80560524417622810.115809531073518310.07858522475025351
25.03.41.50.2Iris-setosa0.150.81070619726853130.113712069607458870.07558173312400986
35.84.01.20.2Iris-setosa0.190.623430294798270.221419138577722020.15515056662400806
45.74.41.50.4Iris-setosa0.160.60297614514312910.232960673929554770.16406318092731592
55.13.71.50.4Iris-setosa0.060.81479160533525890.110884586817709060.07432380784703212
65.23.51.50.2Iris-setosa0.190.7784118498232050.133116116372252650.08847203380454234
74.93.11.50.1Iris-setosa0.040.7573669286383270.14601338166453960.09661968969713357
85.53.51.30.2Iris-setosa0.10.70443174143731730.176488540911427350.11907971765125538
95.13.41.50.2Iris-setosa0.170.79719315634951740.121964488493198120.0808423551572845
107.03.24.71.4Iris-versicolor0.080.14422846334842640.44442956884216440.4113419678094092
115.52.34.01.3Iris-versicolor0.170.15998822963385190.63800263379673010.20200913656941794
125.82.73.91.2Iris-versicolor0.170.118469880518302890.73488509731893570.14664502216276148
135.62.74.21.3Iris-versicolor0.110.093668662492521520.76573926810209260.14059206940538585
145.72.94.21.3Iris-versicolor0.00.078339712255327780.8005609294626160.12109935828205616
156.22.94.31.3Iris-versicolor0.160.076326142248654820.77659780904544480.1470760487059003
166.33.36.02.5Iris-virginica0.210.089876721390794640.203398335362826560.7067249432463788
177.13.05.92.1Iris-virginica0.170.097113828265024420.226182639136813860.6767035325981617
186.53.05.82.2Iris-virginica0.050.0396473612934814740.100896599607961480.859456039098557
196.43.25.32.3Iris-virginica0.110.082118664105550730.227651024559428870.6902303113350203
206.53.05.51.8Iris-virginica0.140.056649666560931160.16990651695997290.773443816479096
217.73.86.72.2Iris-virginica0.150.163008310045644840.297057748061620.5399339418927352
227.72.86.72.0Iris-virginica0.110.152325517095880770.295525442079664640.5521490408244546
236.22.84.81.8Iris-virginica0.090.104453495586290330.50471294871587640.39083355569783323
247.93.86.42.0Iris-virginica0.180.16569833630372340.305220460965028030.5290812027312486
256.42.85.62.2Iris-virginica0.030.0532144707413990950.146382661126820770.8004028681317801
266.32.85.11.5Iris-virginica0.110.101900925315659590.42747480486167030.47062426982267025
276.12.65.61.4Iris-virginica0.080.107204485832533180.33924070906809410.5535548050993727
286.43.15.51.8Iris-virginica0.030.0562173037549262360.168799409469586050.7749832867754879
296.93.15.42.1Iris-virginica0.210.087740104445708520.23207999207781620.6801799034764752
Rows: 1-29 | Columns: 9

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.