Skip to content

Commit f3afca8

Browse files
fix issue #301
1 parent aed0fb2 commit f3afca8

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

category_encoders/utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import numpy as np
77
import sklearn.base
88
from sklearn.base import BaseEstimator, TransformerMixin
9+
from sklearn.exceptions import NotFittedError
910
from typing import Dict, List, Optional, Union
1011
from scipy.sparse import csr_matrix
1112

@@ -315,7 +316,7 @@ def _check_transform_inputs(self, X):
315316
raise ValueError('Columns to be encoded can not contain null')
316317

317318
if self._dim is None:
318-
raise ValueError('Must train encoder before it can be used to transform data.')
319+
raise NotFittedError('Must train encoder before it can be used to transform data.')
319320

320321
# then make sure that it is the right size
321322
if X.shape[1] != self._dim:
@@ -356,7 +357,7 @@ def get_feature_names(self) -> List[str]:
356357
357358
"""
358359
if not isinstance(self.feature_names, list):
359-
raise ValueError("Estimator has to be fitted to return feature names.")
360+
raise NotFittedError("Estimator has to be fitted to return feature names.")
360361
else:
361362
return self.feature_names
362363

0 commit comments

Comments
 (0)