Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- from sklearn.ensemble improt RandomForestRegressor
- # Function mapping hyperparameters to a real-valued scpre
- def objective(hyperparameters):
- # Machine learning model
- rf = RandomForestRegressor(**hyperparameters)
- # Training
- rf.fit(X_train, y_train)
- # Making predictions and evaluating
- predictions = rf.predict(X_valid)
- rmse = np.sqrt(np.mean(np.square(prediction - y_valid)))
- return rmse
Add Comment
Please, Sign In to add comment