chemotools 0.1.2__py3-none-any.whl → 0.1.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. chemotools/baseline/__init__.py +8 -8
  2. chemotools/baseline/{air_pls.py → _air_pls.py} +2 -16
  3. chemotools/baseline/{ar_pls.py → _ar_pls.py} +2 -15
  4. chemotools/baseline/{constant_baseline_correction.py → _constant_baseline_correction.py} +6 -15
  5. chemotools/baseline/{cubic_spline_correction.py → _cubic_spline_correction.py} +11 -13
  6. chemotools/baseline/{linear_correction.py → _linear_correction.py} +2 -19
  7. chemotools/baseline/{non_negative.py → _non_negative.py} +2 -16
  8. chemotools/baseline/{polynomial_correction.py → _polynomial_correction.py} +13 -23
  9. chemotools/baseline/{subtract_reference.py → _subtract_reference.py} +7 -19
  10. chemotools/derivative/__init__.py +2 -2
  11. chemotools/derivative/{norris_william.py → _norris_william.py} +4 -17
  12. chemotools/derivative/{savitzky_golay.py → _savitzky_golay.py} +2 -16
  13. chemotools/feature_selection/_index_selector.py +1 -7
  14. chemotools/scale/__init__.py +3 -3
  15. chemotools/scale/{min_max_scaler.py → _min_max_scaler.py} +7 -20
  16. chemotools/scale/{norm_scaler.py → _norm_scaler.py} +5 -18
  17. chemotools/scale/{point_scaler.py → _point_scaler.py} +11 -22
  18. chemotools/scatter/__init__.py +4 -4
  19. chemotools/scatter/{extended_multiplicative_scatter_correction.py → _extended_multiplicative_scatter_correction.py} +2 -10
  20. chemotools/scatter/{multiplicative_scatter_correction.py → _multiplicative_scatter_correction.py} +2 -8
  21. chemotools/scatter/{robust_normal_variate.py → _robust_normal_variate.py} +2 -16
  22. chemotools/scatter/{standard_normal_variate.py → _standard_normal_variate.py} +8 -19
  23. chemotools/smooth/__init__.py +4 -4
  24. chemotools/smooth/{mean_filter.py → _mean_filter.py} +5 -18
  25. chemotools/smooth/{median_filter.py → _median_filter.py} +2 -16
  26. chemotools/smooth/{savitzky_golay_filter.py → _savitzky_golay_filter.py} +3 -16
  27. chemotools/smooth/{whittaker_smooth.py → _whittaker_smooth.py} +2 -16
  28. {chemotools-0.1.2.dist-info → chemotools-0.1.3.dist-info}/METADATA +1 -1
  29. chemotools-0.1.3.dist-info/RECORD +58 -0
  30. chemotools-0.1.2.dist-info/RECORD +0 -58
  31. {chemotools-0.1.2.dist-info → chemotools-0.1.3.dist-info}/LICENSE +0 -0
  32. {chemotools-0.1.2.dist-info → chemotools-0.1.3.dist-info}/WHEEL +0 -0
  33. {chemotools-0.1.2.dist-info → chemotools-0.1.3.dist-info}/top_level.txt +0 -0
@@ -1,8 +1,8 @@
1
- from .air_pls import AirPls
2
- from .ar_pls import ArPls
3
- from .constant_baseline_correction import ConstantBaselineCorrection
4
- from .cubic_spline_correction import CubicSplineCorrection
5
- from .linear_correction import LinearCorrection
6
- from .non_negative import NonNegative
7
- from .polynomial_correction import PolynomialCorrection
8
- from .subtract_reference import SubtractReference
1
+ from ._air_pls import AirPls
2
+ from ._ar_pls import ArPls
3
+ from ._constant_baseline_correction import ConstantBaselineCorrection
4
+ from ._cubic_spline_correction import CubicSplineCorrection
5
+ from ._linear_correction import LinearCorrection
6
+ from ._non_negative import NonNegative
7
+ from ._polynomial_correction import PolynomialCorrection
8
+ from ._subtract_reference import SubtractReference
@@ -30,14 +30,6 @@ class AirPls(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
30
30
  The number of iterations used to calculate the baseline. Increasing the number of iterations can improve the
31
31
  accuracy of the baseline correction, but also increases the computation time.
32
32
 
33
- Attributes
34
- ----------
35
- n_features_in_ : int
36
- The number of features in the input data.
37
-
38
- _is_fitted : bool
39
- A flag indicating whether the estimator has been fitted to data.
40
-
41
33
  Methods
42
34
  -------
43
35
  fit(X, y=None)
@@ -85,13 +77,7 @@ class AirPls(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
85
77
  Returns the instance itself.
86
78
  """
87
79
  # Check that X is a 2D array and has only finite values
88
- X = check_input(X)
89
-
90
- # Set the number of features
91
- self.n_features_in_ = X.shape[1]
92
-
93
- # Set the fitted attribute to True
94
- self._is_fitted = True
80
+ X = self._validate_data(X)
95
81
 
96
82
  return self
97
83
 
@@ -113,7 +99,7 @@ class AirPls(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
113
99
  """
114
100
 
115
101
  # Check that the estimator is fitted
116
- check_is_fitted(self, "_is_fitted")
102
+ check_is_fitted(self, "n_features_in_")
117
103
 
118
104
  # Check that X is a 2D array and has only finite values
119
105
  X = check_input(X)
@@ -29,13 +29,6 @@ class ArPls(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
29
29
  nr_iterations : int, optional (default=100)
30
30
  The maximum number of iterations for the weight updating scheme.
31
31
 
32
- Attributes
33
- ----------
34
- n_features_in_ : int
35
- The number of input features.
36
-
37
- _is_fitted : bool
38
- Whether the estimator has been fitted.
39
32
 
40
33
  Methods
41
34
  -------
@@ -86,13 +79,7 @@ class ArPls(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
86
79
  """
87
80
 
88
81
  # Check that X is a 2D array and has only finite values
89
- X = check_input(X)
90
-
91
- # Set the number of features
92
- self.n_features_in_ = X.shape[1]
93
-
94
- # Set the fitted attribute to True
95
- self._is_fitted = True
82
+ X = self._validate_data(X)
96
83
 
97
84
  return self
98
85
 
@@ -114,7 +101,7 @@ class ArPls(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
114
101
  """
115
102
 
116
103
  # Check that the estimator is fitted
117
- check_is_fitted(self, "_is_fitted")
104
+ check_is_fitted(self, "n_features_in_")
118
105
 
119
106
  # Check that X is a 2D array and has only finite values
120
107
  X = check_input(X)
@@ -30,12 +30,6 @@ class ConstantBaselineCorrection(OneToOneFeatureMixin, BaseEstimator, Transforme
30
30
  end_index_ : int
31
31
  The index of the end of the range. It is 1 if the wavenumbers are not provided.
32
32
 
33
- n_features_in_ : int
34
- The number of features in the input data.
35
-
36
- _is_fitted : bool
37
- Whether the transformer has been fitted to data.
38
-
39
33
  Methods
40
34
  -------
41
35
  fit(X, y=None)
@@ -46,7 +40,10 @@ class ConstantBaselineCorrection(OneToOneFeatureMixin, BaseEstimator, Transforme
46
40
  """
47
41
 
48
42
  def __init__(
49
- self, start: int = 0, end: int = 1, wavenumbers: np.ndarray = None,
43
+ self,
44
+ start: int = 0,
45
+ end: int = 1,
46
+ wavenumbers: np.ndarray = None,
50
47
  ) -> None:
51
48
  self.start = start
52
49
  self.end = end
@@ -70,13 +67,7 @@ class ConstantBaselineCorrection(OneToOneFeatureMixin, BaseEstimator, Transforme
70
67
  The fitted transformer.
71
68
  """
72
69
  # Check that X is a 2D array and has only finite values
73
- X = check_input(X)
74
-
75
- # Set the number of features
76
- self.n_features_in_ = X.shape[1]
77
-
78
- # Set the fitted attribute to True
79
- self._is_fitted = True
70
+ X = self._validate_data(X)
80
71
 
81
72
  # Set the start and end indices
82
73
  if self.wavenumbers is None:
@@ -109,7 +100,7 @@ class ConstantBaselineCorrection(OneToOneFeatureMixin, BaseEstimator, Transforme
109
100
  The transformed input data.
110
101
  """
111
102
  # Check that the estimator is fitted
112
- check_is_fitted(self, "_is_fitted")
103
+ check_is_fitted(self, ["start_index_", "end_index_"])
113
104
 
114
105
  # Check that X is a 2D array and has only finite values
115
106
  X = check_input(X)
@@ -5,9 +5,10 @@ from sklearn.utils.validation import check_is_fitted
5
5
 
6
6
  from chemotools.utils.check_inputs import check_input
7
7
 
8
+
8
9
  class CubicSplineCorrection(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
9
10
  """
10
- A transformer that corrects a baseline by subtracting a cubic spline through the
11
+ A transformer that corrects a baseline by subtracting a cubic spline through the
11
12
  points defined by the indices.
12
13
 
13
14
  Parameters
@@ -32,6 +33,7 @@ class CubicSplineCorrection(OneToOneFeatureMixin, BaseEstimator, TransformerMixi
32
33
  Transform the input data by subtracting the constant baseline value.
33
34
 
34
35
  """
36
+
35
37
  def __init__(self, indices: list = None) -> None:
36
38
  self.indices = indices
37
39
 
@@ -53,13 +55,7 @@ class CubicSplineCorrection(OneToOneFeatureMixin, BaseEstimator, TransformerMixi
53
55
  The fitted transformer.
54
56
  """
55
57
  # Check that X is a 2D array and has only finite values
56
- X = check_input(X)
57
-
58
- # Set the number of features
59
- self.n_features_in_ = X.shape[1]
60
-
61
- # Set the fitted attribute to True
62
- self._is_fitted = True
58
+ X = self._validate_data(X)
63
59
 
64
60
  if self.indices is None:
65
61
  self.indices_ = [0, len(X[0]) - 1]
@@ -89,7 +85,7 @@ class CubicSplineCorrection(OneToOneFeatureMixin, BaseEstimator, TransformerMixi
89
85
  The transformed data.
90
86
  """
91
87
  # Check that the estimator is fitted
92
- check_is_fitted(self, "_is_fitted")
88
+ check_is_fitted(self, "indices_")
93
89
 
94
90
  # Check that X is a 2D array and has only finite values
95
91
  X = check_input(X)
@@ -97,7 +93,9 @@ class CubicSplineCorrection(OneToOneFeatureMixin, BaseEstimator, TransformerMixi
97
93
 
98
94
  # Check that the number of features is the same as the fitted data
99
95
  if X_.shape[1] != self.n_features_in_:
100
- raise ValueError(f"Expected {self.n_features_in_} features but got {X_.shape[1]}")
96
+ raise ValueError(
97
+ f"Expected {self.n_features_in_} features but got {X_.shape[1]}"
98
+ )
101
99
 
102
100
  # Calculate spline baseline correction
103
101
  for i, x in enumerate(X_):
@@ -106,7 +104,7 @@ class CubicSplineCorrection(OneToOneFeatureMixin, BaseEstimator, TransformerMixi
106
104
 
107
105
  def _spline_baseline_correct(self, x: np.ndarray) -> np.ndarray:
108
106
  indices = self.indices_
109
- intensity = x[indices]
107
+ intensity = x[indices]
110
108
  spl = CubicSpline(indices, intensity)
111
- baseline = spl(range(len(x)))
112
- return x - baseline
109
+ baseline = spl(range(len(x)))
110
+ return x - baseline
@@ -10,17 +10,6 @@ class LinearCorrection(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
10
10
  A transformer that corrects a baseline by subtracting a linear baseline through the
11
11
  initial and final points of the spectrum.
12
12
 
13
- Parameters
14
- ----------
15
-
16
- Attributes
17
- ----------
18
- n_features_in_ : int
19
- The number of features in the input data.
20
-
21
- _is_fitted : bool
22
- Whether the transformer has been fitted to data.
23
-
24
13
  Methods
25
14
  -------
26
15
  fit(X, y=None)
@@ -68,13 +57,7 @@ class LinearCorrection(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
68
57
  The fitted transformer.
69
58
  """
70
59
  # Check that X is a 2D array and has only finite values
71
- X = check_input(X)
72
-
73
- # Set the number of features
74
- self.n_features_in_ = X.shape[1]
75
-
76
- # Set the fitted attribute to True
77
- self._is_fitted = True
60
+ X = self._validate_data(X)
78
61
 
79
62
  return self
80
63
 
@@ -99,7 +82,7 @@ class LinearCorrection(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
99
82
  The transformed data.
100
83
  """
101
84
  # Check that the estimator is fitted
102
- check_is_fitted(self, "_is_fitted")
85
+ check_is_fitted(self, "n_features_in_")
103
86
 
104
87
  # Check that X is a 2D array and has only finite values
105
88
  X = check_input(X)
@@ -14,14 +14,6 @@ class NonNegative(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
14
14
  mode : str, optional
15
15
  The mode to use for the non-negative values. Can be "zero" or "abs".
16
16
 
17
- Attributes
18
- ----------
19
- n_features_in_ : int
20
- The number of features in the input data.
21
-
22
- _is_fitted : bool
23
- Whether the transformer has been fitted to data.
24
-
25
17
  Methods
26
18
  -------
27
19
  fit(X, y=None)
@@ -52,13 +44,7 @@ class NonNegative(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
52
44
  The fitted transformer.
53
45
  """
54
46
  # Check that X is a 2D array and has only finite values
55
- X = check_input(X)
56
-
57
- # Set the number of features
58
- self.n_features_in_ = X.shape[1]
59
-
60
- # Set the fitted attribute to True
61
- self._is_fitted = True
47
+ X = self._validate_data(X)
62
48
 
63
49
  return self
64
50
 
@@ -80,7 +66,7 @@ class NonNegative(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
80
66
  The transformed data.
81
67
  """
82
68
  # Check that the estimator is fitted
83
- check_is_fitted(self, "_is_fitted")
69
+ check_is_fitted(self, "n_features_in_")
84
70
 
85
71
  # Check that X is a 2D array and has only finite values
86
72
  X = check_input(X)
@@ -4,9 +4,10 @@ from sklearn.utils.validation import check_is_fitted
4
4
 
5
5
  from chemotools.utils.check_inputs import check_input
6
6
 
7
+
7
8
  class PolynomialCorrection(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
8
9
  """
9
- A transformer that subtracts a polynomial baseline from the input data. The polynomial is
10
+ A transformer that subtracts a polynomial baseline from the input data. The polynomial is
10
11
  fitted to the points in the spectrum specified by the indices parameter.
11
12
 
12
13
  Parameters
@@ -18,14 +19,6 @@ class PolynomialCorrection(OneToOneFeatureMixin, BaseEstimator, TransformerMixin
18
19
  The indices of the points in the spectrum to fit the polynomial to. Defaults to None,
19
20
  which fits the polynomial to all points in the spectrum (equivalent to detrend).
20
21
 
21
- Attributes
22
- ----------
23
- n_features_in_ : int
24
- The number of features in the input data.
25
-
26
- _is_fitted : bool
27
- Whether the transformer has been fitted to data.
28
-
29
22
  Methods
30
23
  -------
31
24
  fit(X, y=None)
@@ -37,6 +30,7 @@ class PolynomialCorrection(OneToOneFeatureMixin, BaseEstimator, TransformerMixin
37
30
  _baseline_correct_spectrum(x)
38
31
  Subtract the polynomial baseline from a single spectrum.
39
32
  """
33
+
40
34
  def __init__(self, order: int = 1, indices: list = None) -> None:
41
35
  self.order = order
42
36
  self.indices = indices
@@ -59,13 +53,7 @@ class PolynomialCorrection(OneToOneFeatureMixin, BaseEstimator, TransformerMixin
59
53
  The fitted transformer.
60
54
  """
61
55
  # Check that X is a 2D array and has only finite values
62
- X = check_input(X)
63
-
64
- # Set the number of features
65
- self.n_features_in_ = X.shape[1]
66
-
67
- # Set the fitted attribute to True
68
- self._is_fitted = True
56
+ X = self._validate_data(X)
69
57
 
70
58
  if self.indices is None:
71
59
  self.indices_ = range(0, len(X[0]))
@@ -73,8 +61,8 @@ class PolynomialCorrection(OneToOneFeatureMixin, BaseEstimator, TransformerMixin
73
61
  self.indices_ = self.indices
74
62
 
75
63
  return self
76
-
77
- def transform(self, X: np.ndarray, y:int=0, copy:bool=True) -> np.ndarray:
64
+
65
+ def transform(self, X: np.ndarray, y: int = 0, copy: bool = True) -> np.ndarray:
78
66
  """
79
67
  Transform the input data by subtracting the polynomial baseline.
80
68
 
@@ -95,7 +83,7 @@ class PolynomialCorrection(OneToOneFeatureMixin, BaseEstimator, TransformerMixin
95
83
  The transformed data.
96
84
  """
97
85
  # Check that the estimator is fitted
98
- check_is_fitted(self, "_is_fitted")
86
+ check_is_fitted(self, "indices_")
99
87
 
100
88
  # Check that X is a 2D array and has only finite values
101
89
  X = check_input(X)
@@ -103,13 +91,15 @@ class PolynomialCorrection(OneToOneFeatureMixin, BaseEstimator, TransformerMixin
103
91
 
104
92
  # Check that the number of features is the same as the fitted data
105
93
  if X_.shape[1] != self.n_features_in_:
106
- raise ValueError(f"Expected {self.n_features_in_} features but got {X_.shape[1]}")
94
+ raise ValueError(
95
+ f"Expected {self.n_features_in_} features but got {X_.shape[1]}"
96
+ )
107
97
 
108
98
  # Calculate polynomial baseline correction
109
99
  for i, x in enumerate(X_):
110
100
  X_[i] = self._baseline_correct_spectrum(x)
111
101
  return X_.reshape(-1, 1) if X_.ndim == 1 else X_
112
-
102
+
113
103
  def _baseline_correct_spectrum(self, x: np.ndarray) -> np.ndarray:
114
104
  """
115
105
  Subtract the polynomial baseline from a single spectrum.
@@ -126,5 +116,5 @@ class PolynomialCorrection(OneToOneFeatureMixin, BaseEstimator, TransformerMixin
126
116
  """
127
117
  intensity = x[self.indices_]
128
118
  poly = np.polyfit(self.indices_, intensity, self.order)
129
- baseline = [np.polyval(poly, i) for i in range(0, len(x))]
130
- return x - baseline
119
+ baseline = [np.polyval(poly, i) for i in range(0, len(x))]
120
+ return x - baseline
@@ -15,14 +15,6 @@ class SubtractReference(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
15
15
  The reference spectrum to subtract from the input data. If None, the original spectrum
16
16
  is returned.
17
17
 
18
- Attributes
19
- ----------
20
- n_features_in_ : int
21
- The number of features in the input data.
22
-
23
- _is_fitted : bool
24
- Whether the transformer has been fitted to data.
25
-
26
18
  Methods
27
19
  -------
28
20
  fit(X, y=None)
@@ -34,6 +26,7 @@ class SubtractReference(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
34
26
  _subtract_reference(x)
35
27
  Subtract the reference spectrum from a single spectrum.
36
28
  """
29
+
37
30
  def __init__(
38
31
  self,
39
32
  reference: np.ndarray = None,
@@ -58,20 +51,13 @@ class SubtractReference(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
58
51
  The fitted transformer.
59
52
  """
60
53
  # Check that X is a 2D array and has only finite values
61
- X = check_input(X)
62
-
63
- # Set the number of features
64
- self.n_features_in_ = X.shape[1]
65
-
66
- # Set the fitted attribute to True
67
- self._is_fitted = True
54
+ X = self._validate_data(X)
68
55
 
69
56
  # Set the reference
70
-
71
57
  if self.reference is not None:
72
58
  self.reference_ = self.reference.copy()
73
59
  return self
74
-
60
+
75
61
  return self
76
62
 
77
63
  def transform(self, X: np.ndarray, y=None) -> np.ndarray:
@@ -92,7 +78,7 @@ class SubtractReference(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
92
78
  The transformed data.
93
79
  """
94
80
  # Check that the estimator is fitted
95
- check_is_fitted(self, "_is_fitted")
81
+ check_is_fitted(self, "n_features_in_")
96
82
 
97
83
  # Check that X is a 2D array and has only finite values
98
84
  X = check_input(X)
@@ -100,7 +86,9 @@ class SubtractReference(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
100
86
 
101
87
  # Check that the number of features is the same as the fitted data
102
88
  if X_.shape[1] != self.n_features_in_:
103
- raise ValueError(f"Expected {self.n_features_in_} features but got {X_.shape[1]}")
89
+ raise ValueError(
90
+ f"Expected {self.n_features_in_} features but got {X_.shape[1]}"
91
+ )
104
92
 
105
93
  if self.reference is None:
106
94
  return X_.reshape(-1, 1) if X_.ndim == 1 else X_
@@ -1,2 +1,2 @@
1
- from .norris_william import NorrisWilliams
2
- from .savitzky_golay import SavitzkyGolay
1
+ from ._norris_william import NorrisWilliams
2
+ from ._savitzky_golay import SavitzkyGolay
@@ -22,17 +22,9 @@ class NorrisWilliams(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
22
22
  The order of the derivative to calculate. Can be 1 or 2. Default is 1.
23
23
 
24
24
  mode : str, optional
25
- The mode to use for the derivative calculation. Can be "nearest", "constant",
25
+ The mode to use for the derivative calculation. Can be "nearest", "constant",
26
26
  "reflect", "wrap", "mirror" or "interp". Default is "nearest".
27
27
 
28
- Attributes
29
- ----------
30
- n_features_in_ : int
31
- The number of features in the input data.
32
-
33
- _is_fitted : bool
34
- Whether the transformer has been fitted to data.
35
-
36
28
  Methods
37
29
  -------
38
30
  fit(X, y=None)
@@ -41,6 +33,7 @@ class NorrisWilliams(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
41
33
  transform(X, y=0, copy=True)
42
34
  Transform the input data by calculating the Norris-Williams derivative.
43
35
  """
36
+
44
37
  def __init__(
45
38
  self,
46
39
  window_size: int = 5,
@@ -71,13 +64,7 @@ class NorrisWilliams(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
71
64
  The fitted transformer.
72
65
  """
73
66
  # Check that X is a 2D array and has only finite values
74
- X = check_input(X)
75
-
76
- # Set the number of features
77
- self.n_features_in_ = X.shape[1]
78
-
79
- # Set the fitted attribute to True
80
- self._is_fitted = True
67
+ X = self._validate_data(X)
81
68
 
82
69
  return self
83
70
 
@@ -99,7 +86,7 @@ class NorrisWilliams(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
99
86
  The transformed data.
100
87
  """
101
88
  # Check that the estimator is fitted
102
- check_is_fitted(self, "_is_fitted")
89
+ check_is_fitted(self, "n_features_in_")
103
90
 
104
91
  # Check that X is a 2D array and has only finite values
105
92
  X = check_input(X)
@@ -27,14 +27,6 @@ class SavitzkyGolay(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
27
27
  The mode to use for the derivative calculation. Can be "nearest", "constant",
28
28
  "reflect", "wrap", "mirror" or "interp". Default is "nearest".
29
29
 
30
- Attributes
31
- ----------
32
- n_features_in_ : int
33
- The number of features in the input data.
34
-
35
- _is_fitted : bool
36
- Whether the transformer has been fitted to data.
37
-
38
30
  Methods
39
31
  -------
40
32
  fit(X, y=None)
@@ -74,13 +66,7 @@ class SavitzkyGolay(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
74
66
  The fitted transformer.
75
67
  """
76
68
  # Check that X is a 2D array and has only finite values
77
- X = check_input(X)
78
-
79
- # Set the number of features
80
- self.n_features_in_ = X.shape[1]
81
-
82
- # Set the fitted attribute to True
83
- self._is_fitted = True
69
+ X = self._validate_data(X)
84
70
 
85
71
  return self
86
72
 
@@ -102,7 +88,7 @@ class SavitzkyGolay(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
102
88
  The transformed data.
103
89
  """
104
90
  # Check that the estimator is fitted
105
- check_is_fitted(self, "_is_fitted")
91
+ check_is_fitted(self, "n_features_in_")
106
92
 
107
93
  # Check that X is a 2D array and has only finite values
108
94
  X = check_input(X)
@@ -31,12 +31,6 @@ class IndexSelector(BaseEstimator, SelectorMixin):
31
31
  features_index_ : int
32
32
  The index of the features to select.
33
33
 
34
- n_features_in_ : int
35
- The number of features in the input data.
36
-
37
- _is_fitted : bool
38
- Whether the transformer has been fitted to data.
39
-
40
34
  Methods
41
35
  -------
42
36
  fit(X, y=None)
@@ -96,7 +90,7 @@ class IndexSelector(BaseEstimator, SelectorMixin):
96
90
 
97
91
  Returns
98
92
  -------
99
- mask : ndarray of shape (n_features,)
93
+ mask : ndarray of shape (n_features_in_,)
100
94
  The mask indicating the selected features.
101
95
  """
102
96
  # Check that the estimator is fitted
@@ -1,3 +1,3 @@
1
- from .min_max_scaler import MinMaxScaler
2
- from .norm_scaler import NormScaler
3
- from .point_scaler import PointScaler
1
+ from ._min_max_scaler import MinMaxScaler
2
+ from ._norm_scaler import NormScaler
3
+ from ._point_scaler import PointScaler
@@ -8,23 +8,15 @@ from chemotools.utils.check_inputs import check_input
8
8
  class MinMaxScaler(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
9
9
  """
10
10
  A transformer that scales the input data by subtracting the minimum and dividing by
11
- the difference between the maximum and the minimum. When the use_min parameter is False,
11
+ the difference between the maximum and the minimum. When the use_min parameter is False,
12
12
  the data is scaled by the maximum.
13
13
 
14
14
  Parameters
15
15
  ----------
16
16
  use_min : bool, default=True
17
- The normalization to use. If True, the data is subtracted by the minimum and
17
+ The normalization to use. If True, the data is subtracted by the minimum and
18
18
  scaled by the maximum. If False, the data is scaled by the maximum.
19
19
 
20
- Attributes
21
- ----------
22
- n_features_in_ : int
23
- The number of features in the input data.
24
-
25
- _is_fitted : bool
26
- Whether the transformer has been fitted to data.
27
-
28
20
  Methods
29
21
  -------
30
22
  fit(X, y=None)
@@ -55,13 +47,7 @@ class MinMaxScaler(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
55
47
  The fitted transformer.
56
48
  """
57
49
  # Check that X is a 2D array and has only finite values
58
- X = check_input(X)
59
-
60
- # Set the number of features
61
- self.n_features_in_ = X.shape[1]
62
-
63
- # Set the fitted attribute to True
64
- self._is_fitted = True
50
+ X = self._validate_data(X)
65
51
 
66
52
  return self
67
53
 
@@ -83,7 +69,7 @@ class MinMaxScaler(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
83
69
  The transformed data.
84
70
  """
85
71
  # Check that the estimator is fitted
86
- check_is_fitted(self, "_is_fitted")
72
+ check_is_fitted(self, "n_features_in_")
87
73
 
88
74
  # Check that X is a 2D array and has only finite values
89
75
  X = check_input(X)
@@ -97,8 +83,9 @@ class MinMaxScaler(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
97
83
 
98
84
  # Normalize the data by the maximum value
99
85
  if self.use_min:
100
- X_ = (X_ - np.min(X_, axis=1, keepdims=True)) / (np.max(
101
- X_, axis=1, keepdims=True) - np.min(X_, axis=1, keepdims=True))
86
+ X_ = (X_ - np.min(X_, axis=1, keepdims=True)) / (
87
+ np.max(X_, axis=1, keepdims=True) - np.min(X_, axis=1, keepdims=True)
88
+ )
102
89
 
103
90
  else:
104
91
  X_ = X_ / np.max(X_, axis=1, keepdims=True)
@@ -12,15 +12,7 @@ class NormScaler(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
12
12
  Parameters
13
13
  ----------
14
14
  l_norm : int, optional
15
- The L-norm to use. Default is 2.
16
-
17
- Attributes
18
- ----------
19
- n_features_in_ : int
20
- The number of features in the input data.
21
-
22
- _is_fitted : bool
23
- Whether the transformer has been fitted to data.
15
+ The L-norm to use. Default is 2.
24
16
 
25
17
  Methods
26
18
  -------
@@ -30,13 +22,14 @@ class NormScaler(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
30
22
  transform(X, y=0, copy=True)
31
23
  Transform the input data by scaling by the L-norm.
32
24
  """
25
+
33
26
  def __init__(self, l_norm: int = 2):
34
27
  self.l_norm = l_norm
35
28
 
36
29
  def fit(self, X: np.ndarray, y=None) -> "NormScaler":
37
30
  """
38
31
  Fit the transformer to the input data.
39
-
32
+
40
33
  Parameters
41
34
  ----------
42
35
  X : np.ndarray of shape (n_samples, n_features)
@@ -51,13 +44,7 @@ class NormScaler(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
51
44
  The fitted transformer.
52
45
  """
53
46
  # Check that X is a 2D array and has only finite values
54
- X = check_input(X)
55
-
56
- # Set the number of features
57
- self.n_features_in_ = X.shape[1]
58
-
59
- # Set the fitted attribute to True
60
- self._is_fitted = True
47
+ X = self._validate_data(X)
61
48
 
62
49
  return self
63
50
 
@@ -79,7 +66,7 @@ class NormScaler(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
79
66
  The transformed data.
80
67
  """
81
68
  # Check that the estimator is fitted
82
- check_is_fitted(self, "_is_fitted")
69
+ check_is_fitted(self, "n_features_in_")
83
70
 
84
71
  # Check that X is a 2D array and has only finite values
85
72
  X = check_input(X)
@@ -7,12 +7,12 @@ from chemotools.utils.check_inputs import check_input
7
7
 
8
8
  class PointScaler(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
9
9
  """
10
- A transformer that scales the input data by the intensity value at a given point.
10
+ A transformer that scales the input data by the intensity value at a given point.
11
11
  The point can be specified by an index or by a wavenumber.
12
12
 
13
13
  Parameters
14
14
  ----------
15
- point : int,
15
+ point : int,
16
16
  The point to scale the data by. It can be an index or a wavenumber.
17
17
 
18
18
  wavenumber : array-like, optional
@@ -25,12 +25,6 @@ class PointScaler(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
25
25
  point_index_ : int
26
26
  The index of the point to scale the data by. It is 0 if the wavenumbers are not provided.
27
27
 
28
- n_features_in_ : int
29
- The number of features in the input data.
30
-
31
- _is_fitted : bool
32
- Whether the transformer has been fitted to data.
33
-
34
28
  Methods
35
29
  -------
36
30
  fit(X, y=None)
@@ -39,11 +33,11 @@ class PointScaler(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
39
33
  transform(X, y=0, copy=True)
40
34
  Transform the input data by scaling by the value at a given Point.
41
35
  """
36
+
42
37
  def __init__(self, point: int = 0, wavenumbers: np.ndarray = None):
43
38
  self.point = point
44
39
  self.wavenumbers = wavenumbers
45
40
 
46
-
47
41
  def fit(self, X: np.ndarray, y=None) -> "PointScaler":
48
42
  """
49
43
  Fit the transformer to the input data.
@@ -62,13 +56,7 @@ class PointScaler(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
62
56
  The fitted transformer.
63
57
  """
64
58
  # Check that X is a 2D array and has only finite values
65
- X = check_input(X)
66
-
67
- # Set the number of features
68
- self.n_features_in_ = X.shape[1]
69
-
70
- # Set the fitted attribute to True
71
- self._is_fitted = True
59
+ X = self._validate_data(X)
72
60
 
73
61
  # Set the point index
74
62
  if self.wavenumbers is None:
@@ -76,7 +64,6 @@ class PointScaler(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
76
64
  else:
77
65
  self.point_index_ = self._find_index(self.point)
78
66
 
79
-
80
67
  return self
81
68
 
82
69
  def transform(self, X: np.ndarray, y=None) -> np.ndarray:
@@ -97,7 +84,7 @@ class PointScaler(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
97
84
  The transformed data.
98
85
  """
99
86
  # Check that the estimator is fitted
100
- check_is_fitted(self, "_is_fitted")
87
+ check_is_fitted(self, "point_index_")
101
88
 
102
89
  # Check that X is a 2D array and has only finite values
103
90
  X = check_input(X)
@@ -105,14 +92,16 @@ class PointScaler(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
105
92
 
106
93
  # Check that the number of features is the same as the fitted data
107
94
  if X_.shape[1] != self.n_features_in_:
108
- raise ValueError(f"Expected {self.n_features_in_} features but got {X_.shape[1]}")
95
+ raise ValueError(
96
+ f"Expected {self.n_features_in_} features but got {X_.shape[1]}"
97
+ )
109
98
 
110
99
  # Scale the data by Point
111
100
  for i, x in enumerate(X_):
112
101
  X_[i] = x / x[self.point_index_]
113
-
102
+
114
103
  return X_.reshape(-1, 1) if X_.ndim == 1 else X_
115
-
104
+
116
105
  def _find_index(self, target: float) -> int:
117
106
  wavenumbers = np.array(self.wavenumbers)
118
- return np.argmin(np.abs(wavenumbers - target))
107
+ return np.argmin(np.abs(wavenumbers - target))
@@ -1,4 +1,4 @@
1
- from .extended_multiplicative_scatter_correction import ExtendedMultiplicativeScatterCorrection
2
- from .multiplicative_scatter_correction import MultiplicativeScatterCorrection
3
- from .robust_normal_variate import RobustNormalVariate
4
- from .standard_normal_variate import StandardNormalVariate
1
+ from ._extended_multiplicative_scatter_correction import ExtendedMultiplicativeScatterCorrection
2
+ from ._multiplicative_scatter_correction import MultiplicativeScatterCorrection
3
+ from ._robust_normal_variate import RobustNormalVariate
4
+ from ._standard_normal_variate import StandardNormalVariate
@@ -37,8 +37,6 @@ class ExtendedMultiplicativeScatterCorrection(
37
37
  ----------
38
38
  reference_ : np.ndarray
39
39
  The reference spectrum used for the correction.
40
- n_features_in_ : int
41
- The number of features in the training data.
42
40
 
43
41
  References
44
42
  ----------
@@ -82,13 +80,7 @@ class ExtendedMultiplicativeScatterCorrection(
82
80
  The fitted transformer.
83
81
  """
84
82
  # Check that X is a 2D array and has only finite values
85
- X = check_input(X)
86
-
87
- # Set the number of features
88
- self.n_features_in_ = X.shape[1]
89
-
90
- # Set the fitted attribute to True
91
- self._is_fitted = True
83
+ X = self._validate_data(X)
92
84
 
93
85
  # Check that the length of the reference is the same as the number of features
94
86
  if self.reference is not None:
@@ -146,7 +138,7 @@ class ExtendedMultiplicativeScatterCorrection(
146
138
  The transformed data.
147
139
  """
148
140
  # Check that the estimator is fitted
149
- check_is_fitted(self, "_is_fitted")
141
+ check_is_fitted(self, "n_features_in_")
150
142
 
151
143
  # Check that X is a 2D array and has only finite values
152
144
  X = check_input(X)
@@ -68,13 +68,7 @@ class MultiplicativeScatterCorrection(
68
68
  The fitted transformer.
69
69
  """
70
70
  # Check that X is a 2D array and has only finite values
71
- X = check_input(X)
72
-
73
- # Set the number of features
74
- self.n_features_in_ = X.shape[1]
75
-
76
- # Set the fitted attribute to True
77
- self._is_fitted = True
71
+ X = self._validate_data(X)
78
72
 
79
73
  # Check that the length of the reference is the same as the number of features
80
74
  if self.reference is not None:
@@ -129,7 +123,7 @@ class MultiplicativeScatterCorrection(
129
123
  The transformed data.
130
124
  """
131
125
  # Check that the estimator is fitted
132
- check_is_fitted(self, "_is_fitted")
126
+ check_is_fitted(self, "n_features_in_")
133
127
 
134
128
  # Check that X is a 2D array and has only finite values
135
129
  X = check_input(X)
@@ -15,14 +15,6 @@ class RobustNormalVariate(OneToOneFeatureMixin, BaseEstimator, TransformerMixin)
15
15
  The percentile to use for the robust normal variate. The value should be
16
16
  between 0 and 100. The default is 25.
17
17
 
18
- Attributes
19
- ----------
20
- n_features_in_ : int
21
- The number of features in the input data.
22
-
23
- _is_fitted : bool
24
- Whether the transformer has been fitted to data.
25
-
26
18
  Methods
27
19
  -------
28
20
  fit(X, y=None)
@@ -58,13 +50,7 @@ class RobustNormalVariate(OneToOneFeatureMixin, BaseEstimator, TransformerMixin)
58
50
  The fitted transformer.
59
51
  """
60
52
  # Check that X is a 2D array and has only finite values
61
- X = check_input(X)
62
-
63
- # Set the number of features
64
- self.n_features_in_ = X.shape[1]
65
-
66
- # Set the fitted attribute to True
67
- self._is_fitted = True
53
+ X = self._validate_data(X)
68
54
 
69
55
  return self
70
56
 
@@ -86,7 +72,7 @@ class RobustNormalVariate(OneToOneFeatureMixin, BaseEstimator, TransformerMixin)
86
72
  The transformed data.
87
73
  """
88
74
  # Check that the estimator is fitted
89
- check_is_fitted(self, "_is_fitted")
75
+ check_is_fitted(self, "n_features_in_")
90
76
 
91
77
  # Check that X is a 2D array and has only finite values
92
78
  X = check_input(X)
@@ -9,14 +9,6 @@ class StandardNormalVariate(OneToOneFeatureMixin, BaseEstimator, TransformerMixi
9
9
  """
10
10
  A transformer that calculates the standard normal variate of the input data.
11
11
 
12
- Attributes
13
- ----------
14
- n_features_in_ : int
15
- The number of features in the input data.
16
-
17
- _is_fitted : bool
18
- Whether the transformer has been fitted to data.
19
-
20
12
  Methods
21
13
  -------
22
14
  fit(X, y=None)
@@ -25,10 +17,11 @@ class StandardNormalVariate(OneToOneFeatureMixin, BaseEstimator, TransformerMixi
25
17
  transform(X, y=0, copy=True)
26
18
  Transform the input data by calculating the standard normal variate.
27
19
  """
20
+
28
21
  def fit(self, X: np.ndarray, y=None) -> "StandardNormalVariate":
29
22
  """
30
23
  Fit the transformer to the input data.
31
-
24
+
32
25
  Parameters
33
26
  ----------
34
27
  X : np.ndarray of shape (n_samples, n_features)
@@ -43,13 +36,7 @@ class StandardNormalVariate(OneToOneFeatureMixin, BaseEstimator, TransformerMixi
43
36
  The fitted transformer.
44
37
  """
45
38
  # Check that X is a 2D array and has only finite values
46
- X = check_input(X)
47
-
48
- # Set the number of features
49
- self.n_features_in_ = X.shape[1]
50
-
51
- # Set the fitted attribute to True
52
- self._is_fitted = True
39
+ X = self._validate_data(X)
53
40
 
54
41
  return self
55
42
 
@@ -71,7 +58,7 @@ class StandardNormalVariate(OneToOneFeatureMixin, BaseEstimator, TransformerMixi
71
58
  The transformed data.
72
59
  """
73
60
  # Check that the estimator is fitted
74
- check_is_fitted(self, "_is_fitted")
61
+ check_is_fitted(self, "n_features_in_")
75
62
 
76
63
  # Check that X is a 2D array and has only finite values
77
64
  X = check_input(X)
@@ -79,7 +66,9 @@ class StandardNormalVariate(OneToOneFeatureMixin, BaseEstimator, TransformerMixi
79
66
 
80
67
  # Check that the number of features is the same as the fitted data
81
68
  if X_.shape[1] != self.n_features_in_:
82
- raise ValueError(f"Expected {self.n_features_in_} features but got {X_.shape[1]}")
69
+ raise ValueError(
70
+ f"Expected {self.n_features_in_} features but got {X_.shape[1]}"
71
+ )
83
72
 
84
73
  # Calculate the standard normal variate
85
74
  for i, x in enumerate(X_):
@@ -88,4 +77,4 @@ class StandardNormalVariate(OneToOneFeatureMixin, BaseEstimator, TransformerMixi
88
77
  return X_.reshape(-1, 1) if X_.ndim == 1 else X_
89
78
 
90
79
  def _calculate_standard_normal_variate(self, x) -> np.ndarray:
91
- return (x - x.mean()) / x.std()
80
+ return (x - x.mean()) / x.std()
@@ -1,4 +1,4 @@
1
- from .mean_filter import MeanFilter
2
- from .median_filter import MedianFilter
3
- from .savitzky_golay_filter import SavitzkyGolayFilter
4
- from .whittaker_smooth import WhittakerSmooth
1
+ from ._mean_filter import MeanFilter
2
+ from ._median_filter import MedianFilter
3
+ from ._savitzky_golay_filter import SavitzkyGolayFilter
4
+ from ._whittaker_smooth import WhittakerSmooth
@@ -14,19 +14,11 @@ class MeanFilter(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
14
14
  ----------
15
15
  window_size : int, optional
16
16
  The size of the window to use for the mean filter. Must be odd. Default is 3.
17
-
17
+
18
18
  mode : str, optional
19
19
  The mode to use for the mean filter. Can be "nearest", "constant", "reflect",
20
20
  "wrap", "mirror" or "interp". Default is "nearest".
21
21
 
22
- Attributes
23
- ----------
24
- n_features_in_ : int
25
- The number of features in the input data.
26
-
27
- _is_fitted : bool
28
- Whether the transformer has been fitted to data.
29
-
30
22
  Methods
31
23
  -------
32
24
  fit(X, y=None)
@@ -35,7 +27,8 @@ class MeanFilter(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
35
27
  transform(X, y=0, copy=True)
36
28
  Transform the input data by calculating the mean filter.
37
29
  """
38
- def __init__(self, window_size: int = 3, mode='nearest') -> None:
30
+
31
+ def __init__(self, window_size: int = 3, mode="nearest") -> None:
39
32
  self.window_size = window_size
40
33
  self.mode = mode
41
34
 
@@ -57,13 +50,7 @@ class MeanFilter(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
57
50
  The fitted transformer.
58
51
  """
59
52
  # Check that X is a 2D array and has only finite values
60
- X = check_input(X)
61
-
62
- # Set the number of features
63
- self.n_features_in_ = X.shape[1]
64
-
65
- # Set the fitted attribute to True
66
- self._is_fitted = True
53
+ X = self._validate_data(X)
67
54
 
68
55
  return self
69
56
 
@@ -85,7 +72,7 @@ class MeanFilter(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
85
72
  The transformed data.
86
73
  """
87
74
  # Check that the estimator is fitted
88
- check_is_fitted(self, "_is_fitted")
75
+ check_is_fitted(self, "n_features_in_")
89
76
 
90
77
  # Check that X is a 2D array and has only finite values
91
78
  X = check_input(X)
@@ -19,14 +19,6 @@ class MedianFilter(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
19
19
  The mode to use for the median filter. Can be "nearest", "constant", "reflect",
20
20
  "wrap", "mirror" or "interp". Default is "nearest".
21
21
 
22
- Attributes
23
- ----------
24
- n_features_in_ : int
25
- The number of features in the input data.
26
-
27
- _is_fitted : bool
28
- Whether the transformer has been fitted to data.
29
-
30
22
  Methods
31
23
  -------
32
24
  fit(X, y=None)
@@ -57,13 +49,7 @@ class MedianFilter(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
57
49
  The fitted transformer.
58
50
  """
59
51
  # Check that X is a 2D array and has only finite values
60
- X = check_input(X)
61
-
62
- # Set the number of features
63
- self.n_features_in_ = X.shape[1]
64
-
65
- # Set the fitted attribute to True
66
- self._is_fitted = True
52
+ X = self._validate_data(X)
67
53
 
68
54
  return self
69
55
 
@@ -85,7 +71,7 @@ class MedianFilter(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
85
71
  The transformed data.
86
72
  """
87
73
  # Check that the estimator is fitted
88
- check_is_fitted(self, "_is_fitted")
74
+ check_is_fitted(self, "n_features_in_")
89
75
 
90
76
  # Check that X is a 2D array and has only finite values
91
77
  X = check_input(X)
@@ -24,14 +24,6 @@ class SavitzkyGolayFilter(OneToOneFeatureMixin, BaseEstimator, TransformerMixin)
24
24
  The mode to use for the Savitzky-Golay filter. Can be "nearest", "constant",
25
25
  "reflect", "wrap", "mirror" or "interp". Default is "nearest".
26
26
 
27
- Attributes
28
- ----------
29
- n_features_in_ : int
30
- The number of features in the input data.
31
-
32
- _is_fitted : bool
33
- Whether the transformer has been fitted to data.
34
-
35
27
  Methods
36
28
  -------
37
29
  fit(X, y=None)
@@ -40,6 +32,7 @@ class SavitzkyGolayFilter(OneToOneFeatureMixin, BaseEstimator, TransformerMixin)
40
32
  transform(X, y=0, copy=True)
41
33
  Transform the input data by calculating the Savitzky-Golay filter.
42
34
  """
35
+
43
36
  def __init__(
44
37
  self, window_size: int = 3, polynomial_order: int = 1, mode: str = "nearest"
45
38
  ) -> None:
@@ -65,13 +58,7 @@ class SavitzkyGolayFilter(OneToOneFeatureMixin, BaseEstimator, TransformerMixin)
65
58
  The fitted transformer.
66
59
  """
67
60
  # Check that X is a 2D array and has only finite values
68
- X = check_input(X)
69
-
70
- # Set the number of features
71
- self.n_features_in_ = X.shape[1]
72
-
73
- # Set the fitted attribute to True
74
- self._is_fitted = True
61
+ self._validate_data(X)
75
62
 
76
63
  return self
77
64
 
@@ -93,7 +80,7 @@ class SavitzkyGolayFilter(OneToOneFeatureMixin, BaseEstimator, TransformerMixin)
93
80
  The transformed data.
94
81
  """
95
82
  # Check that the estimator is fitted
96
- check_is_fitted(self, "_is_fitted")
83
+ check_is_fitted(self, "n_features_in_")
97
84
 
98
85
  # Check that X is a 2D array and has only finite values
99
86
  X = check_input(X)
@@ -24,14 +24,6 @@ class WhittakerSmooth(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
24
24
  differences : int, optional
25
25
  The number of differences to use for the Whittaker smooth. Default is 1.
26
26
 
27
- Attributes
28
- ----------
29
- n_features_in_ : int
30
- The number of features in the input data.
31
-
32
- _is_fitted : bool
33
- Whether the transformer has been fitted to data.
34
-
35
27
  Methods
36
28
  -------
37
29
  fit(X, y=None)
@@ -66,13 +58,7 @@ class WhittakerSmooth(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
66
58
  The fitted transformer.
67
59
  """
68
60
  # Check that X is a 2D array and has only finite values
69
- X = check_input(X)
70
-
71
- # Set the number of features
72
- self.n_features_in_ = X.shape[1]
73
-
74
- # Set the fitted attribute to True
75
- self._is_fitted = True
61
+ X = self._validate_data(X)
76
62
 
77
63
  return self
78
64
 
@@ -94,7 +80,7 @@ class WhittakerSmooth(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
94
80
  The transformed data.
95
81
  """
96
82
  # Check that the estimator is fitted
97
- check_is_fitted(self, "_is_fitted")
83
+ check_is_fitted(self, "n_features_in_")
98
84
 
99
85
  # Check that X is a 2D array and has only finite values
100
86
  X = check_input(X)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: chemotools
3
- Version: 0.1.2
3
+ Version: 0.1.3
4
4
  Summary: Package to integrate chemometrics in scikit-learn pipelines
5
5
  Home-page: https://github.com/paucablop/chemotools
6
6
  Author: Pau Cabaneros Lopez
@@ -0,0 +1,58 @@
1
+ chemotools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ chemotools/augmentation/__init__.py,sha256=LiYw-QE-cxiYY0ua4SOgL0sC_-uAjkykkcj7gRP8Mic,246
3
+ chemotools/augmentation/baseline_shift.py,sha256=Zs0-3zHWaK26f2qGBRRMxA-q6FPxPG00g-8sHe61UAc,3213
4
+ chemotools/augmentation/exponential_noise.py,sha256=X2HTpL9zoiu0cFq3VsTxS3x_IO_tA_DF2vJyKgh4_UA,3082
5
+ chemotools/augmentation/index_shift.py,sha256=7ujZ_sz4mWEUJMDCHyaLxhTZ5-_K3nQPwtk6y6SLR9Q,3198
6
+ chemotools/augmentation/normal_noise.py,sha256=NmzTuIJKyk6tfDJgmeX9iAzsKlJJk3984tS8nLLG9dg,3051
7
+ chemotools/augmentation/spectrum_scale.py,sha256=WgMw_bCxWbyAYgYBO3q4PbbzcTDyBvVD73kxPfj3cdY,3174
8
+ chemotools/augmentation/uniform_noise.py,sha256=gc0WdREItRiPHjNiZg79n0yK6bfntXkcImrEjkoRdus,3180
9
+ chemotools/baseline/__init__.py,sha256=LFhsmzqv9RYxDS5-vK9jIf3ArNUSZ6yOF4SeUyVF6iA,381
10
+ chemotools/baseline/_air_pls.py,sha256=bYAjemEWZr7oiYJegO0r5gtO16zr0BdJYjmEikA1yBc,5116
11
+ chemotools/baseline/_ar_pls.py,sha256=tZi-89GMIStZUufz9AXVHU6TC1J6fAX4M1rAaIqgSvE,4431
12
+ chemotools/baseline/_constant_baseline_correction.py,sha256=oxxzgCtnSHTEb9QczrxsmcHLtvCoKj6IQrH4M_5yNfw,3898
13
+ chemotools/baseline/_cubic_spline_correction.py,sha256=pHpRdD6oVnn4BRg9CumlPJdAikG076kGjCU8mkMNpgw,3187
14
+ chemotools/baseline/_linear_correction.py,sha256=DJow940emZQdcAKpCrkp7l5wyTYURLkr-hhHU6Pzlgw,3022
15
+ chemotools/baseline/_non_negative.py,sha256=SyiS_-cfnypLXY3gC80oo7doqXUlHAAgmwrkRN4iNX8,2536
16
+ chemotools/baseline/_polynomial_correction.py,sha256=0w9qA_w5dc9IIv5KMmAOZ06hWDuk-uyealsTaZX2qgw,3749
17
+ chemotools/baseline/_subtract_reference.py,sha256=vfre6Z-bgDCwwl3VnpahmGJTBFJVK9HGBrUsjfl2O9o,3135
18
+ chemotools/datasets/__init__.py,sha256=ojqxb-C_eDmizwUqVCJ8BqJxwULD7_hWCyVIA1uRO0c,116
19
+ chemotools/datasets/_base.py,sha256=Z174CaIlpx17Yu8Pg1qZPuHWkS3BYWn7gtOYsoe8zNk,2895
20
+ chemotools/datasets/data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
+ chemotools/datasets/data/coffee_labels.csv,sha256=ZXQWQIf8faLHjdnHfRoXfxMR56kq9Q1BGPZBkQyhGlY,487
22
+ chemotools/datasets/data/coffee_spectra.csv,sha256=VA-sN4u0hC5iALlRxxkj-K87Lz3b3mmUHBJPoDXychI,2206147
23
+ chemotools/datasets/data/fermentation_hplc.csv,sha256=AMmiFQxwaXrH8aN310-3h1YQDiDrT8JNRv1RDvhEvg4,2140
24
+ chemotools/datasets/data/fermentation_spectra.csv,sha256=MaaNMQP0lygJgFbEoUX0OUqdA-id8mF5Llvf_vj9tJk,15237508
25
+ chemotools/datasets/data/train_hplc.csv,sha256=DjtmqiePOWB-F6TsOGFngE1pKyXkb7Xmsi-1CLxsTnE,249
26
+ chemotools/datasets/data/train_spectra.csv,sha256=iVF19W52NHlbqq8BbLomn8n47kSPT0QxJv7wtQX4yjQ,203244
27
+ chemotools/derivative/__init__.py,sha256=a9RAUYDG4C8VNJBbirRCpslKjEcKfRxUtSa39c3gp1s,86
28
+ chemotools/derivative/_norris_william.py,sha256=NKmuo95vNWHQOdcww7APU9Z4s1wWExIRaj9O2Xrx8Bs,4753
29
+ chemotools/derivative/_savitzky_golay.py,sha256=5At4sexJH0RvjkrvVfJvhIfaxXD3vE4Ozq1VClb3qlU,3417
30
+ chemotools/feature_selection/__init__.py,sha256=p47SuyI7jMpV7kiaAsv2hA20smKf5Yo6447LfrNdDhY,76
31
+ chemotools/feature_selection/_index_selector.py,sha256=2z2aAyMUOuP7x1n19RV5JGf6ZcM3mtJZby8tEgBOix4,3379
32
+ chemotools/feature_selection/_range_cut.py,sha256=HI2OoeQYNph9uBICSA1cF2C_u-0UjTf0FDv5093tTnU,3223
33
+ chemotools/scale/__init__.py,sha256=CQPUPx-8pUeHHbN9p5smFro3xtl_UEE0YeXHLVd7Lfk,118
34
+ chemotools/scale/_min_max_scaler.py,sha256=-Wnr7zW-zmW6nR5J5yPdBm1KNuQDa9w27Un7rAr-s8E,2806
35
+ chemotools/scale/_norm_scaler.py,sha256=bjMg1-x2I1xZmmbIgl4vXZZweJV-w3Euta0KGff_2Gk,2363
36
+ chemotools/scale/_point_scaler.py,sha256=u2QELIHF35TReMk3RzXliacNPEAZJmVrjjJy9Rmn1q0,3256
37
+ chemotools/scatter/__init__.py,sha256=-Zs5HBpPL3NaO25n8gh0JZI8f5z88cnt-kVFYT3s3a8,292
38
+ chemotools/scatter/_extended_multiplicative_scatter_correction.py,sha256=SbTEMOPl3oWrzqIvYeVLrFhJKgPH9Ra32RO7OvzLJ00,6692
39
+ chemotools/scatter/_multiplicative_scatter_correction.py,sha256=ZQaypqJhjmqSqW_f7SB_8qJxaHax1Jmz3hAs5fOves4,5547
40
+ chemotools/scatter/_robust_normal_variate.py,sha256=DXHTVGx7rXRwoi-DDULN1CjA4gKv8dQDQ8giJ9X3oZs,2905
41
+ chemotools/scatter/_standard_normal_variate.py,sha256=Q4Cr8aMp5u9pOSDFKM7NIRU5BSRbY7C2A_kDeNcOl4I,2377
42
+ chemotools/smooth/__init__.py,sha256=x-QksF-Z_TIIRDR1EZMf44G0K1Fn7plofsufyaIwuvw,180
43
+ chemotools/smooth/_mean_filter.py,sha256=D-v_GaNgAWxb2NTESVmAcSi-Nqw045hCvJRKLb5ksuc,2622
44
+ chemotools/smooth/_median_filter.py,sha256=tDp_8JK2n9yVKeznf47vaYs8UTOt3D3p1f6PJpZpqy4,2638
45
+ chemotools/smooth/_savitzky_golay_filter.py,sha256=gNIu7drl-Drb5WK0gBRlLu7AY_JHDIiiEDAEEAZJ8M4,3192
46
+ chemotools/smooth/_whittaker_smooth.py,sha256=w9ZecU3A2SM0cWSGGGmYutE0KGpNgzln7w7ocao3nnU,3353
47
+ chemotools/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
48
+ chemotools/utils/check_inputs.py,sha256=fRAV4HIaGamdj_PNXSNnl7LurXytACNTGO51rhPpMUY,512
49
+ tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
50
+ tests/fixtures.py,sha256=Xa-Vd62Kd1fyWg3PLUSP6iIkOK8etrbyOkMJTn3dvX8,1933
51
+ tests/test_datasets.py,sha256=_3mMDYC-vUnb5BenMqvuhmkHI2PPIdsyq_nNu2ggH20,1055
52
+ tests/test_functionality.py,sha256=UhOYEShJZJOwROjNMf3UtXl5MrQBeQQbEMEt0ph7yQ0,21182
53
+ tests/test_sklearn_compliance.py,sha256=CRB_0X9HRGj0pOpUCmiSHwJkCsVB-yK_apsyUONmfmw,5856
54
+ chemotools-0.1.3.dist-info/LICENSE,sha256=qtyOy2wDQVX9hxp58h3T-6Lmfv-mSCHoSRkcLUdM9bg,1070
55
+ chemotools-0.1.3.dist-info/METADATA,sha256=K_8Kuy1_hHBEK3p1WSMLfR0NfHuptAzCa5uijUT6RLc,5018
56
+ chemotools-0.1.3.dist-info/WHEEL,sha256=Xo9-1PvkuimrydujYJAjF7pCkriuXBpUPEjma1nZyJ0,92
57
+ chemotools-0.1.3.dist-info/top_level.txt,sha256=eNcNcKSdo-1H_2gwSDrS__dr7BM3R73Cnn-pBiW5FEw,17
58
+ chemotools-0.1.3.dist-info/RECORD,,
@@ -1,58 +0,0 @@
1
- chemotools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- chemotools/augmentation/__init__.py,sha256=LiYw-QE-cxiYY0ua4SOgL0sC_-uAjkykkcj7gRP8Mic,246
3
- chemotools/augmentation/baseline_shift.py,sha256=Zs0-3zHWaK26f2qGBRRMxA-q6FPxPG00g-8sHe61UAc,3213
4
- chemotools/augmentation/exponential_noise.py,sha256=X2HTpL9zoiu0cFq3VsTxS3x_IO_tA_DF2vJyKgh4_UA,3082
5
- chemotools/augmentation/index_shift.py,sha256=7ujZ_sz4mWEUJMDCHyaLxhTZ5-_K3nQPwtk6y6SLR9Q,3198
6
- chemotools/augmentation/normal_noise.py,sha256=NmzTuIJKyk6tfDJgmeX9iAzsKlJJk3984tS8nLLG9dg,3051
7
- chemotools/augmentation/spectrum_scale.py,sha256=WgMw_bCxWbyAYgYBO3q4PbbzcTDyBvVD73kxPfj3cdY,3174
8
- chemotools/augmentation/uniform_noise.py,sha256=gc0WdREItRiPHjNiZg79n0yK6bfntXkcImrEjkoRdus,3180
9
- chemotools/baseline/__init__.py,sha256=W61mEZU_9-sVGRkP2MJOIhd6e9KsOS1BYjxm1NOMIyM,373
10
- chemotools/baseline/air_pls.py,sha256=OPZZdcsQvEngwjoF8c9rzL1VfRNR_6geg2AuXlL98A8,5460
11
- chemotools/baseline/ar_pls.py,sha256=OY2cpU2X6KIBR9ag3PAJXo_uQbniIV58zbUJxCxvZWs,4736
12
- chemotools/baseline/constant_baseline_correction.py,sha256=97xpKOBOwT5EhrD5tf32ZfkyZpf0_bL-VtyUFng1hn4,4158
13
- chemotools/baseline/cubic_spline_correction.py,sha256=PCHqR7TAhbdlTZrxgedlk0PU0kRUwQd_jymh0g-ieo8,3311
14
- chemotools/baseline/linear_correction.py,sha256=6Sw2n4QTvIDKWRdJpFD48hMvOEwqbctUAQLF1WwcoXs,3381
15
- chemotools/baseline/non_negative.py,sha256=17_82l95U9kgoQ3Pdz3-jGv8B51JzqPdHODt6PegWRw,2864
16
- chemotools/baseline/polynomial_correction.py,sha256=caP866fwZb7PASyz6oezgg8hdZtFMT0EimK89TGSTSc,4059
17
- chemotools/baseline/subtract_reference.py,sha256=Pht87XadXK0URq2fun66OHaUk_cx56AkF84ta3VJy_8,3441
18
- chemotools/datasets/__init__.py,sha256=ojqxb-C_eDmizwUqVCJ8BqJxwULD7_hWCyVIA1uRO0c,116
19
- chemotools/datasets/_base.py,sha256=Z174CaIlpx17Yu8Pg1qZPuHWkS3BYWn7gtOYsoe8zNk,2895
20
- chemotools/datasets/data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
- chemotools/datasets/data/coffee_labels.csv,sha256=ZXQWQIf8faLHjdnHfRoXfxMR56kq9Q1BGPZBkQyhGlY,487
22
- chemotools/datasets/data/coffee_spectra.csv,sha256=VA-sN4u0hC5iALlRxxkj-K87Lz3b3mmUHBJPoDXychI,2206147
23
- chemotools/datasets/data/fermentation_hplc.csv,sha256=AMmiFQxwaXrH8aN310-3h1YQDiDrT8JNRv1RDvhEvg4,2140
24
- chemotools/datasets/data/fermentation_spectra.csv,sha256=MaaNMQP0lygJgFbEoUX0OUqdA-id8mF5Llvf_vj9tJk,15237508
25
- chemotools/datasets/data/train_hplc.csv,sha256=DjtmqiePOWB-F6TsOGFngE1pKyXkb7Xmsi-1CLxsTnE,249
26
- chemotools/datasets/data/train_spectra.csv,sha256=iVF19W52NHlbqq8BbLomn8n47kSPT0QxJv7wtQX4yjQ,203244
27
- chemotools/derivative/__init__.py,sha256=x2F0IJ-uCbEYFoXFbZl_RTPCbSq82vqGOwlM9R_2Klo,84
28
- chemotools/derivative/norris_william.py,sha256=JaJ7zlSiC_0tiITu7VWXtgKrmkQP7gLvuFb0_n1j9Dw,5081
29
- chemotools/derivative/savitzky_golay.py,sha256=fFzQRVGVXQIUkHp1x9dqfLVPlyStubIhSj9aGfZKuXY,3745
30
- chemotools/feature_selection/__init__.py,sha256=p47SuyI7jMpV7kiaAsv2hA20smKf5Yo6447LfrNdDhY,76
31
- chemotools/feature_selection/_index_selector.py,sha256=D51816oj5kikk3lS6tkAAk0fxYNegx8YgF-VO1BGrgI,3531
32
- chemotools/feature_selection/_range_cut.py,sha256=HI2OoeQYNph9uBICSA1cF2C_u-0UjTf0FDv5093tTnU,3223
33
- chemotools/scale/__init__.py,sha256=HuXy_TktvXLTMWoW0pKhVCzMOkRkMRnvWCGiIKvjvZ8,115
34
- chemotools/scale/min_max_scaler.py,sha256=f1bGkODTWGwfnfMfWPimVxIZC3WIikgthQh-zUiaQUU,3123
35
- chemotools/scale/norm_scaler.py,sha256=qNs-npf5Jqcp8RYqt88_5-zwd-yIo-J1jItgUTFeozs,2699
36
- chemotools/scale/point_scaler.py,sha256=LGSmZwuEYLxzVPgH-_aRk9SjOdmyQTxdguqRdBfqCwc,3540
37
- chemotools/scatter/__init__.py,sha256=M0_B4hXVoDc2Qx00QreUfhFqPUTs6LbU4CWaFU17hg4,288
38
- chemotools/scatter/extended_multiplicative_scatter_correction.py,sha256=J65hyEFBzKNo_35Ta9MKWO35CjTw-8hDbSr8xd8RIfc,6912
39
- chemotools/scatter/multiplicative_scatter_correction.py,sha256=MFemiwS-KWFOtlcXVhLnY4mn6QQ8pttuj6UP0rodXEM,5689
40
- chemotools/scatter/robust_normal_variate.py,sha256=joIL-nGUja0nG8YcCuT32ehxmy2xOy3OD0t0yP5vWfM,3233
41
- chemotools/scatter/standard_normal_variate.py,sha256=wmK_8ea2CvoLaGebBFKr8zAU7QjGbaKAg04y6iZ4sDc,2681
42
- chemotools/smooth/__init__.py,sha256=Kwg3jVnl-W-efTHMR6-6hQsTp-An1lYQ1lZFj6sNMtg,176
43
- chemotools/smooth/mean_filter.py,sha256=fcC4EjO57Br3I9SJqWDJRxPxAv2WjjmXTECdBmBYXLI,2953
44
- chemotools/smooth/median_filter.py,sha256=5tR931HIej-yrw1SoV9t09gi55QKbZ3eCTeO-EjNSU8,2966
45
- chemotools/smooth/savitzky_golay_filter.py,sha256=OlkW4-gHsgk7HFf7yeweKkL6aOZpNqMSbUpvKjC66KY,3523
46
- chemotools/smooth/whittaker_smooth.py,sha256=Pq7Njvgc1BMRxnP7mffZPTVhS6KiWR2aKLDa7MTEsbQ,3681
47
- chemotools/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
48
- chemotools/utils/check_inputs.py,sha256=fRAV4HIaGamdj_PNXSNnl7LurXytACNTGO51rhPpMUY,512
49
- tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
50
- tests/fixtures.py,sha256=Xa-Vd62Kd1fyWg3PLUSP6iIkOK8etrbyOkMJTn3dvX8,1933
51
- tests/test_datasets.py,sha256=_3mMDYC-vUnb5BenMqvuhmkHI2PPIdsyq_nNu2ggH20,1055
52
- tests/test_functionality.py,sha256=UhOYEShJZJOwROjNMf3UtXl5MrQBeQQbEMEt0ph7yQ0,21182
53
- tests/test_sklearn_compliance.py,sha256=CRB_0X9HRGj0pOpUCmiSHwJkCsVB-yK_apsyUONmfmw,5856
54
- chemotools-0.1.2.dist-info/LICENSE,sha256=qtyOy2wDQVX9hxp58h3T-6Lmfv-mSCHoSRkcLUdM9bg,1070
55
- chemotools-0.1.2.dist-info/METADATA,sha256=fVbKp2kL76gT3eV_MABv3OcGEyhPXc49N9t_B7c_TzI,5018
56
- chemotools-0.1.2.dist-info/WHEEL,sha256=Xo9-1PvkuimrydujYJAjF7pCkriuXBpUPEjma1nZyJ0,92
57
- chemotools-0.1.2.dist-info/top_level.txt,sha256=eNcNcKSdo-1H_2gwSDrS__dr7BM3R73Cnn-pBiW5FEw,17
58
- chemotools-0.1.2.dist-info/RECORD,,