Skip to content
Snippets Groups Projects
Commit ab60a0a1 authored by Jean-Marie Lepioufle's avatar Jean-Marie Lepioufle
Browse files

add predict

parent 8ff8f722
No related branches found
No related tags found
No related merge requests found
......@@ -4,3 +4,4 @@ S3method(print,algdoor)
export(algdoor)
export(dir_tmp_model)
export(do_fit)
export(do_predict)
......@@ -65,7 +65,8 @@ do_fit <- function(service,algorithm=NULL,...,dataset,col_bind=NULL,target,predi
cat(c(as.character(Sys.time()),"predict\n"), file=fileCheck,append=TRUE)
res_pred <- hello$predict(res_fit)
res <- list(alg = algorithm,
res <- list(service = service,
alg = algorithm,
args = list(...),
target = target,
predictors = predictors,
......
#' do_predict
#' do_predict
#' @param service service
#' @param model_path path to a model
#' @param model_id id of an internal model
#' @param dataset tibble or data.frame
#' @param col_bind col_bind in character
#' @keywords algoli
#' @export
#' @examples
#' \dontrun{
#' do_predict()
#' }
do_predict <- function(service,model_path=NULL,model_id=NULL,dataset=NULL,col_bind){
fileCheck_path <- file.path(getwd(),"algoli")
fileCheck_path <- normalizePath(fileCheck_path,mustWork = FALSE)
dir.create(fileCheck_path, showWarnings = TRUE, recursive = TRUE)
fileCheck <- file.path(fileCheck_path,"predict-check.log")
file.create(fileCheck)
# new algoli
hello <- algoli::algdoor(service = service)
# Connecting to session ...
cat(c(as.character(Sys.time()),"connecting\n"), file=fileCheck,append=TRUE)
hello$connect()
# Incoporating dataset into session ...
cat(c(as.character(Sys.time()),"copying dataset\n"), file=fileCheck,append=TRUE)
hello$dataset(dataset=dataset,col_bind= col_bind, train=0L,test=100L)
# Loading the model ...
cat(c(as.character(Sys.time()),"loading model\n"), file=fileCheck,append=TRUE)
if (!is.null(model_path)) {
res_fit <- hello$load_model(model_path)
} else if (!is.null(model_id)){
tmp <- dir_tmp_model(id=model_id)
model_path <- file.path(tmp$model_path,"model.mod")
res_fit <- hello$load_model(model_path)
} else stop("Either model_path or model_id must non-null")
# Prediction on the dataset ...
cat(c(as.character(Sys.time()),"predict\n"), file=fileCheck,append=TRUE)
res_pred <- hello$predict(res_fit)
res <- list(pred = res_pred,
id = model_id,
path = model_path)
# disconnect ...
cat(c(as.character(Sys.time()),"disconnect\n"), file=fileCheck,append=TRUE)
hello$disconnect()
return(res)
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/predict.R
\name{do_predict}
\alias{do_predict}
\title{do_predict
do_predict}
\usage{
do_predict(service, model_path = NULL, model_id = NULL,
dataset = NULL, col_bind)
}
\arguments{
\item{service}{service}
\item{model_path}{path to a model}
\item{model_id}{id of an internal model}
\item{dataset}{tibble or data.frame}
\item{col_bind}{col_bind in character}
}
\description{
do_predict
do_predict
}
\examples{
\dontrun{
do_predict()
}
}
\keyword{algoli}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment