_대문 | 방명록 | 최근글 | 홈피소개 | 주인놈
FrontPage › 일반화가법모형
set.seed(602957)
x <- rnorm(1000)
noise <- rnorm(1000, sd=1.5)
y <- 3*sin(2*x) + cos(0.75*x) - 1.5*(x^2 ) + noise
select <- runif(1000)
frame <- data.frame(y=y, x = x)
train <- frame[select > 0.1,]
test <-frame[select <= 0.1,]


library(mgcv)
glin.model <- gam(y~s(x), data=train)
summary(glin.model)
sx <- predict(glin.model, type="terms")
xframe <- cbind(train, sx=sx[,1])
ggplot(xframe, aes(x=x)) + geom_point(aes(y=y), alpha=0.4) + geom_line(aes(y=sx))


분류
library("mgcv")
model <- gam(이탈여부 ~ s(변수1) + s(변수2),family=binomial, data=training)
summary(model)
pred <- predict(model, test, type="response")
confusionMatrix(ifelse(pred < 0.5, "이탈", "잔존"), test$이탈여부)

댓글 남기기..
이름: : 오른쪽의 새로고침을 클릭해 주세요. 새로고침
EditText : Print : Mobile : FindPage : DeletePage : LikePages : Powered by MoniWiki : Last modified 2018-04-13 23:12:54

청년이여! 그대의 머리로 사색하고 그대의 손으로 탐구하고 그대의 발로 서라.