我的数据集是'kc_house_data_NaN.csv'
问题)使用特征列表拟合线性回归模型以预测“价格”:
"floors"
"waterfront"
"lat"
"bedrooms"
"sqft_basement"
"view"
"bathrooms"
"sqft_living15"
"sqft_above"
"grade"
"sqft_living"
计算R ^ 2。截取代码和R ^ 2的值的屏幕截图。 代码:
import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression
features =["floors", "waterfront","lat" ,"bedrooms" ,"sqft_basement" ,"view" ,"bathrooms","sqft_living15","sqft_above","grade","sqft_living"]
X = df[["floors", "waterfront","lat" ,"bedrooms" ,"sqft_basement" ,"view" ,"bathrooms","sqft_living15","sqft_above","grade","sqft_living"]]
Y = df['price']
lm2 = LinearRegression()
lm2
lm2.fit(X,Y)
lm2.score(X, Y)
错误:
ValueError Traceback (most recent call last)
58
ValueError: Input contains NaN, infinity or a value too large for dtype('float64').
实际的编码错误在哪里