Skip to content
Merged
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
63 changes: 63 additions & 0 deletions docs/source/fil_migration.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
###############
Migration guide
###############

Basic workflow
==============

.. testsetup:: workflow

import numpy as np
from sklearn.ensemble import RandomForestClassifier

X = np.array([[1, 2], [-1, 2]], dtype="float32")
y = np.array([0, 1], dtype="int32")

skl_model = RandomForestClassifier(n_estimators=1, max_depth=1)
skl_model.fit(X, y)

Call :py:meth:`~nvforest.load_model`, :py:meth:`~nvforest.load_from_sklearn`,
or :py:meth:`~nvforest.load_from_treelite_model`. Note that it is no longer
necessary to specify the ``is_classifier`` parameter.

.. code-block:: python

# BEFORE
import cuml
fil_model = cuml.fil.ForestInference.load_from_sklearn(skl_model, is_classifier=True)
fil_model.optimize(batch_size=1024)
predictions = fil_model.predict(X)
probabilities = fil_model.predict_proba(X)
per_tree_pred = fil_model.predict_per_tree(X)
lead_ids = fil_model.apply(X)

.. testcode:: workflow

# AFTER
import nvforest
nvforest_model = nvforest.load_from_sklearn(skl_model)
nvforest_model = nvforest_model.optimize(batch_size=1024)
predictions = nvforest_model.predict(X)
probabilities = nvforest_model.predict_proba(X)
per_tree_pred = nvforest_model.predict_per_tree(X)
lead_ids = nvforest_model.apply(X)

Device selection
================
Specify the ``device`` parameter when calling :py:meth:`~nvforest.load_model`.

.. code-block:: python

# BEFORE
with cuml.fil.set_fil_device_type("cpu"):
fil_model = cuml.fil.ForestInference.load_from_sklearn(skl_model)

.. testcode:: workflow

# AFTER
nvforest_model = nvforest.load_from_sklearn(skl_model, device="cpu")

nvForest also differs from FIL when it comes to the behavior when no device is explicitly
specified. The ``device`` parameter defaults to ``"auto"``. nvForest will attempt to
load the tree model onto a GPU device, if one is available. If no GPU is available,
nvForest will fall back to the CPU.
17 changes: 17 additions & 0 deletions docs/source/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@
Getting started with nvForest
#############################

Installation
============
You can install nvForest using Pip or Conda.

.. code-block:: console

# Using Pip: need a suffix corresponding to your CUDA version, e.g. for CUDA 13:
$ pip install nvforest-cu13

.. code-block:: console

# Using Conda: need to specify the rapidsai channel
$ conda install -c rapidsai -c conda-forge nvforest

You can also install nvForest as part of RAPIDS, a collection of libraries for GPU accelerated data science.
Visit https://docs.rapids.ai/install/ for more information.

nvForest with Python
====================

Expand Down
2 changes: 2 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ It supports many kinds of decision tree models, including XGBoost, LightGBM, sci
* :doc:`python_api`: Python API documentation
* :doc:`cpp_api`: C++ API documentation
* :doc:`build`: How to build nvForest from the source
* :doc:`fil_migration`: How to migrate existing code using Forest Inference Library (FIL)

.. toctree::
:maxdepth: 2
Expand All @@ -17,3 +18,4 @@ It supports many kinds of decision tree models, including XGBoost, LightGBM, sci
python_api
cpp_api
build
fil_migration
Loading