text `gp_minimize`结果问题的示例

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了text `gp_minimize`结果问题的示例相关的知识,希望对你有一定的参考价值。

{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-04-29T09:15:21.945886Z",
     "start_time": "2018-04-29T09:15:21.586972Z"
    }
   },
   "outputs": [],
   "source": [
    "from skopt import gp_minimize\n",
    "from skopt.space import Integer"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-04-29T09:15:21.951330Z",
     "start_time": "2018-04-29T09:15:21.948290Z"
    }
   },
   "outputs": [],
   "source": [
    "def obj_fun(x):\n",
    "    return 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-04-29T09:15:21.967865Z",
     "start_time": "2018-04-29T09:15:21.953400Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[Integer(low=-2.0, high=2.0)]"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dimensions = [Integer(low=-2.0, high=2.0, name=\"Foobar\")]\n",
    "dimensions"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-04-29T09:15:22.060883Z",
     "start_time": "2018-04-29T09:15:21.969834Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "          fun: 1\n",
       "    func_vals: array([1])\n",
       "       models: [GaussianProcessRegressor(alpha=1e-10, copy_X_train=True,\n",
       "             kernel=1**2 * Matern(length_scale=1, nu=2.5) + WhiteKernel(noise_level=1),\n",
       "             n_restarts_optimizer=2, noise='gaussian', normalize_y=True,\n",
       "             optimizer='fmin_l_bfgs_b', random_state=1854753297)]\n",
       " random_state: <mtrand.RandomState object at 0x7f7df40d0b40>\n",
       "        space: Space([Integer(low=-2.0, high=2.0)])\n",
       "        specs: {'function': 'base_minimize', 'args': {'n_restarts_optimizer': 5, 'y0': None, 'base_estimator': GaussianProcessRegressor(alpha=1e-10, copy_X_train=True,\n",
       "             kernel=1**2 * Matern(length_scale=1, nu=2.5),\n",
       "             n_restarts_optimizer=2, noise='gaussian', normalize_y=True,\n",
       "             optimizer='fmin_l_bfgs_b', random_state=1854753297), 'n_jobs': 1, 'func': <function obj_fun at 0x7f7dc8413158>, 'random_state': <mtrand.RandomState object at 0x7f7df40d0b40>, 'callback': None, 'xi': 0.01, 'n_random_starts': 1, 'dimensions': Space([Integer(low=-2.0, high=2.0)]), 'verbose': False, 'n_calls': 1, 'kappa': 1.96, 'acq_func': 'gp_hedge', 'x0': None, 'acq_optimizer': 'auto', 'n_points': 10000}}\n",
       "            x: [-1]\n",
       "      x_iters: [[-1]]"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "res = gp_minimize(obj_fun,\n",
    "                  dimensions,\n",
    "                  n_calls=1,\n",
    "                  n_random_starts=1)\n",
    "res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2018-04-29T09:15:22.168280Z",
     "start_time": "2018-04-29T09:15:22.062777Z"
    }
   },
   "outputs": [
    {
     "ename": "AssertionError",
     "evalue": "",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mAssertionError\u001b[0m                            Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-5-64e1417ccabc>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32massert\u001b[0m \u001b[0mres\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m\"specs\"\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m\"args\"\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m\"dimensions\"\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdimensions\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mname\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0;34m\"Foobar\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[0;31mAssertionError\u001b[0m: "
     ]
    }
   ],
   "source": [
    "assert res[\"specs\"][\"args\"][\"dimensions\"].dimensions[0].name == \"Foobar\""
   ]
  }
 ],
 "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.5.2"
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}

以上是关于text `gp_minimize`结果问题的示例的主要内容,如果未能解决你的问题,请参考以下文章

skopt 的 gp_minimize() 函数引发 ValueError: array must not contain infs or NaNs

jQuery:对 $.each 的结果进行排序

如何将 Android Wifi 扫描结果添加到列表中?

text Qwenny示例问题

text git-consistent示例02 github问题

reStructured Text 中浮动图像的工作示例