HannaMeyer / CAST

Developer Version of the R package CAST: Caret Applications for Spatio-Temporal models
https://hannameyer.github.io/CAST/
108 stars 30 forks source link

Predict for other class object #105

Closed ManuelSpinola closed 7 months ago

ManuelSpinola commented 7 months ago

Is it possible to use the predict function with other class object besides terra raster?

HannaMeyer commented 7 months ago

CAST does not implement a particular method for predict that is specific for any classes of the CAST package. The predict function can be used with various types of class objects beyond just Terra raster objects, depending on the context and the libraries you're using.

ManuelSpinola commented 7 months ago

Thank you very much.

However, when I try predict with a data frame I got the message:

prediction <- predict(y_x_long_points_df, model_default, na.rm = TRUE)

Error in UseMethod("predict") : no applicable method for 'predict' applied to an object of class "c('tbl_df', 'tbl', 'data.frame')"

El dom, 24 mar 2024 a las 4:37, Hanna Meyer @.***>) escribió:

CAST does not implement a particular method for predict that is specific for any classes of the CAST package. The predict function can be used with various types of class objects beyond just Terra raster objects, depending on the context and the libraries you're using.

— Reply to this email directly, view it on GitHub https://github.com/HannaMeyer/CAST/issues/105#issuecomment-2016765690, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFI3FB4XMJ6BSUFCKHDCA3DYZ2UHHAVCNFSM6AAAAABFBU4AYOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMJWG43DKNRZGA . You are receiving this because you authored the thread.Message ID: @.***>

-- Manuel Spínola, Ph.D. Instituto Internacional en Conservación y Manejo de Vida Silvestre Universidad Nacional Apartado 1350-3000 Heredia COSTA RICA @. @.> @.*** Teléfono: (506) 8706 - 4662 Sitio web institucional: ICOMVIS http://www.icomvis.una.ac.cr/index.php/manuel Sitio web personal: Sitio personal https://mspinola-sitioweb.netlify.app Blog sobre Ciencia de Datos: Blog de Ciencia de Datos https://mspinola-ciencia-de-datos.netlify.app

HannaMeyer commented 7 months ago

This is not an issue of CAST. When you use predict for data frames it's the other way round: model first, new data second. See ?terra::predict compared to ?stats::predict. Hope that helps!

ManuelSpinola commented 7 months ago

Thank you very much.

El lun, 25 mar 2024 a las 1:51, Hanna Meyer @.***>) escribió:

This is not an issue of CAST. When you use predict for data frames it's the other way round: model first, new data second. See ?terra::predict compared to ?stats::predict. Hope that helps!

— Reply to this email directly, view it on GitHub https://github.com/HannaMeyer/CAST/issues/105#issuecomment-2017406895, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFI3FB2ANJ6GHTJHLMJPZCLYZ7JQ5AVCNFSM6AAAAABFBU4AYOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMJXGQYDMOBZGU . You are receiving this because you authored the thread.Message ID: @.***>

-- Manuel Spínola, Ph.D. Instituto Internacional en Conservación y Manejo de Vida Silvestre Universidad Nacional Apartado 1350-3000 Heredia COSTA RICA @. @.> @.*** Teléfono: (506) 8706 - 4662 Sitio web institucional: ICOMVIS http://www.icomvis.una.ac.cr/index.php/manuel Sitio web personal: Sitio personal https://mspinola-sitioweb.netlify.app Blog sobre Ciencia de Datos: Blog de Ciencia de Datos https://mspinola-ciencia-de-datos.netlify.app