Skip to content
This repository was archived by the owner on May 7, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions third_party/bigframes_vendored/sklearn/decomposition/_pca.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,30 @@
class PCA(BaseEstimator, metaclass=ABCMeta):
"""Principal component analysis (PCA).

**Examples:**

>>> import bigframes.pandas as bpd
>>> from bigframes.ml.decomposition import PCA
>>> bpd.options.display.progress_bar = None
>>> X = bpd.DataFrame({"feat0": [-1, -2, -3, 1, 2, 3], "feat1": [-1, -1, -2, 1, 1, 2]})
>>> pca = PCA(n_components=2).fit(X)
>>> pca.predict(X) # doctest:+SKIP
principal_component_1 principal_component_2
0 -0.755243 0.157628
1 -1.05405 -0.141179
2 -1.809292 0.016449
3 0.755243 -0.157628
4 1.05405 0.141179
5 1.809292 -0.016449
<BLANKLINE>
[6 rows x 2 columns]
>>> pca.explained_variance_ratio_ # doctest:+SKIP
principal_component_id explained_variance_ratio
0 1 0.00901
1 0 0.99099
<BLANKLINE>
[2 rows x 2 columns]

Args:
n_components (int, float or None, default None):
Number of components to keep. If n_components is not set, all
Expand Down
16 changes: 16 additions & 0 deletions third_party/bigframes_vendored/sklearn/impute/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,22 @@ class SimpleImputer(_BaseImputer):
Replace missing values using a descriptive statistic (e.g. mean, median, or
most frequent) along each column.

**Examples:**

>>> import bigframes.pandas as bpd
>>> from bigframes.ml.impute import SimpleImputer
>>> bpd.options.display.progress_bar = None
>>> X_train = bpd.DataFrame({"feat0": [7.0, 4.0, 10.0], "feat1": [2.0, None, 5.0], "feat2": [3.0, 6.0, 9.0]})
>>> imp_mean = SimpleImputer().fit(X_train)
>>> X_test = bpd.DataFrame({"feat0": [None, 4.0, 10.0], "feat1": [2.0, None, None], "feat2": [3.0, 6.0, 9.0]})
>>> imp_mean.transform(X_test)
imputer_feat0 imputer_feat1 imputer_feat2
0 7.0 2.0 3.0
1 4.0 3.5 6.0
2 10.0 3.5 9.0
<BLANKLINE>
[3 rows x 3 columns]

Args:
strategy ({'mean', 'median', 'most_frequent'}, default='mean'):
The imputation strategy. 'mean': replace missing values using the mean along
Expand Down