모델 저장하기 in R

이경주 Junior data analyst·2023년 10월 30일

R

목록 보기
2/2

1. 개요(How to save a R model)

https://www.projectpro.io/recipes/save-r-model

  • python에서 모델을 저장하는 기능을 보고 R에도 있지 않을까? 해서 찾은 결과

Step 1. 라이브러리 불러오기

# install.packages("rpart.plot") 
library(rpart.plot)

# install.pacakges("rpart")
library(rpart)

Step 2. 모델 저장하기

## 모델 경로는 한글이 섞이지 않은 영어로!

# saving the model
saveRDS(model, file = "경로/model.rda")

# loading the model
model_old = readRDS(file = "경로/model.rda")

model <- model_old

데이터의 크기(nrow)가 크거나, 모델이 복잡하여 학습하는데 오래 걸리거나, 조건이 많아 최적의 모델을 찾기까지 오래걸린다면 위의 방법을 써서 시간을 절약 할 수 있을 것이당.

profile
Good afternoon, Good evening and Good night

1개의 댓글

comment-user-thumbnail
2023년 12월 22일

팬입니다 항상 응원해요!

답글 달기