Created
March 30, 2018 16:00
-
-
Save tsu-nera/8c37ddf9defca2db46472078351ead33 to your computer and use it in GitHub Desktop.
xgboost visualization with tensorboard
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.datasets import load_boston | |
import pandas as pd | |
import xgboost as xgb | |
from tensorboard_logger import configure, log_value | |
from sklearn.cross_validation import train_test_split | |
def logspy(env): | |
log_value("train", env.evaluation_result_list[0][1], step=env.iteration) | |
log_value("val", env.evaluation_result_list[1][1], step=env.iteration) | |
configure("logs/sample-1234") | |
boston = load_boston() | |
df = pd.DataFrame(boston.data, columns=boston.feature_names) | |
x1, x2, y1, y2 = train_test_split( | |
df, boston.target, test_size=0.1, random_state=18) | |
dtrain = xgb.DMatrix(x1, y1) | |
dvalid = xgb.DMatrix(x2, y2) | |
watchlist = [(dtrain, 'train'), (dvalid, 'valid')] | |
model = xgb.train( | |
params={}, | |
num_boost_round=100, | |
dtrain=dtrain, | |
evals=watchlist, | |
callbacks=[logspy]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://gyazo.com/9da25151162b5e5db0106a55439ef647