Skip to content

Commit

Permalink
[python] update DataTable handling (#2020)
Browse files Browse the repository at this point in the history
  • Loading branch information
StrikerRUS committed Feb 21, 2019
1 parent 414bb60 commit c5cfe3e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion docs/Python-Intro.rst
Expand Up @@ -36,7 +36,7 @@ The LightGBM Python module can load data from:

- libsvm/tsv/csv/txt format file

- NumPy 2D array(s), pandas DataFrame, H2O DataTable, SciPy sparse matrix
- NumPy 2D array(s), pandas DataFrame, H2O DataTable's Frame, SciPy sparse matrix

- LightGBM binary file

Expand Down
12 changes: 6 additions & 6 deletions python-package/lightgbm/basic.py
Expand Up @@ -409,7 +409,7 @@ def predict(self, data, num_iteration=-1,
Parameters
----------
data : string, numpy array, pandas DataFrame, H2O DataTable or scipy.sparse
data : string, numpy array, pandas DataFrame, H2O DataTable's Frame or scipy.sparse
Data source for prediction.
When data type is string, it represents the path of txt file.
num_iteration : int, optional (default=-1)
Expand Down Expand Up @@ -652,7 +652,7 @@ def __init__(self, data, label=None, reference=None,
Parameters
----------
data : string, numpy array, pandas DataFrame, H2O DataTable, scipy.sparse or list of numpy arrays
data : string, numpy array, pandas DataFrame, H2O DataTable's Frame, scipy.sparse or list of numpy arrays
Data source of Dataset.
If string, it represents the path to txt file.
label : list, numpy 1-D array, pandas Series / one-column DataFrame or None, optional (default=None)
Expand Down Expand Up @@ -1009,7 +1009,7 @@ def create_valid(self, data, label=None, weight=None, group=None,
Parameters
----------
data : string, numpy array, pandas DataFrame, H2O DataTable, scipy.sparse or list of numpy arrays
data : string, numpy array, pandas DataFrame, H2O DataTable's Frame, scipy.sparse or list of numpy arrays
Data source of Dataset.
If string, it represents the path to txt file.
label : list, numpy 1-D array, pandas Series / one-column DataFrame or None, optional (default=None)
Expand Down Expand Up @@ -1399,7 +1399,7 @@ def get_data(self):
Returns
-------
data : string, numpy array, pandas DataFrame, H2O DataTable, scipy.sparse, list of numpy arrays or None
data : string, numpy array, pandas DataFrame, H2O DataTable's Frame, scipy.sparse, list of numpy arrays or None
Raw data used in the Dataset construction.
"""
if self.handle is None:
Expand Down Expand Up @@ -2162,7 +2162,7 @@ def predict(self, data, num_iteration=None,
Parameters
----------
data : string, numpy array, pandas DataFrame, H2O DataTable or scipy.sparse
data : string, numpy array, pandas DataFrame, H2O DataTable's Frame or scipy.sparse
Data source for prediction.
If string, it represents the path to txt file.
num_iteration : int or None, optional (default=None)
Expand Down Expand Up @@ -2207,7 +2207,7 @@ def refit(self, data, label, decay_rate=0.9, **kwargs):
Parameters
----------
data : string, numpy array, pandas DataFrame, H2O DataTable or scipy.sparse
data : string, numpy array, pandas DataFrame, H2O DataTable's Frame or scipy.sparse
Data source for refit.
If string, it represents the path to txt file.
label : list, numpy 1-D array or pandas Series / one-column DataFrame
Expand Down
6 changes: 5 additions & 1 deletion python-package/lightgbm/compat.py
Expand Up @@ -92,7 +92,11 @@ class DataFrame(object):

"""datatable"""
try:
from datatable import DataTable
import datatable
if hasattr(datatable, "Frame"):
DataTable = datatable.Frame
else:
DataTable = datatable.DataTable
DATATABLE_INSTALLED = True
except ImportError:
DATATABLE_INSTALLED = False
Expand Down

0 comments on commit c5cfe3e

Please sign in to comment.