diff --git a/4-Classification/4-Applied/solution/index.html b/4-Classification/4-Applied/solution/index.html index 99d200246..a229e7541 100644 --- a/4-Classification/4-Applied/solution/index.html +++ b/4-Classification/4-Applied/solution/index.html @@ -1,36 +1,105 @@
- ONNX Runtime JavaScript examples: Quick Start - Web (using script tag) + Recipe Matcher
+

Check your refrigerator. What can you create?

+
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+
+ + + - diff --git a/4-Classification/4-Applied/solution/model.onnx b/4-Classification/4-Applied/solution/model.onnx index 591e0c2ba..ee542f4db 100644 Binary files a/4-Classification/4-Applied/solution/model.onnx and b/4-Classification/4-Applied/solution/model.onnx differ diff --git a/4-Classification/4-Applied/solution/notebook.ipynb b/4-Classification/4-Applied/solution/notebook.ipynb index b619dfbfc..14b1a1275 100644 --- a/4-Classification/4-Applied/solution/notebook.ipynb +++ b/4-Classification/4-Applied/solution/notebook.ipynb @@ -31,7 +31,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 25, + "execution_count": 1, "metadata": {}, "outputs": [ { @@ -39,17 +39,17 @@ "name": "stdout", "text": [ "Requirement already satisfied: skl2onnx in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (1.8.0)\n", - "Requirement already satisfied: numpy>=1.15 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from skl2onnx) (1.19.2)\n", - "Requirement already satisfied: onnxconverter-common<1.9,>=1.6.1 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from skl2onnx) (1.8.1)\n", "Requirement already satisfied: protobuf in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from skl2onnx) (3.8.0)\n", - "Requirement already satisfied: scikit-learn>=0.19 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from skl2onnx) (0.24.2)\n", - "Requirement already satisfied: scipy>=1.0 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from skl2onnx) (1.4.1)\n", + "Requirement already satisfied: numpy>=1.15 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from skl2onnx) (1.19.2)\n", "Requirement already satisfied: six in /Users/jenlooper/Library/Python/3.7/lib/python/site-packages (from skl2onnx) (1.12.0)\n", + "Requirement already satisfied: scipy>=1.0 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from skl2onnx) (1.4.1)\n", "Requirement already satisfied: onnx>=1.2.1 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from skl2onnx) (1.9.0)\n", + "Requirement already satisfied: scikit-learn>=0.19 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from skl2onnx) (0.24.2)\n", + "Requirement already satisfied: onnxconverter-common<1.9,>=1.6.1 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from skl2onnx) (1.8.1)\n", "Requirement already satisfied: setuptools in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from protobuf->skl2onnx) (45.1.0)\n", + "Requirement already satisfied: typing-extensions>=3.6.2.1 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from onnx>=1.2.1->skl2onnx) (3.10.0.0)\n", "Requirement already satisfied: joblib>=0.11 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from scikit-learn>=0.19->skl2onnx) (0.16.0)\n", "Requirement already satisfied: threadpoolctl>=2.0.0 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from scikit-learn>=0.19->skl2onnx) (2.1.0)\n", - "Requirement already satisfied: typing-extensions>=3.6.2.1 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from onnx>=1.2.1->skl2onnx) (3.10.0.0)\n", "\u001b[33mWARNING: You are using pip version 20.2.3; however, version 21.1.2 is available.\n", "You should consider upgrading via the '/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7 -m pip install --upgrade pip' command.\u001b[0m\n", "Note: you may need to restart the kernel to use updated packages.\n" @@ -62,7 +62,7 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 2, "metadata": {}, "outputs": [ { @@ -70,9 +70,9 @@ "name": "stdout", "text": [ "Requirement already satisfied: onnxruntime in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (1.8.0)\n", - "Requirement already satisfied: flatbuffers in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from onnxruntime) (2.0)\n", "Requirement already satisfied: protobuf in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from onnxruntime) (3.8.0)\n", "Requirement already satisfied: numpy>=1.16.6 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from onnxruntime) (1.19.2)\n", + "Requirement already satisfied: flatbuffers in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from onnxruntime) (2.0)\n", "Requirement already satisfied: six>=1.9 in /Users/jenlooper/Library/Python/3.7/lib/python/site-packages (from protobuf->onnxruntime) (1.12.0)\n", "Requirement already satisfied: setuptools in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from protobuf->onnxruntime) (45.1.0)\n", "\u001b[33mWARNING: You are using pip version 20.2.3; however, version 21.1.2 is available.\n", @@ -87,7 +87,7 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -97,7 +97,7 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 4, "metadata": {}, "outputs": [ { @@ -130,7 +130,7 @@ "text/html": "
\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
Unnamed: 0cuisinealmondangelicaaniseanise_seedappleapple_brandyapricotarmagnac...whiskeywhite_breadwhite_winewhole_grain_wheat_flourwinewoodyamyeastyogurtzucchini
00indian00000000...0000000000
11indian10000000...0000000000
22indian00000000...0000000000
33indian00000000...0000000000
44indian00000000...0000000010
\n

5 rows × 382 columns

\n
" }, "metadata": {}, - "execution_count": 28 + "execution_count": 4 } ], "source": [ @@ -140,7 +140,7 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": 5, "metadata": {}, "outputs": [ { @@ -173,7 +173,7 @@ "text/html": "
\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
almondangelicaaniseanise_seedappleapple_brandyapricotarmagnacartemisiaartichoke...whiskeywhite_breadwhite_winewhole_grain_wheat_flourwinewoodyamyeastyogurtzucchini
00000000000...0000000000
11000000000...0000000000
20000000000...0000000000
30000000000...0000000000
40000000000...0000000010
\n

5 rows × 380 columns

\n
" }, "metadata": {}, - "execution_count": 29 + "execution_count": 5 } ], "source": [ @@ -183,7 +183,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 6, "metadata": {}, "outputs": [ { @@ -200,7 +200,7 @@ "text/html": "
\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
cuisine
0indian
1indian
2indian
3indian
4indian
\n
" }, "metadata": {}, - "execution_count": 30 + "execution_count": 6 } ], "source": [ @@ -210,7 +210,7 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 7, "metadata": {}, "outputs": [], "source": [ @@ -222,7 +222,7 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 8, "metadata": {}, "outputs": [], "source": [ @@ -231,7 +231,7 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 9, "metadata": {}, "outputs": [ { @@ -242,7 +242,7 @@ ] }, "metadata": {}, - "execution_count": 33 + "execution_count": 9 } ], "source": [ @@ -252,7 +252,7 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 10, "metadata": {}, "outputs": [], "source": [ @@ -261,14 +261,14 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 11, "metadata": {}, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ - " precision recall f1-score support\n\n chinese 0.67 0.68 0.67 243\n indian 0.90 0.87 0.89 238\n japanese 0.75 0.73 0.74 251\n korean 0.84 0.74 0.79 242\n thai 0.74 0.86 0.80 225\n\n accuracy 0.77 1199\n macro avg 0.78 0.78 0.78 1199\nweighted avg 0.78 0.77 0.78 1199\n\n" + " precision recall f1-score support\n\n chinese 0.67 0.70 0.69 232\n indian 0.87 0.89 0.88 252\n japanese 0.80 0.70 0.75 241\n korean 0.83 0.82 0.83 228\n thai 0.76 0.81 0.79 246\n\n accuracy 0.79 1199\n macro avg 0.79 0.79 0.79 1199\nweighted avg 0.79 0.79 0.79 1199\n\n" ] } ], @@ -278,17 +278,17 @@ }, { "cell_type": "code", - "execution_count": 36, + "execution_count": 12, "metadata": {}, "outputs": [], "source": [ "from skl2onnx import convert_sklearn\n", "from skl2onnx.common.data_types import FloatTensorType\n", "\n", - "initial_type = [('float_input', FloatTensorType([None, 10]))]\n", + "initial_type = [('float_input', FloatTensorType([None, 380]))]\n", "options = {id(model): {'nocl': True, 'zipmap': False}}\n", "onx = convert_sklearn(model, initial_types=initial_type,options=options)\n", - "with open(\"./model2.onnx\", \"wb\") as f:\n", + "with open(\"./model.onnx\", \"wb\") as f:\n", " f.write(onx.SerializeToString())\n", "\n", "\n"