Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .hyperspace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
site: summit

num_iters: 20
11 changes: 11 additions & 0 deletions examples/configs/gbm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: gbm

parameters:

max_depth:
low: 2
high: 10

learning_rate:
low: 0.10
high: 1.0
175 changes: 175 additions & 0 deletions examples/notebooks/parser.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"from hyperspace.api.config import ModelConfig\n",
"from hyperspace.internal.parser import Parser"
]
},
{
"cell_type": "code",
"execution_count": 63,
"metadata": {},
"outputs": [],
"source": [
"test0 = \"{'a': 1, 'b': 2, 'c': {'d': 3}}\"\n",
"test1 = \"{x: {y: !param xxx}}\"\n",
"test2 = \"\"\"{\n",
" param0: {low: 0., high: 10},\n",
" param1: {low: 11, high: 20.},\n",
" param3: [one, two, three]\n",
"}\"\"\"\n"
]
},
{
"cell_type": "code",
"execution_count": 64,
"metadata": {},
"outputs": [],
"source": [
"Parser.register()"
]
},
{
"cell_type": "code",
"execution_count": 65,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'a': 1, 'b': 2, 'c': {'d': 3}}"
]
},
"execution_count": 65,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Parser.parse(test0)"
]
},
{
"cell_type": "code",
"execution_count": 66,
"metadata": {},
"outputs": [],
"source": [
"out = Parser.parse(test1)"
]
},
{
"cell_type": "code",
"execution_count": 67,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Parameter(name=xxx)"
]
},
"execution_count": 67,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"out['x']['y']"
]
},
{
"cell_type": "code",
"execution_count": 68,
"metadata": {},
"outputs": [],
"source": [
"params = Parser.parse(test2)"
]
},
{
"cell_type": "code",
"execution_count": 70,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'param0': {'low': 0.0, 'high': 10},\n",
" 'param1': {'low': 11, 'high': 20.0},\n",
" 'param3': ['one', 'two', 'three']}"
]
},
"execution_count": 70,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"params"
]
},
{
"cell_type": "code",
"execution_count": 74,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"value: 0.0, type: <class 'float'>\n",
"value: 10, type: <class 'int'>\n",
"value: 11, type: <class 'int'>\n",
"value: 20.0, type: <class 'float'>\n",
"value: one, type: <class 'str'>\n",
"value: two, type: <class 'str'>\n",
"value: three, type: <class 'str'>\n"
]
}
],
"source": [
"for _, v in params.items():\n",
" if isinstance(v, dict):\n",
" for _, value in v.items():\n",
" print(f'value: {value}, type: {type(value)}')\n",
" else:\n",
" for value in v:\n",
" print(f'value: {value}, type: {type(value)}')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"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.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading