Basics (15).ipynb (25.1 KB)
To complete my project I wanted to further refine the predictions.
To do so, I am trying to for loop through pruning to find the best values (within reason)
def adjustmant_(model):
model.fit(train[columns],train[target])
prediction1 = model.predict(test[columns])
# mean absolute error, (true, predicted)
return mae_(test[target], prediction1)
mae_list = []
for a in range(100):
margin = adjustmant_(RandomForestRegressor(max_depth=1+a,
min_samples_split=2))
mae_list.append(margin)
max_ = max(mae_list)
print([index for index,value in enum(mae_list)if value == max_])
but I am getting a function error.
TypeErrorTraceback (most recent call last)
<ipython-input-13-288a407c9260> in <module>()
8 for a in range(100):
9 margin = adjustmant_(RandomForestRegressor(max_depth=1+a,
---> 10 min_samples_split=2))
11 mae_list.append(margin)
12 max_ = max(mae_list)
<ipython-input-13-288a407c9260> in adjustmant_(model)
1 def adjustmant_(model):
2 model.fit(train[columns],train[target])
----> 3 prediction1 = model.predict(test[columns])
4 # mean absolute error, (true, predicted)
5 return mae_(test[target], prediction1)
TypeError: 'function' object is not subscriptable