Skip to content

Instantly share code, notes, and snippets.

@sinhrks
Last active February 22, 2018 06:13
Show Gist options
  • Save sinhrks/cc9a88f74074fc296e12 to your computer and use it in GitHub Desktop.
Save sinhrks/cc9a88f74074fc296e12 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"'0.4'"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"%matplotlib inline\n",
"import numpy as np\n",
"import xgboost as xgb\n",
"from sklearn import datasets\n",
"\n",
"import matplotlib.pyplot as plt\n",
"plt.style.use('ggplot')\n",
"\n",
"xgb.__version__"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false,
"scrolled": true
},
"outputs": [
{
"data": {
"text/plain": [
"['sepal length (cm)',\n",
" 'sepal width (cm)',\n",
" 'petal length (cm)',\n",
" 'petal width (cm)']"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"iris = datasets.load_iris()\n",
"iris.feature_names"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false,
"scrolled": true
},
"outputs": [],
"source": [
"iris = datasets.load_iris()\n",
"dm = xgb.DMatrix(iris.data, label=iris.target,\n",
" feature_names=['SepalLength', 'SepalWidth', 'PetalLength', u'PetalWidth'])\n",
"\n",
"np.random.seed(1) "
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"['SepalLength', 'SepalWidth', 'PetalLength', u'PetalWidth']"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"params={'objective': 'multi:softprob',\n",
" 'eval_metric': 'mlogloss',\n",
" 'eta': 0.3,\n",
" 'num_class': 3}\n",
"\n",
"bst = xgb.train(params, dm, num_boost_round=18)\n",
"bst.feature_names"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false,
"scrolled": true
},
"outputs": [
{
"data": {
"text/plain": [
"{'PetalLength': 95, 'PetalWidth': 59, 'SepalLength': 17, 'SepalWidth': 16}"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"bst.get_fscore()"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"SepalLength\n",
"PetalWidth\n",
"PetalLength\n",
"SepalWidth\n"
]
}
],
"source": [
"for k in bst.get_fscore():\n",
" print(k)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.axes._subplots.AxesSubplot at 0x106389fd0>"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAbMAAAEhCAYAAAD1Q07PAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XtYFHX/P/7nLrByWkVAPIAHDAFFRQu1GyyPHfFjpil+\nSVGIUswyRZD7rtvQ1Fsw7vRGsu7LY1peYonHLFOgA2ghWiZnBEpS5IxyXNid3x/8mNsV1FXBddjn\n47q82pmdnXm9JuXJe/a9szJBEAQQERFJmFzfBRARET0ohhkREUkew4yIiCSPYUZERJLHMCMiIslj\nmBERkeQxzIgMhKOjI9atW6fvMog6BMOMDNr8+fMhl8tb/YmNjW23Y0yePBn+/v7ttr/7dfbsWSxd\nulTfZdzRnj17IJfzxxLdO2N9F0Ckb08//XSr8OrWrZueqrkzlUoFhUJxX6+1sbFp52raV1NTk75L\nIAnjr0Bk8BQKBezs7LT+dOnSBQCQmpqKZ599FkqlEnZ2dpgxYwb+/PNP8bX5+fmYPn067O3tYWFh\ngeHDh2PPnj3i8/Pnz0d8fDx27doljvp++OEHFBQUQC6XIzk5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0Q342VG\nIgNx7tw5FBUVQRAEmJmZQS6XQy6Xw8nJCVZWVvj888/R0NAAlUqFrKwsAICXlxeOHTuG4uJi1NfX\nY+/evfDy8mpzFAcAzzzzDOLi4lBYWAgAqK2txenTpx9aj2S4ODIjMhBXr17Ftm3bcP36dVhaWuK5\n557DkCFDAAArVqzAjh07sGjRIgDAU089BRcXF0yYMAHl5eV4//330djYiBEjRiAgIOC2xxg9ejTq\n6+uxceNGlJSUwNzcHO7u7vjb3/72UHokw8Uv5yQiIsnjZUYiIpI8hhkREUkew4yIiCSPYUZERJLH\nMCMiIsljmBERkeQxzIiISPIYZkREJHkMMyIikrz/D5nz9DAfHnQbAAAAAElFTkSuQmCC\n",
"text/plain": [
"<matplotlib.figure.Figure at 0x103125d90>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"xgb.plot_importance(bst)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/svg+xml": [
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n",
"<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
"<!-- Generated by graphviz version 2.28.0 (20120430.0057)\n",
" -->\n",
"<!-- Title: _anonymous_0 Pages: 1 -->\n",
"<svg width=\"225pt\" height=\"258pt\"\n",
" viewBox=\"0.00 0.00 225.00 258.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
"<g id=\"graph1\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 254)\">\n",
"<title>_anonymous_0</title>\n",
"<polygon fill=\"white\" stroke=\"white\" points=\"-4,5 -4,-254 222,-254 222,5 -4,5\"/>\n",
"<!-- 0 -->\n",
"<g id=\"node1\" class=\"node\"><title>0</title>\n",
"<ellipse fill=\"none\" stroke=\"black\" cx=\"107\" cy=\"-170\" rx=\"80.0675\" ry=\"80.09\"/>\n",
"<text text-anchor=\"middle\" x=\"107\" y=\"-164.4\" font-family=\"Times,serif\" font-size=\"14.00\">PetalLength&lt;2.45</text>\n",
"</g>\n",
"<!-- 1 -->\n",
"<g id=\"node3\" class=\"node\"><title>1</title>\n",
"<polygon fill=\"none\" stroke=\"black\" points=\"96.5306,-36 -0.530646,-36 -0.530646,-0 96.5306,-0 96.5306,-36\"/>\n",
"<text text-anchor=\"middle\" x=\"48\" y=\"-12.4\" font-family=\"Times,serif\" font-size=\"14.00\">leaf=0.430622</text>\n",
"</g>\n",
"<!-- 0&#45;&gt;1 -->\n",
"<g id=\"edge2\" class=\"edge\"><title>0&#45;&gt;1</title>\n",
"<path fill=\"none\" stroke=\"#0000ff\" d=\"M78.0185,-95.3183C71.0303,-77.5517 64.0033,-59.6864 58.5067,-45.712\"/>\n",
"<polygon fill=\"#0000ff\" stroke=\"#0000ff\" points=\"61.7148,-44.3061 54.7973,-36.2813 55.2006,-46.8684 61.7148,-44.3061\"/>\n",
"<text text-anchor=\"middle\" x=\"103.614\" y=\"-57.4\" font-family=\"Times,serif\" font-size=\"14.00\">yes, missing</text>\n",
"</g>\n",
"<!-- 2 -->\n",
"<g id=\"node5\" class=\"node\"><title>2</title>\n",
"<polygon fill=\"none\" stroke=\"black\" points=\"217.028,-36 114.972,-36 114.972,-0 217.028,-0 217.028,-36\"/>\n",
"<text text-anchor=\"middle\" x=\"166\" y=\"-12.4\" font-family=\"Times,serif\" font-size=\"14.00\">leaf=&#45;0.220049</text>\n",
"</g>\n",
"<!-- 0&#45;&gt;2 -->\n",
"<g id=\"edge4\" class=\"edge\"><title>0&#45;&gt;2</title>\n",
"<path fill=\"none\" stroke=\"#ff0000\" d=\"M135.981,-95.3183C142.97,-77.5517 149.997,-59.6864 155.493,-45.712\"/>\n",
"<polygon fill=\"#ff0000\" stroke=\"#ff0000\" points=\"158.799,-46.8684 159.203,-36.2813 152.285,-44.3061 158.799,-46.8684\"/>\n",
"<text text-anchor=\"middle\" x=\"159\" y=\"-57.4\" font-family=\"Times,serif\" font-size=\"14.00\">no</text>\n",
"</g>\n",
"</g>\n",
"</svg>\n"
],
"text/plain": [
"<graphviz.dot.Digraph at 0x103125d50>"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"xgb.to_graphviz(bst)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.9"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment