[Python] ValueError: Input contains infinity or a value too large for dtype('float64')

Discussão em 'Python' iniciado por Stack, Abril 15, 2025.

  1. Stack

    Stack Membro Participativo

    i need help I'm working on machine learning. I tried to import a dataset using this code:

    # Importing the libraries
    import numpy as np
    import matplotlib.pyplot as plt
    import pandas as pd

    # Importing the dataset
    dataset = pd.read_csv('Rural3.csv', low_memory=False)
    X = dataset.iloc[:, :-1].values
    y = dataset.iloc[:, 77].values

    # Splitting the dataset into the Training set and Test set
    from sklearn.model_selection import train_test_split
    X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.25, random_state = 0)

    # Feature Scaling
    from sklearn.preprocessing import StandardScaler
    sc = StandardScaler()
    X_train = sc.fit_transform(X_train)
    X_test = sc.transform(X_test)


    However, an error appears: ValueError: Input contains infinity or a value too large for dtype('float64')

    What should i do please ? i'm newbie in python. Thanks in advance.

    Continue reading...

Compartilhe esta Página