Skip to contents

Returns model predictions from a model fitted with rf(), rf_repeat(), or rf_spatial().

Usage

get_predictions(model)

Arguments

model

A model produced by rf(), rf_repeat(), or rf_spatial().

Value

A vector with predictions, or median of the predictions across repetitions if the model was fitted with rf_repeat().

Examples


#loading example data
data(plant_richness_df)

#fitting a random forest model
rf.model <- rf(
  data = plant_richness_df,
  dependent.variable.name = "richness_species_vascular",
  predictor.variable.names = colnames(plant_richness_df)[5:21],
  n.cores = 1,
  verbose = FALSE
)

#get vector of predictions
x <- get_predictions(rf.model)
x
#>   [1]  5089.9686  4553.2001  1498.6098  6997.1780 10917.1038  2874.9074
#>   [7]  4879.5548  6091.4630  2929.2654  4314.0733  2908.4935  2868.7256
#>  [13]   719.7016  6064.0372  7862.8904  7124.7102  3743.8252  4495.1800
#>  [19]  5421.9854  3174.6544  6122.7444  6087.2123 11985.6153  2638.0687
#>  [25]   656.5402  6315.4036  2527.4894  2570.6949  1239.0518  1606.8977
#>  [31]  3755.0483  7468.7728  4479.5603  3248.7257  7644.6147  6270.9530
#>  [37]  2426.1410  2738.7782   850.1533  1234.8311  2617.0397  3664.5525
#>  [43]  3228.7475  3386.2269  3249.1632  3554.6452  2486.2164  1784.2087
#>  [49]  1830.1257  4164.4311  5287.7065  2983.7874  1577.6187  3138.6107
#>  [55]   608.9623 10850.7427  4202.2291  2099.1342  1480.4952   898.6531
#>  [61]  2391.1838  2341.7634 10007.5996  5485.5437  2915.7275  3239.8695
#>  [67]  9772.2748  4726.4460  1299.4710  3844.4597  4606.0415  1152.8957
#>  [73]  9136.2741  5494.1387  5610.2730   988.4926  2358.1904  1998.0878
#>  [79]  1330.7636  3839.3374  2204.8646  1570.0205  2811.1915  2672.7551
#>  [85]  3624.0725   756.0369  2674.0807  2596.1948  2734.3257  1961.9983
#>  [91]  5926.9062  1267.6369  1775.5636  8993.5469  4065.1506  4379.9417
#>  [97]  8145.7530  6970.5516  9551.2491  3101.2651  2931.6995  5297.6180
#> [103]  1694.3413  2543.9139  3606.4275  2420.4880  6755.3152  4282.0070
#> [109]  6552.2939  1112.3188  2591.1244  3779.8972  2689.5633  2098.8618
#> [115]  6621.7904   850.5737  2263.2761  1778.2165  3340.5704   911.3395
#> [121]  1652.2408 10666.7822  1308.8814  3415.6255  4019.1710  4771.1122
#> [127]  3212.5594  4067.9657  2670.4533  3837.7822  4648.7099  2616.5089
#> [133]   937.7306  4701.3611  6722.2070  8483.8930  1003.5022  2364.6951
#> [139]  3276.8705  1127.2561  6836.0442  2874.5358  1247.4081  5940.0026
#> [145]  5074.3997  1647.3183  3268.1437  4380.2851  1555.8793   635.3892
#> [151]  2881.3722  2869.9599  6154.1375  2403.1722  6432.8062  7045.6842
#> [157]  7674.0356  2743.9269  3380.3008  8534.0471  3489.7143  2363.4290
#> [163]  4920.7653  7381.5103 13682.3877  2919.3904  5012.3926  1996.3059
#> [169]  1906.3266  2104.9318  6543.4690   933.4083  1486.7635  4218.4585
#> [175]  2972.5470  3953.2742  3185.9614 14807.0903  3086.9862   501.3080
#> [181]  4866.7396  5612.4179   744.5291  3884.0051  6603.9572  3207.8454
#> [187]  5156.6593  8456.9709  4216.9714  4103.2941  4899.9128  9343.0380
#> [193]  4616.3915  5840.3574  9494.0949   894.0851   493.6557 14360.0564
#> [199]  2197.8118  1552.3253  3053.2866  3018.5477  5774.0916  6913.9601
#> [205]  3881.2811  4141.5380  6801.3874  3222.3693  2691.8048  1523.4945
#> [211]  2833.9950  3252.8523  5578.6175  9307.4694  5222.6798  7801.7061
#> [217]  1525.1829  4950.1168  1961.4530  2779.0307  2964.0033  2835.1727
#> [223]  6196.7575  4831.0779  3574.9780  4149.5948  2233.7732