Guest User

Untitled

a guest
Jun 24th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. import numpy as np
  2. from sklearn.ensemble improt RandomForestRegressor
  3.  
  4. # Function mapping hyperparameters to a real-valued scpre
  5. def objective(hyperparameters):
  6.  
  7. # Machine learning model
  8. rf = RandomForestRegressor(**hyperparameters)
  9.  
  10. # Training
  11. rf.fit(X_train, y_train)
  12.  
  13. # Making predictions and evaluating
  14. predictions = rf.predict(X_valid)
  15. rmse = np.sqrt(np.mean(np.square(prediction - y_valid)))
  16.  
  17. return rmse
Add Comment
Please, Sign In to add comment