Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
algoli
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
rglow
algoli
Commits
ab60a0a1
Commit
ab60a0a1
authored
4 years ago
by
Jean-Marie Lepioufle
Browse files
Options
Downloads
Patches
Plain Diff
add predict
parent
8ff8f722
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
NAMESPACE
+1
-0
1 addition, 0 deletions
NAMESPACE
R/fit.R
+2
-1
2 additions, 1 deletion
R/fit.R
R/predict.R
+58
-0
58 additions, 0 deletions
R/predict.R
man/do_predict.Rd
+31
-0
31 additions, 0 deletions
man/do_predict.Rd
with
92 additions
and
1 deletion
NAMESPACE
+
1
−
0
View file @
ab60a0a1
...
...
@@ -4,3 +4,4 @@ S3method(print,algdoor)
export(algdoor)
export(dir_tmp_model)
export(do_fit)
export(do_predict)
This diff is collapsed.
Click to expand it.
R/fit.R
+
2
−
1
View file @
ab60a0a1
...
...
@@ -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
,
...
...
This diff is collapsed.
Click to expand it.
R/predict.R
0 → 100644
+
58
−
0
View file @
ab60a0a1
#' 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
)
}
This diff is collapsed.
Click to expand it.
man/do_predict.Rd
0 → 100644
+
31
−
0
View file @
ab60a0a1
% 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}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment