我需要帮助 我在研究机器学习。 我尝试使用以下代码导入数据集:
# 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)
但是,会出现一个错误: ValueError:输入包含无穷大或对dtype('float64')太大的值
我该怎么办?我是python的新手。 提前谢谢。在
如果数据的值非常大,请尝试规范化。您可以找到更多信息here
我建议您查看是否有空值,在用pandas加载数据集后,请执行以下操作:
还要确保你的X值是数字,你可以使用描述数据集()或数据集.info():
^{pr2}$你也可以尝试更新你的sklearn,在sklearn的某些版本中有一个已知的bug(我不记得是哪一个)
相关问题 更多 >
编程相关推荐