【发布时间】:2020-07-30 05:26:51
【问题描述】:
我是机器学习的新手,需要为我的项目构建房价预测模型
我正在使用来自 https://www.ritchieng.com/machine-learning-project-boston-home-prices/ 的教程,但我得到的价格价值却截然不同
# Importing the libraries necessary for this project
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
from sklearn.datasets import load_boston
# Loading the datasets for prediction
boston = load_boston()
prices = boston.target
boston_frame= pd.DataFrame(boston.data, columns=boston.feature_names)
boston_frame['MEDV'] = prices
boston_frame.describe()
# Calculating the minimum, maximum, mean, median and standard deviation of 'MEDV'(i.e prices) in boston
minimum_price = prices.min()
maximum_price = np.max(prices)
mean_price = np.mean(prices)
median_price = np.median(prices)
std_price = np.std(prices)
# Show the calculated statistics
print("Statistics for Boston housing dataset:\n")
print(f"Minimum price: ${(minimum_price):.2f}")
print(f"Maximum price: ${(maximum_price):.2f}")
print(f"Mean price: ${(mean_price):.2f}")
print(f"Median price: ${(median_price):.2f}")
print(f"Standard Deviation of price: ${(std_price):.2f}")
以下是我的输出,它与教程中的内容相去甚远,并且没有任何意义,房子将是 5 美元
Statistics for Boston housing dataset:
Minimum price: $5.00
Maximum price: $50.00
Mean price: $22.53
Median price: $21.20
Standard Deviation of price: $9.19
【问题讨论】:
标签: python pandas scikit-learn