Skip to content

Commit

Permalink
Remove state.
Browse files Browse the repository at this point in the history
  • Loading branch information
kklein committed Jul 30, 2024
1 parent c9e62c4 commit f581d8a
Showing 1 changed file with 14 additions and 95 deletions.
109 changes: 14 additions & 95 deletions docs/examples/example_onnx.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -113,20 +113,9 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<metalearners.xlearner.XLearner at 0x10e5b9520>"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"from metalearners import XLearner\n",
"from lightgbm import LGBMRegressor, LGBMClassifier\n",
Expand Down Expand Up @@ -172,22 +161,9 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'propensity_model': [LGBMClassifier(n_estimators=5, verbose=-1)],\n",
" 'control_effect_model': [LGBMRegressor(n_estimators=5, verbose=-1)],\n",
" 'treatment_effect_model': [LGBMRegressor(n_estimators=5, verbose=-1)]}"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"necessary_models = xlearner._necessary_onnx_models()\n",
"necessary_models"
Expand All @@ -211,19 +187,9 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"The maximum opset needed by this model is only 9.\n",
"The maximum opset needed by this model is only 8.\n",
"The maximum opset needed by this model is only 8.\n"
]
}
],
"outputs": [],
"source": [
"import onnx\n",
"from onnxmltools import convert_lightgbm\n",
Expand Down Expand Up @@ -255,18 +221,9 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/kevinklein/Code/metalearners/metalearners/xlearner.py:463: UserWarning: _build_onnx is an experimental feature. Use it at your own risk!\n",
" warning_experimental_feature(\"_build_onnx\")\n"
]
}
],
"outputs": [],
"source": [
"onnx_model = xlearner._build_onnx(onnx_models)"
]
Expand All @@ -282,47 +239,9 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ONNX model input: [name: \"X\"\n",
"type {\n",
" tensor_type {\n",
" elem_type: 1\n",
" shape {\n",
" dim {\n",
" }\n",
" dim {\n",
" dim_value: 11\n",
" }\n",
" }\n",
" }\n",
"}\n",
"]\n",
"ONNX model output: [name: \"tau\"\n",
"type {\n",
" tensor_type {\n",
" elem_type: 1\n",
" shape {\n",
" dim {\n",
" }\n",
" dim {\n",
" dim_value: 1\n",
" }\n",
" dim {\n",
" dim_value: 1\n",
" }\n",
" }\n",
" }\n",
"}\n",
"]\n"
]
}
],
"outputs": [],
"source": [
"print(\"ONNX model input: \", onnx_model.graph.input)\n",
"print(\"ONNX model output: \", onnx_model.graph.output)"
Expand Down Expand Up @@ -350,7 +269,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -371,7 +290,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -389,7 +308,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down

0 comments on commit f581d8a

Please sign in to comment.