<commit_before>{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Tune Visualization"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In order to visualize results, please install `plotly` with the following command:\n",
    "\n",
    "  `pip install plotly`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import os\n",
    "import pandas as pd\n",
    "from ray.tune.visual_utils import load_results_to_df, generate_plotly_dim_dict\n",
    "import plotly\n",
    "import plotly.graph_objs as go\n",
    "plotly.offline.init_notebook_mode(connected=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Specify the directory where all your results are in the variable `RESULTS_DIR`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "RESULTS_DIR = os.path.expanduser(\"~/ray_results\")\n",
    "df = load_results_to_df(RESULTS_DIR)\n",
    "[key for key in df]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Choose the fields you wish to visualize over in `GOOD_FIELDS`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true,
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "GOOD_FIELDS = ['experiment_id',\n",
    "               'num_sgd_iter',\n",
    "               'timesteps_total',\n",
    "               'episode_len_mean',\n",
    "               'episode_reward_mean']\n",
    "\n",
    "visualization_df = df[GOOD_FIELDS]\n",
    "visualization_df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Enjoy.\n",
    "\n",
    "Documentation for this Plotly visualization can be found here: https://plot.ly/python/parallel-coordinates-plot/"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "data = [go.Parcoords(\n",
    "            line = dict(color = 'blue'),\n",
    "            dimensions = [generate_plotly_dim_dict(visualization_df, field) \n",
    "                              for field in visualization_df])\n",
    "]\n",
    "\n",
    "plotly.offline.iplot(data)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
<commit_msg>[tune] Fix Tune ParallelCoordinateViz Notebook  (#1494)<commit_after>{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Tune Visualization"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In order to visualize results, please install `plotly` with the following command:\n",
    "\n",
    "  `pip install plotly`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import os\n",
    "import pandas as pd\n",
    "from ray.tune.visual_utils import load_results_to_df, generate_plotly_dim_dict\n",
    "import plotly\n",
    "import plotly.graph_objs as go\n",
    "plotly.offline.init_notebook_mode(connected=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Specify the directory where all your results are in the variable `RESULTS_DIR`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "RESULTS_DIR = os.path.expanduser(\"~/ray_results\")\n",
    "df = load_results_to_df(RESULTS_DIR)\n",
    "[key for key in df]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Choose the fields you wish to visualize over in `GOOD_FIELDS`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true,
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "GOOD_FIELDS = ['experiment_id',\n",
    "               'num_sgd_iter',\n",
    "               'timesteps_total',\n",
    "               'episode_len_mean',\n",
    "               'episode_reward_mean']\n",
    "\n",
    "visualization_df = df[GOOD_FIELDS]\n",
    "visualization_df = visualization_df.dropna()\n",
    "visualization_df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Enjoy.\n",
    "\n",
    "Documentation for this Plotly visualization can be found here: https://plot.ly/python/parallel-coordinates-plot/"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "data = [go.Parcoords(\n",
    "            line = dict(color = 'blue'),\n",
    "            dimensions = [generate_plotly_dim_dict(visualization_df, field) \n",
    "                              for field in visualization_df])\n",
    "]\n",
    "\n",
    "plotly.offline.iplot(data)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}

{'fraction_non_alphanumeric': 0.19192779291553133, 'fraction_numerical': 0.003746594005449591, 'mean_word_length': 2.51255980861244, 'pattern_counts': {'":': 116, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '932135', 'n_tokens_mistral': 2241, 'n_tokens_neox': 2159, 'n_words': 399}