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,)
()
| 18 | |
| 19 | |
| 20 | def 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 | |
| 37 | def apply_pca(data_x: np.ndarray, n_components: int) -> tuple[np.ndarray, np.ndarray]: |