[Python] The result won't display based on the scikit code [closed]

Discussão em 'Python' iniciado por Stack, Fevereiro 9, 2025.

  1. Stack

    Stack Membro Participativo

    When I execute the code, it doesn't work. No result. I dont get any feedback. What am I missing?

    [​IMG]

    # https://scikit-learn.org/stable/getting_started.html

    from sklearn.preprocessing import StandardScaler
    from sklearn.linear_model import LogisticRegression
    from sklearn.pipeline import make_pipeline
    from sklearn.datasets import load_iris
    from sklearn.model_selection import train_test_split
    from sklearn.metrics import accuracy_score

    # create a pipeline object
    pipe = make_pipeline(
    StandardScaler(),
    LogisticRegression()
    )

    # load the iris dataset and split it into train and test sets
    X, y = load_iris(return_X_y=True)
    X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=0)

    # fit the whole pipeline
    pipe.fit(X_train, y_train)

    # we can now use it like any other estimator
    accuracy_score(pipe.predict(X_test), y_test)

    Continue reading...

Compartilhe esta Página