Commit d22de3c2 authored by Nikita Titov's avatar Nikita Titov Committed by Guolin Ke
Browse files

fixed imports (#1220)

parent 0a9725b2
...@@ -15,7 +15,7 @@ import scipy.sparse ...@@ -15,7 +15,7 @@ import scipy.sparse
from .compat import (DataFrame, Series, integer_types, json, from .compat import (DataFrame, Series, integer_types, json,
json_default_with_numpy, numeric_types, range_, json_default_with_numpy, numeric_types, range_,
string_type, LGBMDeprecationWarning) string_type)
from .libpath import find_lib_path from .libpath import find_lib_path
......
# coding: utf-8 # coding: utf-8
"""Find the path to lightgbm dynamic library files.""" """Find the path to lightgbm dynamic library files."""
import os import os
import sys
def find_lib_path(): def find_lib_path():
......
...@@ -4,19 +4,13 @@ ...@@ -4,19 +4,13 @@
from __future__ import absolute_import from __future__ import absolute_import
import numpy as np import numpy as np
import warnings
try:
import pandas as pd
_IS_PANDAS_INSTALLED = True
except ImportError:
_IS_PANDAS_INSTALLED = False
from .basic import Dataset, LightGBMError from .basic import Dataset, LightGBMError
from .compat import (SKLEARN_INSTALLED, _LGBMClassifierBase, from .compat import (SKLEARN_INSTALLED, _LGBMClassifierBase,
LGBMNotFittedError, _LGBMLabelEncoder, _LGBMModelBase, LGBMNotFittedError, _LGBMLabelEncoder, _LGBMModelBase,
_LGBMRegressorBase, _LGBMCheckXY, _LGBMCheckArray, _LGBMCheckConsistentLength, _LGBMRegressorBase, _LGBMCheckXY, _LGBMCheckArray, _LGBMCheckConsistentLength,
_LGBMCheckClassificationTargets, _LGBMComputeSampleWeight, _LGBMCheckClassificationTargets, _LGBMComputeSampleWeight,
argc_, range_, LGBMDeprecationWarning) argc_, range_, DataFrame)
from .engine import train from .engine import train
...@@ -414,7 +408,7 @@ class LGBMModel(_LGBMModelBase): ...@@ -414,7 +408,7 @@ class LGBMModel(_LGBMModelBase):
feval = None feval = None
params['metric'] = eval_metric params['metric'] = eval_metric
if not _IS_PANDAS_INSTALLED or not isinstance(X, pd.DataFrame): if not isinstance(X, DataFrame):
X, y = _LGBMCheckXY(X, y, accept_sparse=True, force_all_finite=False, ensure_min_samples=2) X, y = _LGBMCheckXY(X, y, accept_sparse=True, force_all_finite=False, ensure_min_samples=2)
_LGBMCheckConsistentLength(X, y, sample_weight) _LGBMCheckConsistentLength(X, y, sample_weight)
...@@ -504,7 +498,7 @@ class LGBMModel(_LGBMModelBase): ...@@ -504,7 +498,7 @@ class LGBMModel(_LGBMModelBase):
""" """
if self._n_features is None: if self._n_features is None:
raise LGBMNotFittedError("Estimator not fitted, call `fit` before exploiting the model.") raise LGBMNotFittedError("Estimator not fitted, call `fit` before exploiting the model.")
if not _IS_PANDAS_INSTALLED or not isinstance(X, pd.DataFrame): if not isinstance(X, DataFrame):
X = _LGBMCheckArray(X, accept_sparse=True, force_all_finite=False) X = _LGBMCheckArray(X, accept_sparse=True, force_all_finite=False)
n_features = X.shape[1] n_features = X.shape[1]
if self._n_features != n_features: if self._n_features != n_features:
...@@ -531,7 +525,7 @@ class LGBMModel(_LGBMModelBase): ...@@ -531,7 +525,7 @@ class LGBMModel(_LGBMModelBase):
""" """
if self._n_features is None: if self._n_features is None:
raise LGBMNotFittedError("Estimator not fitted, call `fit` before exploiting the model.") raise LGBMNotFittedError("Estimator not fitted, call `fit` before exploiting the model.")
if not _IS_PANDAS_INSTALLED or not isinstance(X, pd.DataFrame): if not isinstance(X, DataFrame):
X = _LGBMCheckArray(X, accept_sparse=True, force_all_finite=False) X = _LGBMCheckArray(X, accept_sparse=True, force_all_finite=False)
n_features = X.shape[1] n_features = X.shape[1]
if self._n_features != n_features: if self._n_features != n_features:
...@@ -708,7 +702,7 @@ class LGBMClassifier(LGBMModel, _LGBMClassifierBase): ...@@ -708,7 +702,7 @@ class LGBMClassifier(LGBMModel, _LGBMClassifierBase):
""" """
if self._n_features is None: if self._n_features is None:
raise LGBMNotFittedError("Estimator not fitted, call `fit` before exploiting the model.") raise LGBMNotFittedError("Estimator not fitted, call `fit` before exploiting the model.")
if not _IS_PANDAS_INSTALLED or not isinstance(X, pd.DataFrame): if not isinstance(X, DataFrame):
X = _LGBMCheckArray(X, accept_sparse=True, force_all_finite=False) X = _LGBMCheckArray(X, accept_sparse=True, force_all_finite=False)
n_features = X.shape[1] n_features = X.shape[1]
if self._n_features != n_features: if self._n_features != n_features:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment