MCPcopy
hub / github.com/scikit-learn/scikit-learn / _dense_fit

Method _dense_fit

sklearn/preprocessing/_data.py:2809–2832  ·  view source on GitHub ↗

Compute percentiles for dense matrices. Parameters ---------- X : ndarray of shape (n_samples, n_features) The data used to scale along the features axis.

(self, X, random_state)

Source from the content-addressed store, hash-verified

2807 self.copy = copy
2808
2809 def _dense_fit(self, X, random_state):
2810 """Compute percentiles for dense matrices.
2811
2812 Parameters
2813 ----------
2814 X : ndarray of shape (n_samples, n_features)
2815 The data used to scale along the features axis.
2816 """
2817 if self.ignore_implicit_zeros:
2818 warnings.warn(
2819 "'ignore_implicit_zeros' takes effect only with"
2820 " sparse matrix. This parameter has no effect."
2821 )
2822
2823 n_samples, n_features = X.shape
2824 references = self.references_ * 100
2825
2826 if self.subsample is not None and self.subsample < n_samples:
2827 # Take a subsample of `X`
2828 X = resample(
2829 X, replace=False, n_samples=self.subsample, random_state=random_state
2830 )
2831
2832 self.quantiles_ = np.nanpercentile(X, references, axis=0)
2833
2834 def _sparse_fit(self, X, random_state):
2835 """Compute percentiles for sparse matrices.

Callers 1

fitMethod · 0.95

Calls 1

resampleFunction · 0.90

Tested by

no test coverage detected