'''machine learning'''
# build a model
from sklearn.ensemble import RandomForestRegressor
from sklearn.model_selection import cross_val_score
# Random Forest ( depth)
params=[1,3,5,6,7,8,9,10] # check for each depth to find out which one performs best
test_scores=[] # get score for each depth (designed to find out which one performs best)
for param in params:
clf=RandomForestRegressor(n_estimators=30,max_depth=param) # construct a classifier
test_score=np.sqrt(-cross_val_score(clf,X_train,y_train,scoring='neg_mean_squared_error',cv=5)) # put the training data in and cal the cost
test_scores.append(np.mean(test_score)) # cal the average cost