我正在尝试评估特征的相关性,并使用 DecisionTreeRegressor()
相关代码如下:
# TODO: Make a copy of the DataFrame, using the 'drop' function to drop the given feature
new_data = data.drop(['Frozen'], axis = 1)
# TODO: Split the data into training and testing sets(0.25) using the given feature as the target
# TODO: Set a random state.
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(new_data, data['Frozen'], test_size = 0.25, random_state = 1)
# TODO: Create a decision tree regressor and fit it to the training set
from sklearn.tree import DecisionTreeRegressor
regressor = DecisionTreeRegressor(random_state=1)
regressor.fit(X_train, y_train)
# TODO: Report the score of the prediction using the testing set
from sklearn.model_selection import cross_val_score
#score = cross_val_score(regressor, X_test, y_test)
score = regressor.score(X_test, y_test)
print score # python 2.x
当我运行
print
函数时,它会返回给定的分数:
你可以在这里找到分数函数实现及一些解释:-0.649574327334
我还没有完全理解整个概念,所以这个解释对我来说并不是很有帮助。例如,我无法理解为什么分数可以为负,以及它确切表示了什么(如果某些东西被平方,我会期望它只能是正的)。返回预测的R^2决定系数。 ... 最佳得分是1.0,但它可能为负(因为模型可能变得任意糟糕)。
这个得分表示什么,为什么它可以是负数?
如果您想了解更多信息,阅读一些文章可能也会有所帮助!