MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / collect_dataset

Function collect_dataset

machine_learning/principle_component_analysis.py:20–34  ·  view source on GitHub ↗

Collects the dataset (Iris dataset) and returns feature matrix and target values. :return: Tuple containing feature matrix (X) and target labels (y) Example: >>> X, y = collect_dataset() >>> X.shape (150, 4) >>> y.shape (150,)

()

Source from the content-addressed store, hash-verified

18
19
20def collect_dataset() -> tuple[np.ndarray, np.ndarray]:
21 """
22 Collects the dataset (Iris dataset) and returns feature matrix and target values.
23
24 :return: Tuple containing feature matrix (X) and target labels (y)
25
26 Example:
27 >>> X, y = collect_dataset()
28 >>> X.shape
29 (150, 4)
30 >>> y.shape
31 (150,)
32 """
33 data = load_iris()
34 return np.array(data.data), np.array(data.target)
35
36
37def apply_pca(data_x: np.ndarray, n_components: int) -> tuple[np.ndarray, np.ndarray]:

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected