Skip to content

Commit 0e8c395

Browse files
analytics
1 parent e7c4542 commit 0e8c395

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

.virtual_documents/testing.ipynb

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from sklearn.decomposition import SparsePCA
2+
import numpy as np
3+
4+
# Generate example data
5+
X = np.array([[1, 2, 3],
6+
[4, 5, 6],
7+
[7, 8, 9]])
8+
9+
# Perform Sparse PCA
10+
spca = SparsePCA(n_components=2, alpha=1)
11+
X_spca = spca.fit_transform(X)
12+
13+
# Components
14+
print("Components:", spca.components_)
15+
16+
# Transformed data
17+
print("Transformed data:", X_spca)
18+
19+
20+
X_spca.shape, X.shape
21+
22+
23+
X_spca, X
24+
25+
26+

0 commit comments

Comments
 (0)