我想将DataFrame中的DatetimeIndex转换为float格式,可以在模型中对其进行分析。有人可以告诉我该怎么做吗?我需要使用date2num()函数吗?非常感谢!
我正在研究GridSearch方法来调整Desicion树模型或随机森林模型的参数.在阅读了波士顿住房价格的例子后,我发现我无法运行该示例的代码.以下代码是示例的GridSearch代码.问题是ValueError: Parameter values for parameter (max_depth) need to be a sequence.我搜索了某些示例,但是,params这些示例中的变量几乎以相同的格式定义,这可能导致此错误.我认为作者想要创建一个带键的字典总是"max_depth",但值会从1到10不等.我无法解决这个问题.有人可以帮助我吗?
def fit_model(X, y):
""" Performs grid search over the 'max_depth' parameter for a
decision tree regressor trained on the input data [X, y]. """
# Create cross-validation sets from the training data
cv_sets = ShuffleSplit(X.shape[0], n_iter = 10, test_size = 0.20, random_state = 0)
print (cv_sets)
# Create a decision tree regressor object
regressor = DecisionTreeRegressor()
# Create a dictionary for the parameter 'max_depth' with …Run Code Online (Sandbox Code Playgroud)