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
2c4c49f6
Commit
2c4c49f6
authored
4 years ago
by
Jean-Marie Lepioufle
Browse files
Options
Downloads
Patches
Plain Diff
improve file_path and id
parent
ffb3c390
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
DESCRIPTION
+3
-1
3 additions, 1 deletion
DESCRIPTION
R/fit.R
+10
-20
10 additions, 20 deletions
R/fit.R
R/predict.R
+4
-2
4 additions, 2 deletions
R/predict.R
man/do_fit.Rd
+1
-3
1 addition, 3 deletions
man/do_fit.Rd
with
18 additions
and
26 deletions
DESCRIPTION
+
3
−
1
View file @
2c4c49f6
Package: algoli
Type: Package
Version: 0.0.
2
Version: 0.0.
3
Authors@R: c(person("Jean-Marie", "Lepioufle", , "jml@nilu.no", role=c("aut","cre")),
person("NILU",role="cph"))
Title: algoli
...
...
@@ -9,6 +9,8 @@ Description: Make the use of algorithms for fitting/prediction easy.
One simple syntax for every libraries.
Depends:
R (>= 3.4.1)
Imports:
stringi
Suggests:
knitr
License: MIT + file LICENSE
...
...
This diff is collapsed.
Click to expand it.
R/fit.R
+
10
−
20
View file @
2c4c49f6
...
...
@@ -10,19 +10,20 @@
#' @param predictors predictors in character
#' @param train train percentage
#' @param test test percentage
#' @param MODEL_DIR boolean save model in a specific recoverable folder, temporary solution
#' @keywords algoli
#' @export
#' @examples
#' \dontrun{
#' do_fit()
#' }
do_fit
<-
function
(
service
,
algorithm
=
NULL
,
...
,
dataset
,
col_bind
=
NULL
,
target
,
predictors
,
train
=
0.8
,
test
=
0.2
,
MODEL_DIR
=
FALSE
){
do_fit
<-
function
(
service
,
algorithm
=
NULL
,
...
,
dataset
,
col_bind
=
NULL
,
target
,
predictors
,
train
=
0.8
,
test
=
0.2
){
fileCheck_path
<-
file.path
(
getwd
(),
"algoli"
)
id
<-
stringi
::
stri_rand_strings
(
1
,
16
,
'[a-z0-9]'
)
fileCheck_path
<-
normalizePath
(
file.path
(
tempdir
(),
"algoli"
),
mustWork
=
FALSE
)
fileCheck_path
<-
normalizePath
(
fileCheck_path
,
mustWork
=
FALSE
)
dir.create
(
fileCheck_path
,
showWarnings
=
TRUE
,
recursive
=
TRUE
)
fileCheck
<-
file.path
(
fileCheck_path
,
"
fit-check.log
"
)
fileCheck
<-
file.path
(
fileCheck_path
,
paste0
(
'
fit-check
_'
,
id
,
'_
.log
'
)
)
file.create
(
fileCheck
)
target
<-
gsub
(
"\\."
,
"_"
,
target
)
...
...
@@ -45,21 +46,9 @@ do_fit <- function(service,algorithm=NULL,...,dataset,col_bind=NULL,target,predi
# exporting model ...
cat
(
c
(
as.character
(
Sys.time
()),
"export model\n"
),
file
=
fileCheck
,
append
=
TRUE
)
tmp_model_path
<-
normalizePath
(
file.path
(
tempdir
(),
"
model"
),
mustWork
=
FALSE
)
tmp_model_path
<-
normalizePath
(
file.path
(
tempdir
(),
"
algoli"
,
id
),
mustWork
=
FALSE
)
dir.create
(
tmp_model_path
,
showWarnings
=
TRUE
,
recursive
=
TRUE
)
from
<-
hello
$
export_model
(
res_fit
,
tmp_model_path
)
if
(
!
MODEL_DIR
)
{
tmp
<-
list
(
id
=
NULL
,
model_path
=
from
)
}
else
if
(
MODEL_DIR
)
{
# for an internal access to the binary, temporary solution
tmp
<-
dir_tmp_model
()
if
(
!
is.null
(
tmp
$
model_path
)){
to
<-
file.path
(
tmp
$
model_path
,
"model.mod"
)
file.copy
(
from
=
from
,
to
=
to
)
}
else
tmp
<-
list
(
id
=
NULL
,
model_path
=
NULL
)
}
else
tmp
<-
list
(
id
=
NULL
,
model_path
=
NULL
)
model_path
<-
hello
$
export_model
(
res_fit
,
tmp_model_path
)
# Prediction on the test dataset ...
cat
(
c
(
as.character
(
Sys.time
()),
"predict\n"
),
file
=
fileCheck
,
append
=
TRUE
)
...
...
@@ -70,9 +59,10 @@ do_fit <- function(service,algorithm=NULL,...,dataset,col_bind=NULL,target,predi
args
=
list
(
...
),
target
=
target
,
predictors
=
predictors
,
col_bind
=
col_bind
,
pred
=
res_pred
,
id
=
tmp
$
id
,
path
=
tmp
$
model_path
)
id
=
id
,
path
=
model_path
)
# disconnect ...
cat
(
c
(
as.character
(
Sys.time
()),
"disconnect\n"
),
file
=
fileCheck
,
append
=
TRUE
)
...
...
This diff is collapsed.
Click to expand it.
R/predict.R
+
4
−
2
View file @
2c4c49f6
...
...
@@ -14,10 +14,12 @@
#' }
do_predict
<-
function
(
service
,
model_path
=
NULL
,
model_id
=
NULL
,
dataset
=
NULL
,
col_bind
=
NULL
){
fileCheck_path
<-
file.path
(
getwd
(),
"algoli"
)
id
<-
stringi
::
stri_rand_strings
(
1
,
16
,
'[a-z0-9]'
)
fileCheck_path
<-
normalizePath
(
file.path
(
tempdir
(),
"algoli"
),
mustWork
=
FALSE
)
fileCheck_path
<-
normalizePath
(
fileCheck_path
,
mustWork
=
FALSE
)
dir.create
(
fileCheck_path
,
showWarnings
=
TRUE
,
recursive
=
TRUE
)
fileCheck
<-
file.path
(
fileCheck_path
,
"
predict-check.log
"
)
fileCheck
<-
file.path
(
fileCheck_path
,
paste0
(
'
predict-check
_'
,
id
,
'_
.log
'
)
)
file.create
(
fileCheck
)
# new algoli
...
...
This diff is collapsed.
Click to expand it.
man/do_fit.Rd
+
1
−
3
View file @
2c4c49f6
...
...
@@ -6,7 +6,7 @@
do_fit}
\usage{
do_fit(service, algorithm = NULL, ..., dataset, col_bind = NULL,
target, predictors, train = 0.8, test = 0.2
, MODEL_DIR = FALSE
)
target, predictors, train = 0.8, test = 0.2)
}
\arguments{
\item{service}{service}
...
...
@@ -26,8 +26,6 @@ do_fit(service, algorithm = NULL, ..., dataset, col_bind = NULL,
\item{train}{train percentage}
\item{test}{test percentage}
\item{MODEL_DIR}{boolean save model in a specific recoverable folder, temporary solution}
}
\description{
do_fit
...
...
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