Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated the R-package by adding the warm-start and save_model features #273

Merged
merged 1 commit into from
Dec 8, 2018

Conversation

mlampros
Copy link
Collaborator

@mlampros mlampros commented Dec 6, 2018


I've added the warm-start and save_model features. I've tested it locally and I used the following test-cases,


#---------------
# RGF Regressor
#--------------

library(RGF)

set.seed(1)
x = matrix(runif(1000), nrow = 100, ncol = 10)

y = runif(100)

RGF_regr = RGF_Regressor$new(max_leaf = 50)

RGF_regr$fit(x, y)

pth = "/your_folder/model_rgf"

RGF_regr$save_model(filename = pth)

preds = RGF_regr$predict(x)

RGF_regr1 = RGF_Regressor$new(max_leaf = 150, init_model = pth)

RGF_regr1$fit(x, y)

preds1 = RGF_regr1$predict(x)               # there are differences between 'preds' and 'preds1' to observe


#--------------------------------------------------------------------------------------------------------------- ERROR CASE
# IF I GIVE :    RGF_Regressor$new(max_leaf = 50, init_model = pth)     THEN I RECEIVE THE FOLLOWING ERROR :
#-----------------------------------------------------------------------------------------------------------

# Error in py_call_impl(callable, dots$args, dots$keywords) : 
#   Exception: "train": 
#   algorithm=RGF
# train_x_fn=/tmp/rgf/2e3daf71-b125-4b77-a99a-fb74031c0f6e2.train.data.x
# train_y_fn=/tmp/rgf/2e3daf71-b125-4b77-a99a-fb74031c0f6e2.train.data.y
# Log:ON
# model_fn_prefix=/tmp/rgf/2e3daf71-b125-4b77-a99a-fb74031c0f6e2.model
# model_fn_for_warmstart=/home/lampros/Pictures/model_rgf
# --------------------
#   Thu Dec  6 20:26:49 2018: Reading training data ... 
# Thu Dec  6 20:26:49 2018: Start ... #train=100
# --------------------
#   Forest-level: 
#   loss=LS
# max_leaf_forest=50
# max_tree=25
# opt_interval=100
# test_interval=100
# num_tree_search=1
# memory_policy=Generous
# !Input error!: (Detected in AzRgforest::warmup_timer) 
# The model given for warm-start is already over the requested maximum size of the models: #leaf=50, #tree=14 

#-----------------------------------------------------------------------------------------------
# THE ERROR APPEARS BECAUSE THE NUMBER OF TREES SHOULD BE GREATER THAN THE INITIAL (WHICH IS 50)
#---------------------------------------------------------------------------------------------------------------


#---------------
# RGF Classifier
#---------------

library(RGF)

set.seed(1)
x = matrix(runif(1000), nrow = 100, ncol = 10)

y = sample(1:2, 100, replace = TRUE)

RGF_class = RGF_Classifier$new(max_leaf = 50)

RGF_class$fit(x, y)


pth = "/your_folder/model_rgf"

RGF_class$save_model(filename = pth)


preds = RGF_class$predict(x)

RGF_class1 = RGF_Classifier$new(max_leaf = 150, init_model = pth)

RGF_class1$fit(x, y)

preds1 = RGF_class1$predict(x)

table(preds, preds1)                  # there are differences between 'preds' and 'preds1' to observe

the tests can be added by @jameslamb as we've agreed in issue Nr. 269.
@fukatani , @StrikerRUS this pull request is ready for review.

@@ -1,3 +1,9 @@
## RGF 1.0.5.2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @mlampros very much!

One note: since 1.0.5.1 has never been released, maybe squash all changes into 1.0.6 version and release it later (after uploading rgf_python with warm-start functionality to PyPI)?

Copy link
Collaborator Author

@mlampros mlampros Dec 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I thought that the extended version (4-digits rather than 3-digits) has been used internally only for the rgf-team repository, so that we don't get an error on travis as we've discussed in an earlier pull request and we can keep track of changes over time. Once the new version of rgf_python is ready we can merge all these changes to 1.0.x (3-digit).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, cool! Agree with you.

Copy link
Member

@fukatani fukatani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@mlampros mlampros merged commit 7c8ce94 into master Dec 8, 2018
@StrikerRUS StrikerRUS deleted the R-package-warm_start branch December 10, 2018 10:04
@StrikerRUS StrikerRUS mentioned this pull request Jan 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants