根据他人预测新产品的价值?
predict value of a New Product based on others?
我有以下数据集,每一行是一辆有 5 个值的汽车,最后是他的价格
我想添加一个包含 5 个值的新汽车行,并根据从前几行中了解到的信息获得价格 calculated/predicted。
这可以在 excel 或 python 中完成吗?
您正在寻找的是解决 'regression' 问题的方法。在 Python 和 Excel 中有很多方法可以做到这一点。如果您 google 'Python regression Machine Learning'.
,您会发现很多有关如何设置数据的帮助
对于 Python 我会尝试使用 scikit-learn 模块。示例代码可能如下所示:
from sklearn import linear_model
import pandas as pd
# assume the input dataset you have above is read into a pandas dataframe:
data = pd.read_csv('inputdata.csv')
X = data[['Value1','Value2','Value3','Value4','Value5']]
y = data['Price']
regr = linear_model.LinearRegression()
# Train the model using the training sets
regr.fit(X, y)
# now assuming some new set of data with the same columns as your training data
X_test = pd.read_csv('inputdata.csv')[['Value1','Value2','Value3','Value4','Value5']]
# can generate predictions with
predictions = regr.predict(X_test)
从上面可以看出,制作某种模型来预测新值的代码非常少。然而,该模型可能做得不是很好。理解如何建立一个强大的模型超出了这个问题的范围,但是有很多在线资源可以帮助你做到这一点,for example.
我有以下数据集,每一行是一辆有 5 个值的汽车,最后是他的价格
我想添加一个包含 5 个值的新汽车行,并根据从前几行中了解到的信息获得价格 calculated/predicted。
这可以在 excel 或 python 中完成吗?
您正在寻找的是解决 'regression' 问题的方法。在 Python 和 Excel 中有很多方法可以做到这一点。如果您 google 'Python regression Machine Learning'.
,您会发现很多有关如何设置数据的帮助对于 Python 我会尝试使用 scikit-learn 模块。示例代码可能如下所示:
from sklearn import linear_model
import pandas as pd
# assume the input dataset you have above is read into a pandas dataframe:
data = pd.read_csv('inputdata.csv')
X = data[['Value1','Value2','Value3','Value4','Value5']]
y = data['Price']
regr = linear_model.LinearRegression()
# Train the model using the training sets
regr.fit(X, y)
# now assuming some new set of data with the same columns as your training data
X_test = pd.read_csv('inputdata.csv')[['Value1','Value2','Value3','Value4','Value5']]
# can generate predictions with
predictions = regr.predict(X_test)
从上面可以看出,制作某种模型来预测新值的代码非常少。然而,该模型可能做得不是很好。理解如何建立一个强大的模型超出了这个问题的范围,但是有很多在线资源可以帮助你做到这一点,for example.