chemotools 0.1.2__py3-none-any.whl → 0.1.4__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.
- chemotools/augmentation/uniform_noise.py +6 -6
- chemotools/baseline/__init__.py +8 -8
- chemotools/baseline/{air_pls.py → _air_pls.py} +2 -16
- chemotools/baseline/{ar_pls.py → _ar_pls.py} +2 -15
- chemotools/baseline/{constant_baseline_correction.py → _constant_baseline_correction.py} +6 -15
- chemotools/baseline/{cubic_spline_correction.py → _cubic_spline_correction.py} +11 -13
- chemotools/baseline/{linear_correction.py → _linear_correction.py} +2 -19
- chemotools/baseline/{non_negative.py → _non_negative.py} +2 -16
- chemotools/baseline/{polynomial_correction.py → _polynomial_correction.py} +13 -23
- chemotools/baseline/{subtract_reference.py → _subtract_reference.py} +7 -19
- chemotools/derivative/__init__.py +2 -2
- chemotools/derivative/{norris_william.py → _norris_william.py} +4 -17
- chemotools/derivative/{savitzky_golay.py → _savitzky_golay.py} +2 -16
- chemotools/feature_selection/_index_selector.py +1 -7
- chemotools/feature_selection/_range_cut.py +1 -0
- chemotools/scale/__init__.py +3 -3
- chemotools/scale/{min_max_scaler.py → _min_max_scaler.py} +7 -20
- chemotools/scale/{norm_scaler.py → _norm_scaler.py} +5 -18
- chemotools/scale/{point_scaler.py → _point_scaler.py} +11 -22
- chemotools/scatter/__init__.py +4 -4
- chemotools/scatter/{extended_multiplicative_scatter_correction.py → _extended_multiplicative_scatter_correction.py} +2 -10
- chemotools/scatter/{multiplicative_scatter_correction.py → _multiplicative_scatter_correction.py} +2 -8
- chemotools/scatter/{robust_normal_variate.py → _robust_normal_variate.py} +2 -16
- chemotools/scatter/{standard_normal_variate.py → _standard_normal_variate.py} +8 -19
- chemotools/smooth/__init__.py +4 -4
- chemotools/smooth/{mean_filter.py → _mean_filter.py} +5 -18
- chemotools/smooth/{median_filter.py → _median_filter.py} +2 -16
- chemotools/smooth/{savitzky_golay_filter.py → _savitzky_golay_filter.py} +3 -16
- chemotools/smooth/{whittaker_smooth.py → _whittaker_smooth.py} +2 -16
- {chemotools-0.1.2.dist-info → chemotools-0.1.4.dist-info}/METADATA +1 -1
- chemotools-0.1.4.dist-info/RECORD +58 -0
- {chemotools-0.1.2.dist-info → chemotools-0.1.4.dist-info}/WHEEL +1 -1
- tests/test_functionality.py +2 -1
- chemotools-0.1.2.dist-info/RECORD +0 -58
- {chemotools-0.1.2.dist-info → chemotools-0.1.4.dist-info}/LICENSE +0 -0
- {chemotools-0.1.2.dist-info → chemotools-0.1.4.dist-info}/top_level.txt +0 -0
@@ -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 =
|
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, "
|
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 =
|
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, "
|
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(
|
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))
|
chemotools/scatter/__init__.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
from .
|
2
|
-
from .
|
3
|
-
from .
|
4
|
-
from .
|
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 =
|
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, "
|
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)
|
chemotools/scatter/{multiplicative_scatter_correction.py → _multiplicative_scatter_correction.py}
RENAMED
@@ -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 =
|
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, "
|
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 =
|
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, "
|
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 =
|
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, "
|
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(
|
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()
|
chemotools/smooth/__init__.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
from .
|
2
|
-
from .
|
3
|
-
from .
|
4
|
-
from .
|
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
|
-
|
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 =
|
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, "
|
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 =
|
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, "
|
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
|
-
|
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, "
|
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 =
|
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, "
|
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)
|
@@ -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=szGhk9T7SDe_6v5N8n8ztf7lxHVMiqqzrgL0JGHystw,3175
|
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=gcKjmCGn0SwKRHck3QIrqWN3q-S9qRgGlSbqzaOxG7Y,3309
|
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=cWFWSVTaEkMoZD1tB6-wfEXX59bEDzE8EVo0NcmEABw,21237
|
53
|
+
tests/test_sklearn_compliance.py,sha256=CRB_0X9HRGj0pOpUCmiSHwJkCsVB-yK_apsyUONmfmw,5856
|
54
|
+
chemotools-0.1.4.dist-info/LICENSE,sha256=qtyOy2wDQVX9hxp58h3T-6Lmfv-mSCHoSRkcLUdM9bg,1070
|
55
|
+
chemotools-0.1.4.dist-info/METADATA,sha256=TawdLG6hGhatxlxsWZ4ZoQO3FZIBhJdcgBfi6_P4CxA,5018
|
56
|
+
chemotools-0.1.4.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
57
|
+
chemotools-0.1.4.dist-info/top_level.txt,sha256=eNcNcKSdo-1H_2gwSDrS__dr7BM3R73Cnn-pBiW5FEw,17
|
58
|
+
chemotools-0.1.4.dist-info/RECORD,,
|
tests/test_functionality.py
CHANGED
@@ -622,6 +622,7 @@ def test_range_cut_by_wavenumber_with_list():
|
|
622
622
|
|
623
623
|
# Assert
|
624
624
|
assert np.allclose(spectrum_corrected[0], spectrum[0][1:7], atol=1e-8)
|
625
|
+
assert range_cut.wavenumbers_ == [2, 3, 4, 5, 6, 7]
|
625
626
|
|
626
627
|
|
627
628
|
def test_range_cut_by_wavenumber_with_dataframe():
|
@@ -740,7 +741,7 @@ def test_subtract_reference_without_reference(spectrum):
|
|
740
741
|
def test_uniform_noise():
|
741
742
|
# Arrange
|
742
743
|
spectrum = np.ones(10000).reshape(1, -1)
|
743
|
-
uniform_noise = UniformNoise(
|
744
|
+
uniform_noise = UniformNoise(min=-1, max=1, random_state=42)
|
744
745
|
|
745
746
|
# Act
|
746
747
|
spectrum_corrected = uniform_noise.fit_transform(spectrum)
|