import os
import numpy as np

HERE = os.path.dirname(os.path.abspath(__file__))
MEDIA = os.path.join(HERE, "media")
SEED = 572

FEATURES = ["sepal length (cm)", "sepal width (cm)",
            "petal length (cm)", "petal width (cm)"]
CLASSES = ["Iris-setosa", "Iris-versicolor", "Iris-virginica"]
COLORS = ["#1b9e77", "#d95f02", "#7570b3"]


def load_iris():
    """Read the UCI iris.data file. Returns X (150 x 4) and y (0, 1, 2)."""
    X, y = [], []
    with open(os.path.join(HERE, "iris.data")) as f:
        for line in f:
            line = line.strip()
            if not line:
                continue
            parts = line.split(",")
            X.append([float(v) for v in parts[:4]])
            y.append(CLASSES.index(parts[4]))
    return np.array(X), np.array(y)


if __name__ == "__main__":
    X, y = load_iris()
    print("X shape:", X.shape)
    print("y counts:", np.bincount(y))
    print("first row:", X[0], CLASSES[y[0]])
