r

Error when trying to pass custom metric in Caret package

亡梦爱人 提交于 2021-02-10 19:31:57
问题 Related question - 1 I have a dataset like so: > head(training_data) year month channelGrouping visitStartTime visitNumber timeSinceLastVisit browser 1 2016 October Social 1477775021 1 0 Chrome 2 2016 September Social 1473037945 1 0 Safari 3 2017 July Organic Search 1500305542 1 0 Chrome 4 2017 July Organic Search 1500322111 2 16569 Chrome 5 2016 August Social 1471890172 1 0 Safari 6 2017 May Direct 1495146428 1 0 Chrome operatingSystem isMobile continent subContinent country source medium 1

Area between the two curves

╄→гoц情女王★ 提交于 2021-02-10 18:54:43
问题 I have two sets of data I had plotted two probability density functions. Now I want the area between the two probability density functions, which are in certain x range. I tried to integrate the area, trapezoidal rule etc: Calculating the area between a curve and a straight line without finding the function Error calculating the area between two lines using "integrate" How to measure area between 2 distribution curves in R / ggplot2 but all are in vain. Here is the link to the data i am

interpolation with matrices in R

徘徊边缘 提交于 2021-02-10 18:53:58
问题 I want to use linear interpolation to create a large matrix from 2 smaller matrices. I can do this using a function like this: mat1 <- matrix(rep(20, 4), ncol = 2) mat2 <- matrix(seq(21, 24, 1), ncol = 2) mat3 <- matrix(c(18, 27, 25, 12), ncol = 2) num.days <- c(31, 29) interpolate <- function(initial, final, n){ data.list <- list() for (i in 1:(n - 1)){ step1 <- (final - initial) / n step2 <- step1 * i data.list[[1]] <- initial data.list[[i+1]] <- round(step2 + initial, 2) } newmat = do.call

plotting a fitted segmented linear model shows more break points than what is estimated

不问归期 提交于 2021-02-10 18:53:51
问题 I was helping a friend with segmented regressions today. We were trying to fit a piecewise regression with a breakpoints to see if it fits data better than a standard linear model. I stumbled across a problem I cannot understand. When fitting a piecewise regression with a single breakpoint with the data provided, it does indeed fit a single breakpoint. However, when you predict from the model it gives what looks like 2 breakpoints. When plotting the model using plot.segmented() this problem

interpolation with matrices in R

三世轮回 提交于 2021-02-10 18:53:44
问题 I want to use linear interpolation to create a large matrix from 2 smaller matrices. I can do this using a function like this: mat1 <- matrix(rep(20, 4), ncol = 2) mat2 <- matrix(seq(21, 24, 1), ncol = 2) mat3 <- matrix(c(18, 27, 25, 12), ncol = 2) num.days <- c(31, 29) interpolate <- function(initial, final, n){ data.list <- list() for (i in 1:(n - 1)){ step1 <- (final - initial) / n step2 <- step1 * i data.list[[1]] <- initial data.list[[i+1]] <- round(step2 + initial, 2) } newmat = do.call

interpolation with matrices in R

别来无恙 提交于 2021-02-10 18:53:36
问题 I want to use linear interpolation to create a large matrix from 2 smaller matrices. I can do this using a function like this: mat1 <- matrix(rep(20, 4), ncol = 2) mat2 <- matrix(seq(21, 24, 1), ncol = 2) mat3 <- matrix(c(18, 27, 25, 12), ncol = 2) num.days <- c(31, 29) interpolate <- function(initial, final, n){ data.list <- list() for (i in 1:(n - 1)){ step1 <- (final - initial) / n step2 <- step1 * i data.list[[1]] <- initial data.list[[i+1]] <- round(step2 + initial, 2) } newmat = do.call

plotting a fitted segmented linear model shows more break points than what is estimated

有些话、适合烂在心里 提交于 2021-02-10 18:51:20
问题 I was helping a friend with segmented regressions today. We were trying to fit a piecewise regression with a breakpoints to see if it fits data better than a standard linear model. I stumbled across a problem I cannot understand. When fitting a piecewise regression with a single breakpoint with the data provided, it does indeed fit a single breakpoint. However, when you predict from the model it gives what looks like 2 breakpoints. When plotting the model using plot.segmented() this problem

Area between the two curves

Deadly 提交于 2021-02-10 18:50:03
问题 I have two sets of data I had plotted two probability density functions. Now I want the area between the two probability density functions, which are in certain x range. I tried to integrate the area, trapezoidal rule etc: Calculating the area between a curve and a straight line without finding the function Error calculating the area between two lines using "integrate" How to measure area between 2 distribution curves in R / ggplot2 but all are in vain. Here is the link to the data i am

how to convert a very large dataset to xts? - as.xts fails on 1.5M rows

梦想的初衷 提交于 2021-02-10 18:43:23
问题 I have the data: dput(head(data)) > dput(head(data)) structure(list(Gmt.time = c("01.06.2015 00:00", "01.06.2015 00:01", "01.06.2015 00:02", "01.06.2015 00:03", "01.06.2015 00:04", "01.06.2015 00:05" ), Open = c(0.88312, 0.88337, 0.88377, 0.88412, 0.88393, 0.8838 ), High = c(0.88337, 0.88378, 0.88418, 0.88418, 0.88393, 0.88393 ), Low = c(0.883, 0.88337, 0.88374, 0.88394, 0.88368, 0.88362 ), Close = c(0.88337, 0.88375, 0.88412, 0.88394, 0.8838, 0.88393 ), Volume = c(83.27, 100.14, 117.18, 52

how to convert a very large dataset to xts? - as.xts fails on 1.5M rows

别来无恙 提交于 2021-02-10 18:41:49
问题 I have the data: dput(head(data)) > dput(head(data)) structure(list(Gmt.time = c("01.06.2015 00:00", "01.06.2015 00:01", "01.06.2015 00:02", "01.06.2015 00:03", "01.06.2015 00:04", "01.06.2015 00:05" ), Open = c(0.88312, 0.88337, 0.88377, 0.88412, 0.88393, 0.8838 ), High = c(0.88337, 0.88378, 0.88418, 0.88418, 0.88393, 0.88393 ), Low = c(0.883, 0.88337, 0.88374, 0.88394, 0.88368, 0.88362 ), Close = c(0.88337, 0.88375, 0.88412, 0.88394, 0.8838, 0.88393 ), Volume = c(83.27, 100.14, 117.18, 52