{"id":23102805,"url":"https://github.com/dataxujing/gcforest_r","last_synced_at":"2026-03-10T04:33:40.443Z","repository":{"id":112305225,"uuid":"150224292","full_name":"DataXujing/gcForest_r","owner":"DataXujing","description":":art: :art: R package for gcForest  [ https://CRAN.R-project.org/package=gcForest ][ https://github.com/cran/gcForest ]","archived":false,"fork":false,"pushed_at":"2018-10-07T02:53:33.000Z","size":28,"stargazers_count":6,"open_issues_count":2,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-18T07:03:55.922Z","etag":null,"topics":["algorithm","r"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DataXujing.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-09-25T07:25:23.000Z","updated_at":"2019-03-15T07:01:31.000Z","dependencies_parsed_at":"2023-05-12T16:00:38.305Z","dependency_job_id":null,"html_url":"https://github.com/DataXujing/gcForest_r","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/DataXujing/gcForest_r","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DataXujing%2FgcForest_r","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DataXujing%2FgcForest_r/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DataXujing%2FgcForest_r/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DataXujing%2FgcForest_r/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DataXujing","download_url":"https://codeload.github.com/DataXujing/gcForest_r/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DataXujing%2FgcForest_r/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30324444,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-10T01:36:58.598Z","status":"online","status_checked_at":"2026-03-10T02:00:06.579Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithm","r"],"created_at":"2024-12-17T00:00:29.913Z","updated_at":"2026-03-10T04:33:40.413Z","avatar_url":"https://github.com/DataXujing.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":" # gcForest  \u003ca href=\"https://github.com/DataXujing/gcForest_r/\"\u003e\u003cimg src=\"vignettes/logo.png\" align=\"right\" alt=\"logo\" height=\"120\" width=\"240\" /\u003e\u003c/a\u003e\n\nXu Jing\n\n## 1.Introduction\n\nThe gcForest algorithm was suggested in Zhou and Feng 2017 (\u003chttps://arxiv.org/abs/1702.08835\u003e , refer for this paper for technical details) and pylablanche(\u003chttps://github.com/pylablanche\u003e) who provide a Python3.X implementation of this algorithm on github (\u003chttps://github.com/pylablanche/gcForest\u003e). We provide a R package called gcForest which is the R interface of the  pylablanche's gcForest module (Python3.X). And if you want to known more about gcForest, please read the source paper (Deep Forest).\n\n## 2.Prerequisites\n\nAs mentioned in the previous paragraph, we provide a R interface of the Python3.X module gcForest(by pylablanche), If you want to use this R packages like the R's tensorflow and keras you should hava a Python3.X environment first, and then, you will need to have the following installed on your computer to make it work:\n\n+ Python 3.X\n+ Numpy \u003e= 1.12.0\n+ Scikit-learn \u003e= 0.18.1\n\nafter these, you can install this R package like:\n\n+ `install.packages('gcForest')`\n\n+ `devtools::install_github('DataXujing/gcForest_r')`\n\nrun `library(gcForest)` in your R Console no mistakes.\n\n\n## 3.Using gcForest\n\nSupported APIs:\n\n+ `fit(X,y)` Training the gcForest on input data X and associated target y;\n+ `predict(X)` Predict the class of unknown samples X;\n+ `predict_proba(X)` Predict the class probabilities of unknown samples X;\n+ `mg_scanning(X, y=None)` Performs a Multi Grain Scanning on input data;\n+ `window_slicing_pred_prob(X, window, shape_1X, y=None)` Performs a window slicing of the input data and send them through Random Forests. If target values 'y' are provided sliced data are then used to train the Random Forests;\n+ `cascade_forest(X, y=None)` Perform (or train if 'y' is not None) a cascade forest estimator;\n+ `gcdata(x)` Tansform R data structure to Python data structure;\n+ `model_save(model,path)` To save trained model in disk;\n+ `model_load(path)` To load trained model from disk to R environment;\n\nExample1: iris data set\n\n```r\n\nlibrary(gcForest)\n\nsk \u003c- reticulate::import('sklearn')\ntrain_test_split \u003c- sk$model_selection$train_test_split\n\ndata \u003c- sk$datasets$load_iris\niris \u003c- data()\nX = iris$data\ny = iris$target\ndata_split = train_test_split(X, y, test_size=0.33)\n\nX_tr \u003c- data_split[[1]]\nX_te \u003c- data_split[[2]]\ny_tr \u003c- data_split[[3]]\ny_te \u003c- data_split[[4]]\n\ngcforest_m \u003c- gcforest(shape_1X=4L, window=2L, tolerance=0.0)\ngcforest_m$fit(X_tr,y_tr)\ngcf_model \u003c- model_save(gcforest_m,'../gcforest_model.model')\n\ngcf \u003c- model_load('../gcforest_model.model')\ngcf$fit(X_tr, y_tr)\n\n```\n\nExample2: Digits data set\n\n```r\n\nlibrary(gcForest)\n\nsk \u003c- sk \u003c- reticulate::import('sklearn')\ntrain_test_split \u003c- sk$model_selection$train_test_split\n\ndata \u003c- sk$datasets$load_digits\ndigits \u003c- data()\nX = digits$data\ny = digits$target\ndata_split = train_test_split(X, y, test_size=0.4)\n\ngcforest_m \u003c- gcforest(shape_1X=c(8L,8L), window=c(4L,6L), tolerance=0.0, min_samples_mgs=10L, min_samples_cascade=7L)\ngcforest_m$fit(X_tr,y_tr)\ngcf_model \u003c- model_save(gcforest_m,'../gcforest_model.model')\n\ngcf \u003c- model_load('../gcforest_model.model')\ngcf$fit(X_tr, y_tr)\n```\n\nExample3: Using mg-scanning and cascade_forest Sperately\n\n```r\n# mg-scanning\ngcforest_m \u003c- gcForest(shape_1X=c(8L,8L), window=5L, min_samples_mgs=10L, min_samples_cascade=7L)\nX_tr_mgs \u003c- gcforest_m$mg_scanning(X_tr, y_tr)\n\nX_te_mgs \u003c- gcforest_m$mg_scanning(X_te)\n\n# cascade_forest\ngcforest_m \u003c- gcForest(tolerance=0.0, min_samples_mgs=10L, min_samples_cascade=7L)\ncf \u003c- gcforest_m$cascade_forest(X_tr_mgs, y_tr)\n\npred_proba \u003c- gcforest_m$cascade_forest(X_te_mgs)\npred_proba \u003c- reticulate::py_to_r(pred_proba)\n\n# then do mean and max\n```\n\nExample4: Skipping mg_scanning\n\n```r\ngcforest_m \u003c- gcForest(tolerance=0.0, min_samples_cascade=20L)\ncf \u003c- gcforest_m$cascade_forest(X_tr, y_tr)\npred_proba \u003c- gcforest_m$cascade_forest(X_te)\npred_proba \u003c- reticulate::py_to_r(pred_proba)\n\n# then do mean and max\n\n```\n\n## 4.Notes\n\nThanks for the paper of Deep Forest( Zhou and Feng 2017 (\u003chttps://arxiv.org/abs/1702.08835\u003e)) and the author of the [gcForest Python3.X moulde](https://github.com/pylablanche/gcForest) (pylablanche \u003chttps://github.com/pylablanche\u003e). And We constantly improve gcForest R package, and even consider putting official modules which provide by  [LAMDA(Learning And Mining from DatA)](http://lamda.nju.edu.cn/code_gcForest.ashx?AspxAutoDetectCookieSupport=1)in gcForest R package.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdataxujing%2Fgcforest_r","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdataxujing%2Fgcforest_r","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdataxujing%2Fgcforest_r/lists"}