from core.datasets.classic.ClassicDataset import ClassicDataset
from sklearn.datasets import fetch_openml
import numpy as np


class ParkinsonsDataset(ClassicDataset):
    def __init__(self, seed):
        self.dataset = fetch_openml(data_id=1488, as_frame=True)

        super().__init__(
            name='parkinsons',
            num_classes=2,
            num_features=22,
            sample_shape=(22,),
            feature_names=self.dataset.feature_names,
            seed=seed
        )

    def _get_x_y(self):
        x = np.asarray(self.dataset.data)
        y = np.asarray(self.dataset.target)

        # Convert target to integer labels (0 or 1).
        y = y.astype(int) - 1

        return x, y
