I would like to to run several models (ols to ml) and automatically select the model with best rmse or R2 and use this best model fit to de prediction on r shiny. Does any one has a piece of code to learn from (even with fake models)?
on the documentation that was linked to I dont see that resample( appears anywhere ; The closest I see is
theres an implicit call to fit_resamples as part of the workflow_map() call
I found a solution like this one where i extract the name of a regression fit like "reg_ols" corresponding the the max R2 then use it inside a predict function: get((rownames(FOO[which.max(fun$model_r2),])))
=> it works when a call this function but strangely i have a pb: when i run : predict (reg_ols, newdata) or predict (get((rownames(FOO[which.max(fun$model_r2),]))), new data) THE RESULT IS DIFFERENT ;()
We can't comment on code that we have no context from which to determine why it should be expected to run. It doesn't seem tidy at all to be relying on rownames. You're probably just not retreiving what you thought you were.
You are right, sorry. Indeed, i did several checks and realized i had another issue that is simple to understand i use geocoder() to extract latitude/longitude using osm BUT at each code execution the geocoder() function send me back coordinates that are of course the same BUT with slight differences after two figures after the comma. So my question if i may: how to extract the max precision after comme each time? Thanks a lot
To help us help you, could you please prepare a repr oducible ex ample (reprex) illustrating your issue? Please have a look at this guide, to see how to create one:
I'm sorry. I ll try to do it indeed. I hesistated because i have a big code (i"m learning r shiny) so i have a extract the relevant piece of code. What i was saying is the if you give a postal adress to geocoder, you receive the correct lat/long but the slight variations after the commas.
Firstly, you havent linked to any R code; thats another language (java? )
I dont follow understanding what your issue is. geocode() from tidygeocoder will give you as much precision as it knows to give for the address you pass.
You can format this to text to percieve it at differing levels of precision, what do you mean by variations ? are you saying that you run the same address twice through geocode() and get different results each time ?
Thanks a lot for your response. I will test on R your format() function that i did not know.
For info, i only use 'osm' because 'arcgis' gives me no response for european adresses (I'm perhaps wrong).
Thank you again
Last question if possible:
regarding sampling data: please what is the difference or what is the best option between:
-createdatapartition()
-sample()
personnally i find the sample() function intuitive and easier to carry.
Many thanks,