Comments (2)
library(CASdatasets) ## ausprivauto0405
library(dplyr) ## group_by, summarise
library(ggplot2) ## ggplot, geom_histogram, geom_bar, geom_point, coord_flip
library(MASS) ## stepAIC
library(glmnet)
library(glmnetUtils) ## cv.glmnet
library(cvTools) ## cvFolds
library(Matrix) ## sparse.model.matrix
library(makedummies) ## makedummies
library(aglm) ## cv.aglm
library(parallel) ## detectCores
## SETTING
col1 <- "gray"
col2 <- "deeppink"
SEED <- 2018
CPU <- detectCores() - 1
data("ausprivauto0405") ## load data
aus.df <- ausprivauto0405
rm(ausprivauto0405)
dim(aus.df) ## dimension of data
## IsClaim
aus.df["IsClaim"] <- aus.df$ClaimNb > 0
## DATA SPLIT
set.seed(SEED) # for reproduciability
hold.out.num <-
sample(seq(nrow(aus.df)), round(nrow(aus.df) / 4))
aus.df['isHoldOut'] <- FALSE
aus.df[hold.out.num, 'isHoldOut'] <- TRUE
train <- aus.df[!aus.df$isHoldOut, ]
hold.out <- aus.df[aus.df$isHoldOut, ]
## AGLM
lambda.list <- 0.1^seq(1, 7, length.out = 100)
aus.x.ohe <- makedummies(aus.df[, 1:6], basal_level = FALSE)
aglm.cv.cl <- cv.aglm(
x = aus.x.ohe[!aus.df$isHoldOut, ],
y = as.integer(aus.df[!aus.df$isHoldOut, "IsClaim"]),
type.measure = "auc",
nfolds = nfold,
family = "binomial",
alpha = 1,
lambda = lambda.list
)
(lambda.min <- aglm.cv.cl@lambda.min)
aglm.cl <- aglm(
x = aus.x.ohe[!aus.df$isHoldOut, ],
y = as.integer(aus.df[!aus.df$isHoldOut, "IsClaim"]),
family = "binomial",
alpha = 1,
lambda = lambda.min
)
## PREDICTION
aglm.pred <-
predict(aglm.cl, newx = aus.x.ohe[aus.df$isHoldOut, ], type = "response")
aglm.pred <-
predict(aglm.cl, newx = aus.x.ohe[aus.df$isHoldOut, ]) # failed
from aglm.
@Greenwind1 Please try #31
from aglm.
Related Issues (20)
- Small changes HOT 1
- predict.aglm should accept a cv.aglm object HOT 3
- Doesn't "add_linear_columns = FALSE" work? HOT 1
- newoffset for predict.glmnet HOT 1
- Change names? HOT 2
- predict.AccurateGLM with type = "coefficients" or "nonzero" HOT 1
- Line 97 in 2904927 HOT 1
- Keep fit.preval, etc. in cv.aglm() HOT 1
- Set license HOT 2
- logical features
- Formula input HOT 1
- Partial residuals HOT 3
- Defaults of type.measure HOT 1
- An additional option of plot.AccurateGLM HOT 4
- Another additional option of plot.AccurateGLM HOT 1
- L dummy option HOT 2
- install_github in case of not installing glmnet HOT 2
- Heavy vignettes
- Tests for more datasets
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aglm.