1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Machine Learning SciKit Learn High RMSE

Discussão em 'Python' iniciado por Stack, Setembro 12, 2025.

  1. Stack

    Stack Membro Participativo

    I am using SciKit Learn to perform Linear Regression. For some reason I am getting extremely high RMSE. I have checked the data and the car data price min 2000.0 and max price is 38369.0.

    Dataset: https://gist.github.com/azamsharp/edc17c9e13a1643ea315d3c3b85fafd4

    Do you see anything wrong with the following code?

    import pandas as pd
    df = pd.read_csv("/content/sample_data/Car_Prices_Dataset__Highly_Correlated__20k_rows_.csv")

    from sklearn.preprocessing import StandardScaler

    # Standardized
    scaler = StandardScaler()
    df[["Year", "Mileage"]] = scaler.fit_transform(df[["Year", "Mileage"]])

    X = df.drop(["Price"], axis=1)
    y = df["Price"]

    from sklearn.model_selection import train_test_split
    X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

    from sklearn.linear_model import LinearRegression

    model = LinearRegression()
    model.fit(X_train, y_train)

    from sklearn.metrics import r2_score, mean_squared_error
    y_pred = model.predict(X_test)
    r2 = r2_score(y_test, y_pred)
    rmse = mean_squared_error(y_test, y_pred)

    Test R^2: 0.803
    Test RMSE: $21,279,110

    Continue reading...

Compartilhe esta Página