我已经用Logistic回归训练了一个数据集。但是,我找不到经过训练的数据的学习曲线和决策边界的任何绘图代码块。我把代码放在下面。那么,我该怎么做呢?
library(mapdeck)
library(sf)
library(sfheaders)
library(data.table)
## 'roads' is an sf object included in mapdeck
sf_roads <- mapdeck::roads
## you don't need this, I only use it later in the plot so I can subset only 'long'
## roads, so the gif is below 2mb!
sf_roads$length <- as.numeric( sf::st_length( sf_roads ) )
sf_roads$id <- 1:nrow( sf_roads ) ## for joining the 'length' back on
## grab the road coordinates
dt <- sf::st_coordinates( sf_roads )
dt <- as.data.table( dt )
## st_coordinates returns a L1 'id', which is equivalent to our 'id' above
## Need Z and M attributes
dt[, Z := 0 ] ## can be actual elevation if you have it
dt[, M := 1:.N, by = .(L1)] ## this 'M' is your timestamp
## convert back to sf LINESTRING
sf_trips <- sfheaders::sf_linestring(
obj = dt
, x = "X"
, y = "Y"
, z = "Z"
, m = "M"
, linestring_id = "L1"
)
## You don't need this bit, where I join the 'length' back on.
sf_roads$geometry <- NULL
sf_trips <- merge(
x = sf_trips
, y = sf_roads
, by.x = "L1"
, by.y = "id"
)
mapdeck(
style = mapdeck_style("dark")
) %>%
add_trips(
data = sf_trips[ sf_trips$length > 500, ] ## only showing 'long' roads
, stroke_colour = "L1"
, stroke_width = 100
, opacity = 0.8
, animation_speed = 10
, trail_length = 50
, palette =
)