Skip to content

Remove absolute imports #13629

@NicolasHug

Description

@NicolasHug

In a lot of files, we're still using absolute imports for scikit-learn tools. These should be relative import instead.

~/dev/sklearn(branch:master*) » git grep "from sklearn" sklearn | grep -v test | grep -v ">>>" 

sklearn/base.py:from sklearn.utils import _IS_32BIT
sklearn/calibration.py:from sklearn.preprocessing import LabelEncoder
sklearn/cluster/_hierarchical.pyx:from sklearn.utils.fast_dict cimport IntFloatDict
sklearn/cluster/_k_means.pyx:from sklearn.utils.sparsefuncs_fast import assign_rows_csr
sklearn/cluster/affinity_propagation_.py:from sklearn.exceptions import ConvergenceWarning
sklearn/datasets/openml.py:from sklearn.externals import _arff
sklearn/datasets/species_distributions.py:from sklearn.datasets.base import _pkl_filepath
sklearn/datasets/species_distributions.py:from sklearn.utils import _joblib
sklearn/datasets/svmlight_format.py:        from sklearn.datasets import load_svmlight_file
sklearn/ensemble/_gradient_boosting.pyx:from sklearn.tree._tree cimport Node
sklearn/ensemble/_gradient_boosting.pyx:from sklearn.tree._tree cimport Tree
sklearn/ensemble/_gradient_boosting.pyx:from sklearn.tree._tree cimport DTYPE_t
sklearn/ensemble/_gradient_boosting.pyx:from sklearn.tree._tree cimport SIZE_t
sklearn/ensemble/_gradient_boosting.pyx:from sklearn.tree._tree cimport INT32_t
sklearn/ensemble/_gradient_boosting.pyx:from sklearn.tree._utils cimport safe_realloc
sklearn/exceptions.py:       Moved from sklearn.utils.validation.
sklearn/exceptions.py:       Moved from sklearn.base.
sklearn/exceptions.py:       Moved from sklearn.utils.
sklearn/exceptions.py:       Moved from sklearn.utils.validation.
sklearn/exceptions.py:       Moved from sklearn.utils.
sklearn/exceptions.py:       Moved from sklearn.cross_validation.
sklearn/exceptions.py:       Moved from sklearn.utils.validation, extends EfficiencyWarning.
sklearn/exceptions.py:       Moved from sklearn.base.
sklearn/externals/copy_joblib.sh:find joblib -name "*.py" | xargs sed -i.bak "s/from joblib/from sklearn.externals.joblib/"
sklearn/externals/joblib/externals/loky/backend/popen_loky_win32.py:            prog = 'from sklearn.externals.joblib.externals.loky.backend.popen_loky_win32 import main; main()'
sklearn/externals/joblib/externals/loky/backend/reduction.py:    from sklearn.externals.joblib.externals import cloudpickle  # noqa: F401
sklearn/externals/joblib/externals/loky/backend/reduction.py:        from sklearn.externals.joblib.externals.cloudpickle import CloudPickler as loky_pickler_cls
sklearn/externals/joblib/externals/loky/backend/spawn.py:from sklearn.externals.joblib.externals.loky.backend import context
sklearn/externals/joblib/externals/loky/cloudpickle_wrapper.py:    from sklearn.externals.joblib.externals.cloudpickle import dumps, loads
sklearn/externals/joblib/externals/loky/cloudpickle_wrapper.py:        raise ImportError("could not from sklearn.externals.joblib.externals import cloudpickle. Please install "
sklearn/feature_extraction/_hashing.pyx:from sklearn.utils.murmurhash cimport murmurhash3_bytes_s32
sklearn/feature_extraction/_hashing.pyx:from sklearn.utils.fixes import sp_version
sklearn/gaussian_process/gpc.py:from sklearn.base import BaseEstimator, ClassifierMixin, clone
sklearn/gaussian_process/gpc.py:from sklearn.gaussian_process.kernels \
sklearn/gaussian_process/gpc.py:from sklearn.utils.validation import check_X_y, check_is_fitted, check_array
sklearn/gaussian_process/gpc.py:from sklearn.utils import check_random_state
sklearn/gaussian_process/gpc.py:from sklearn.preprocessing import LabelEncoder
sklearn/gaussian_process/gpc.py:from sklearn.multiclass import OneVsRestClassifier, OneVsOneClassifier
sklearn/gaussian_process/gpc.py:from sklearn.exceptions import ConvergenceWarning
sklearn/gaussian_process/gpr.py:from sklearn.base import BaseEstimator, RegressorMixin, clone
sklearn/gaussian_process/gpr.py:from sklearn.base import MultiOutputMixin
sklearn/gaussian_process/gpr.py:from sklearn.gaussian_process.kernels import RBF, ConstantKernel as C
sklearn/gaussian_process/gpr.py:from sklearn.utils import check_random_state
sklearn/gaussian_process/gpr.py:from sklearn.utils.validation import check_X_y, check_array
sklearn/gaussian_process/gpr.py:from sklearn.exceptions import ConvergenceWarning
sklearn/linear_model/cd_fast.pyx:from sklearn.utils cimport _random 
sklearn/linear_model/logistic.py:        preprocess the data with a scaler from sklearn.preprocessing.
sklearn/linear_model/logistic.py:        with a scaler from sklearn.preprocessing.
sklearn/linear_model/ridge.py:          scaler from sklearn.preprocessing.
sklearn/linear_model/ridge.py:          scaler from sklearn.preprocessing.
sklearn/linear_model/ridge.py:          scaler from sklearn.preprocessing.
sklearn/linear_model/sgd_fast.pyx:from sklearn.utils.weight_vector cimport WeightVector
sklearn/linear_model/sgd_fast.pyx:from sklearn.utils.seq_dataset cimport SequentialDataset64 as SequentialDataset
sklearn/manifold/_barnes_hut_tsne.pyx:from sklearn.neighbors.quad_tree cimport _QuadTree
sklearn/metrics/cluster/bicluster.py:from sklearn.utils.linear_assignment_ import linear_assignment
sklearn/metrics/cluster/bicluster.py:from sklearn.utils.validation import check_consistent_length, check_array
sklearn/metrics/cluster/expected_mutual_info_fast.pyx:from sklearn.utils.lgamma cimport lgamma
sklearn/metrics/cluster/unsupervised.py:from sklearn.utils import deprecated
sklearn/model_selection/_split.py:                             "object (from sklearn.model_selection) "
sklearn/neighbors/binary_tree.pxi:from sklearn.utils.lgamma cimport lgamma
sklearn/neighbors/quad_tree.pyx:from sklearn.tree._utils cimport safe_realloc, sizet_ptr_to_ndarray
sklearn/setup.py:from sklearn._build_utils import maybe_cythonize_extensions
sklearn/tree/_utils.pxd:from sklearn.neighbors.quad_tree cimport Cell
sklearn/tree/_utils.pyx:from sklearn.utils cimport _random
sklearn/utils/_random.pyx:from sklearn.utils import check_random_state
sklearn/utils/estimator_checks.py:from sklearn.utils import IS_PYPY
sklearn/utils/estimator_checks.py:from sklearn.utils import _joblib
sklearn/utils/estimator_checks.py:from sklearn.utils import is_scalar_nan
sklearn/utils/estimator_checks.py:from sklearn.discriminant_analysis import LinearDiscriminantAnalysis
sklearn/utils/estimator_checks.py:from sklearn.linear_model import Ridge
sklearn/utils/estimator_checks.py:from sklearn.base import (clone, ClusterMixin, is_classifier, is_regressor,
sklearn/utils/estimator_checks.py:from sklearn.metrics import accuracy_score, adjusted_rand_score, f1_score
sklearn/utils/estimator_checks.py:from sklearn.random_projection import BaseRandomProjection
sklearn/utils/estimator_checks.py:from sklearn.feature_selection import SelectKBest
sklearn/utils/estimator_checks.py:from sklearn.pipeline import make_pipeline
sklearn/utils/estimator_checks.py:from sklearn.exceptions import DataConversionWarning
sklearn/utils/estimator_checks.py:from sklearn.exceptions import SkipTestWarning
sklearn/utils/estimator_checks.py:from sklearn.model_selection import ShuffleSplit
sklearn/utils/estimator_checks.py:from sklearn.model_selection._validation import _safe_split
sklearn/utils/estimator_checks.py:from sklearn.metrics.pairwise import (rbf_kernel, linear_kernel,
sklearn/utils/estimator_checks.py:from sklearn.utils import shuffle
sklearn/utils/estimator_checks.py:from sklearn.utils.validation import has_fit_parameter, _num_samples
sklearn/utils/estimator_checks.py:from sklearn.preprocessing import StandardScaler
sklearn/utils/estimator_checks.py:from sklearn.datasets import load_iris, load_boston, make_blobs
sklearn/utils/estimator_checks.py:    from sklearn.base.
sklearn/utils/random.py:from sklearn.utils import check_random_state
sklearn/utils/seq_dataset.pyx.tp:from sklearn.utils cimport _random
sklearn/utils/stats.py:from sklearn.utils.extmath import stable_cumsum

Metadata

Metadata

Assignees

No one assigned

    Labels

    EasyWell-defined and straightforward way to resolve

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions