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

[doc] Reference the R doc in sphinx document site. #11166

Draft
wants to merge 22 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/jvm_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ concurrency:
cancel-in-progress: true

env:
PR_COMMIT_SHA: ${{ github.event.pull_request.head.sha }}
BRANCH_NAME: >-
${{ github.event.pull_request.number && 'PR-' }}${{ github.event.pull_request.number || github.ref_name }}

Expand Down Expand Up @@ -122,7 +123,7 @@ jobs:
run: |
python3 ops/pipeline/manage-artifacts.py upload \
--s3-bucket xgboost-docs \
--prefix ${BRANCH_NAME}/${GITHUB_SHA} --make-public \
--prefix ${BRANCH_NAME}/${PR_COMMIT_SHA} --make-public \
jvm-packages/${{ env.BRANCH_NAME }}.tar.bz2

build-test-jvm-packages:
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/r_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on: [push, pull_request]

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
PR_COMMIT_SHA: ${{ github.event.pull_request.head.sha }}
BRANCH_NAME: >-
${{ github.event.pull_request.number && 'PR-' }}${{ github.event.pull_request.number || github.ref_name }}

permissions:
contents: read # to fetch code (actions/checkout)
Expand All @@ -12,6 +15,7 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true


jobs:
test-Rpkg:
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -101,3 +105,25 @@ jobs:
if: steps.changes.outputs.r_package == 'true'
run: |
python3 ops/script/test_r_package.py --r=/usr/bin/R --task=doc

build-r-docs:
name: Build docs for the R package
runs-on:
- runs-on=${{ github.run_id }}
- runner=linux-amd64-cpu
- tag=r-tests-build-docs
steps:
# Restart Docker daemon so that it recognizes the ephemeral disks
- run: sudo systemctl restart docker
- uses: actions/checkout@v4
with:
submodules: "true"
- name: Log into Docker registry (AWS ECR)
run: bash ops/pipeline/login-docker-registry.sh
- run: bash ops/pipeline/build-r-docs.sh
- name: Upload R doc
run: |
python3 ops/pipeline/manage-artifacts.py upload \
--s3-bucket xgboost-docs \
--prefix ${BRANCH_NAME}/${PR_COMMIT_SHA} --make-public \
r-docs-${{ env.BRANCH_NAME }}.tar.bz2
3 changes: 3 additions & 0 deletions R-package/.Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@
README.md
^doc$
^Meta$
^_pkgdown\.yml$
^docs$
^pkgdown$
1 change: 1 addition & 0 deletions R-package/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docs
16 changes: 5 additions & 11 deletions R-package/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
XGBoost R Package for Scalable GBM
==================================
XGBoost R Package
=================

[![CRAN Status Badge](http://www.r-pkg.org/badges/version/xgboost)](https://cran.r-project.org/web/packages/xgboost)
[![CRAN Downloads](http://cranlogs.r-pkg.org/badges/xgboost)](https://cran.rstudio.com/web/packages/xgboost/index.html)
[![Documentation Status](https://readthedocs.org/projects/xgboost/badge/?version=latest)](http://xgboost.readthedocs.org/en/latest/R-package/index.html)
[![Documentation Status](https://readthedocs.org/projects/xgboost/badge/?version=latest)](https://xgboost.readthedocs.org/en/latest/R-package/index.html)

Resources
---------
* [XGBoost R Package Online Documentation](http://xgboost.readthedocs.org/en/latest/R-package/index.html)
* [XGBoost R Package Online Documentation](https://xgboost.readthedocs.org/en/stable/R-package/index.html)
- Check this out for detailed documents, examples and tutorials.

Installation
Expand All @@ -19,13 +19,7 @@ We are [on CRAN](https://cran.r-project.org/web/packages/xgboost/index.html) now
install.packages('xgboost')
```

For more detailed installation instructions, please see [here](http://xgboost.readthedocs.org/en/latest/build.html#r-package-installation).

Examples
--------

* Please visit [walk through example](demo).
* See also the [example scripts](../demo/kaggle-higgs) for Kaggle Higgs Challenge, including [speedtest script](../demo/kaggle-higgs/speedtest.R) on this dataset and the one related to [Otto challenge](../demo/kaggle-otto), including a [RMarkdown documentation](../demo/kaggle-otto/understandingXGBoostModel.Rmd).
For more detailed installation instructions, please see [here](https://xgboost.readthedocs.io/en/stable/install.html).

Development
-----------
Expand Down
93 changes: 93 additions & 0 deletions R-package/pkgdown/_pkgdown.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
url: https://github.com/dmlc/xgboost

template:
bootstrap: 5
math-rendering: mathjax
Copy link
Contributor

Choose a reason for hiding this comment

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

@trivialfis What about the katex with the workaround that is mentioned in the issue you linked?
r-lib/pkgdown#2704 (comment)

Looks like it should solve the issue of symbols like sqrt showing random glitches.

Copy link
Member Author

Choose a reason for hiding this comment

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

Will test it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Let's not do that. Injecting npm dependencies with a fixed version is outside my comfort zone. I know nothing about web development and would like to avoid it in XGBoost.


reference:
Copy link
Contributor

Choose a reason for hiding this comment

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

Could the CI job be configured in such a way that it'd throw a warning if some function is exported but not listed in this file?

Copy link
Member Author

Choose a reason for hiding this comment

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

Pkgdown throws an error if there's a missing symbol.

- title: High Level Interface
desc: High level XGBoost interface
contents:
- "xgboost"
- "predict.xgboost"
- "print.xgboost"
- title: Datasets
desc: Test datasets bundled with the R package.
contents:
- "agaricus.train"
- "agaricus.test"
- title: Global Configuration
desc: Global configuration for the XGBoost library.
contents:
- "xgb.config"
- "xgb.set.config"
- "xgb.get.config"
- title: DMatrix
desc: Low-level data storage.
contents:
- "xgb.DMatrix"
- "xgb.DMatrix.hasinfo"
- "xgb.DMatrix.save"
- "dim.xgb.DMatrix"
- "dimnames.xgb.DMatrix"
- "print.xgb.DMatrix"
- "xgb.DataBatch"
- "xgb.DataIter"
- "xgb.get.DMatrix.data"
- "xgb.get.DMatrix.num.non.missing"
- "xgb.ExtMemDMatrix"
- "xgb.QuantileDMatrix.from_iterator"
- "xgb.get.DMatrix.qcut"
- "xgb.slice.DMatrix"
- title: Booster
desc: The model for XGBoost.
contents:
- "a-compatibility-note-for-saveRDS-save"
- "coef.xgb.Booster"
- "getinfo.xgb.Booster"
- "predict.xgb.Booster"
- "print.xgb.Booster"
- "xgb.load"
- "xgb.load.raw"
- "xgb.save"
- "xgb.save.raw"
- "xgb.copy.Booster"
- "xgb.slice.Booster"
- "xgb.get.num.boosted.rounds"
- "xgb.is.same.Booster"
- "xgb.importance"
- "xgb.attr"
- "xgb.create.features"
- "xgb.model.dt.tree"
- "xgb.model.parameters<-"
- "xgb.ggplot.deepness"
- "xgb.dump"
- "variable.names.xgb.Booster"
- "xgb.ggplot.importance"
- "xgb.plot.multi.trees"
- "xgb.plot.shap"
- "xgb.ggplot.shap.summary"
- "xgb.plot.tree"
- "xgb.gblinear.history"
- title: Training Callbacks
desc: Callback functions used for training.
contents:
- "xgb.Callback"
- "xgb.cb.cv.predict"
- "xgb.cb.early.stop"
- "xgb.cb.evaluation.log"
- "xgb.cb.gblinear.history"
- "xgb.cb.print.evaluation"
- "xgb.cb.reset.parameters"
- "xgb.cb.save.model"
- title: Low-level Training Functions
desc: Low-level Training Functions with DMatrix and Booster
contents:
- "xgb.params"
- "xgb.train"
- "xgb.cv"
- "print.xgb.cv.synchronous"
Copy link
Contributor

Choose a reason for hiding this comment

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

Also predict.xgb.Booster and print.xgb.Booster.

Copy link
Member Author

Choose a reason for hiding this comment

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

These are in the booster section. Is that correct?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes. Not sure where they'd fit better though.

Copy link
Member Author

Choose a reason for hiding this comment

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

Seems logical to put them in the booster section as they are booster s3 methods.

- title: Deprecation Settings
contents:
- "xgboost-deprecated"
- "xgboost-options"
1 change: 0 additions & 1 deletion R-package/tests/helper_scripts/install_deps.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ pkgs <- c(
"RhpcBLASctl",
## imports
"Matrix",
"methods",
"data.table",
"jsonlite"
)
Expand Down
15 changes: 9 additions & 6 deletions R-package/vignettes/xgboost_introduction.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ output:
toc_float: true
---

# Introduction
XGBoost for R introduction
==========================

## Introduction

**XGBoost** is an optimized distributed gradient boosting library designed to be highly **efficient**, **flexible** and **portable**. It implements machine learning algorithms under the [Gradient Boosting](https://en.wikipedia.org/wiki/Gradient_boosting) framework. XGBoost provides a parallel tree boosting (also known as GBDT, GBM) that solve many data science problems in a fast and accurate way. The same code runs on major distributed environment (Hadoop, SGE, MPI) and can solve problems beyond billions of examples.

Expand All @@ -22,7 +25,7 @@ For more details about XGBoost's features and usage, see the [online documentati

This short vignette outlines the basic usage of the R interface for XGBoost, assuming the reader has some familiarity with the underlying concepts behind statistical modeling with gradient-boosted decision trees.

# Building a predictive model
## Building a predictive model

At its core, XGBoost consists of a C++ library which offers bindings for different programming languages, including R. The R package for XGBoost provides an idiomatic interface similar to those of other statistical modeling packages using and x/y design, as well as a lower-level interface that interacts more directly with the underlying core library and which is similar to those of other language bindings like Python, plus various helpers to interact with its model objects such as by plotting their feature importances or converting them to other formats.

Expand Down Expand Up @@ -62,7 +65,7 @@ model_abserr <- xgboost(x, y, objective = "reg:absoluteerror", nthreads = 1, nro

_Note: the objective must match with the type of the "y" response variable - for example, classification objectives for discrete choices require "factor" types, while regression models for real-valued data require "numeric" types._

# Model parameters
## Model parameters

XGBoost models allow a large degree of control over how they are built. By their nature, gradient-boosted decision tree ensembles are able to capture very complex patterns between features in the data and a response variable, which also means they can suffer from overfitting if not controlled appropirately.

Expand Down Expand Up @@ -105,7 +108,7 @@ xgboost(
)
```

# Examining model objects
## Examining model objects

XGBoost model objects for the most part consist of a pointer to a C++ object where most of the information is held and which is interfaced through the utility functions and methods in the package, but also contains some R attributes that can be retrieved (and new ones added) through `attributes()`:

Expand All @@ -131,7 +134,7 @@ xgb.importance(model)
xgb.model.dt.tree(model)
```

# Other features
## Other features

XGBoost supports many additional features on top of its traditional gradient-boosting framework, including, among others:

Expand All @@ -143,7 +146,7 @@ XGBoost supports many additional features on top of its traditional gradient-boo

See the [online documentation](https://xgboost.readthedocs.io/en/stable/index.html) - particularly the [tutorials section](https://xgboost.readthedocs.io/en/stable/tutorials/index.html) - for a glimpse over further functionalities that XGBoost offers.

# The low-level interface
## The low-level interface

In addition to the `xgboost(x, y, ...)` function, XGBoost also provides a lower-level interface for creating model objects through the function `xgb.train()`, which resembles the same `xgb.train` functions in other language bindings of XGBoost.

Expand Down
1 change: 1 addition & 0 deletions doc/R-package/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*~
*.md
2 changes: 2 additions & 0 deletions doc/R-package/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ PKGROOT=../../R-package
xgboostfromJSON.md: $(PKGROOT)/vignettes/xgboostfromJSON.Rmd
xgboost_introduction.md: $(PKGROOT)/vignettes/xgboost_introduction.Rmd

all: xgboostfromJSON.md xgboost_introduction.md

# General Rules for build rmarkdowns, need knitr
%.md:
trivialfis marked this conversation as resolved.
Show resolved Hide resolved
Rscript -e \
Expand Down
19 changes: 16 additions & 3 deletions doc/R-package/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,32 @@ XGBoost R Package

You have found the XGBoost R Package!

.. toctree::
:maxdepth: 2
:titlesonly:

***********
Get Started
***********

* Checkout the :doc:`Installation Guide </install>` contains instructions to install xgboost, and :doc:`Tutorials </tutorials/index>` for examples on how to use XGBoost for various tasks.
* Read the `API documentation <https://cran.r-project.org/web/packages/xgboost/xgboost.pdf>`_.
* Read the latest `API documentation <../r_docs/R-package/docs/reference/index.html>`__ . This might refer to a newer version than the one on CRAN.
* Read the `CRAN documentation <https://cran.r-project.org/web/packages/xgboost/xgboost.pdf>`_.

*********
Vignettes
trivialfis marked this conversation as resolved.
Show resolved Hide resolved
*********

.. toctree::

xgboost_introduction
xgboostfromJSON

************
Other topics
************

.. toctree::
:maxdepth: 2
:titlesonly:

Handling of indexable elements <index_base>
Developer guide: parameters from core library <adding_parameters>
5 changes: 5 additions & 0 deletions doc/R-package/r_docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
:orphan:

=============
XGBoost R API
=============
Loading
Loading