{"id":1036,"date":"2020-06-25T07:03:08","date_gmt":"2020-06-25T00:03:08","guid":{"rendered":"http:\/\/www.miai.vn\/?p=1036"},"modified":"2020-06-25T07:03:08","modified_gmt":"2020-06-25T00:03:08","slug":"oanh-gia-model-ai-theo-cach-mi-an-lien-chuong-3-thuc-hanh-voi-python","status":"publish","type":"post","link":"https:\/\/miai.vn\/?p=1036","title":{"rendered":"\u201cO\u00e1nh gi\u00e1\u201d model AI theo c\u00e1ch M\u00ec \u0103n li\u1ec1n \u2013 Ch\u01b0\u01a1ng 3. Th\u1ef1c h\u00e0nh v\u1edbi Python"},"content":{"rendered":"\n<p>Xin ch\u00e0o c\u00e1c member M\u00ec AI, h\u00f4m nay ch\u00fang ta c\u00f9ng \u0111i ti\u1ebfp series \u201cO\u00e1nh gi\u00e1\u201d model AI theo c\u00e1ch M\u00ec \u0103n li\u1ec1n v\u1edbi m\u1ed9t b\u00e0i th\u1ef1c h\u00e0nh \u0111\u00e1nh gi\u00e1 model b\u1eb1ng Python.<\/p>\n\n\n\n<p>Trong 2 b\u00e0i tr\u01b0\u1edbc trong series ch\u00fang ta \u0111\u00e3 l\u00e0m quen v\u1edbi c\u00e1c kh\u00e1i  ni\u1ec7m Loss, Accuracy, Precision, Recall, F1 Score. B\u1ea1n n\u00e0o ch\u01b0a \u0111\u1ecdc c\u00f3 th\u1ec3 \u0111\u1ecdc t\u1ea1i \u0111\u00e2y:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a aria-label=\"undefined (opens in a new tab)\" href=\"https:\/\/www.miai.vn\/2020\/06\/12\/oanh-gia-model-ai-theo-cach-mi-an-lien-chuong-1-loss-va-accuracy\/\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>\u201cO\u00e1nh gi\u00e1\u201d model AI theo c\u00e1ch M\u00ec \u0103n li\u1ec1n \u2013 Ch\u01b0\u01a1ng 1. Loss v\u00e0 Accuracy<\/strong><\/a><\/li><li><a aria-label=\"undefined (opens in a new tab)\" href=\"https:\/\/www.miai.vn\/2020\/06\/16\/oanh-gia-model-ai-theo-cach-mi-an-lien-chuong-2-precision-recall-va-f-score\/\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>\u201cO\u00e1nh gi\u00e1\u201d model AI theo c\u00e1ch M\u00ec \u0103n li\u1ec1n \u2013 Ch\u01b0\u01a1ng 2. Precision, Recall v\u00e0 F Score<\/strong><\/a><\/li><\/ul>\n\n\n\n<p>Sau khi m\u00ecnh \u0111\u0103ng hai b\u00e0i n\u00e0y th\u00ec c\u00e1c b\u1ea1n c\u00f3 comment l\u00e0 kh\u00e1 d\u1ec5 hi\u1ec3u tuy nhi\u00ean v\u1eabn y\u00eau c\u1ea7u c\u00f3 m\u1ed9t b\u00e0i th\u1ef1c h\u00e0nh cho th\u00f4ng h\u1eb3n lu\u00f4n. Do \u0111\u00f3 h\u00f4m nay ch\u00fang ta c\u00f9ng nhau th\u1ef1c h\u00e0nh m\u1ed9t ch\u00fat nha.<\/p>\n\n\n\n<p>Okie, go go go!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Ph\u1ea7n 1 &#8211; L\u1ef1a ch\u1ecdn b\u00e0i to\u00e1n<\/h2>\n\n\n\n<p>Do l\u00e0 \u0111\u1ec3 v\u00ed d\u1ee5 cho c\u00e1c b\u1ea1n hi\u1ec3u n\u00ean ch\u00fang ta s\u1ebd ch\u1ecdn m\u1ed9t b\u00e0i to\u00e1n \u0111\u01a1n gi\u1ea3n th\u00f4i. Sau khi \u0111\u00e3 hi\u1ec3u nguy\u00ean l\u00fd c\u00e1ch l\u00e0m, c\u00e1c b\u1ea1n c\u00f3 th\u1ec3 \u00e1p d\u1ee5ng v\u1edbi b\u00e0i to\u00e1n b\u1ea5t k\u00ec nh\u00e9!<\/p>\n\n\n\n<p>B\u00e0i to\u00e1n h\u00f4m nay ch\u00fang ta l\u00e0m ph\u1ea3i g\u1ecdi l\u00e0 1 b\u00e0i to\u00e1n kinh \u0111i\u1ec3n \u0111\u00f3 l\u00e0 ph\u00e2n lo\u1ea1i hoa lan hay c\u00f2n g\u1ecdi l\u00e0 IRIS Classification. B\u00e0i to\u00e1n n\u1ea7y kinh \u0111i\u1ec3n \u0111\u1ebfn l\u1ed7i Sklearn t\u00edch h\u1ee3p lu\u00f4n data  \u0111\u1ec3 l\u00fac c\u1ea7n d\u00f9ng kh\u1ecfi c\u1ea7n load t\u1eeb b\u00ean ngo\u00e0i. Haha!<\/p>\n\n\n\n<p>B\u00e0i to\u00e1n n\u00e0y ch\u00fang ta s\u1ebd d\u1ef1a v\u00e0o th\u00f4ng tin b\u00f4ng hoa lan \u0111\u1ec3 d\u1ef1 \u0111o\u00e1n t\u00ean lo\u00e0i hoa lan. Ta c\u00f3 d\u1eef li\u1ec7u nh\u01b0 sau:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Input: L\u00e0 4 th\u00f4ng tin v\u1ec1 c\u00e1c b\u00f4ng hoa lan g\u1ed3m: chi\u1ec1u d\u00e0i v\u00e0 r\u1ed9ng c\u1ee7a c\u00e1nh hoa, chi\u1ec1u d\u00e0i v\u00e0 r\u1ed9ng c\u1ee7a \u0111\u00e0i hoa. V\u00ed d\u1ee5 [5.84 3.05 3.76 1.2]<\/li><li>Output: L\u00e0 t\u00ean c\u1ee7a lo\u00e0i hoa lan. C\u00f3 3 lo\u00e0i: 0 &#8211; Setosa, 1-Veriscolour v\u00e0 2-Virginica<\/li><\/ul>\n\n\n\n<ins class=\"adsbygoogle\" style=\"display:block\" data-ad-client=\"ca-pub-5095883280136027\" data-ad-slot=\"7735063137\" data-ad-format=\"auto\" data-full-width-responsive=\"true\"><\/ins>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img decoding=\"async\" src=\"https:\/\/thegoodpython.com\/assets\/images\/iris-species.png\" alt=\"\u0111\u00e1nh gi\u00e1 model\"\/><figcaption>Ngu\u1ed3n: <a href=\"https:\/\/thegoodpython.com\/assets\/images\/iris-species.png\" target=\"_blank\" aria-label=\"undefined (opens in a new tab)\" rel=\"noreferrer noopener nofollow\">T\u1ea1i \u0111\u00e2y<\/a><\/figcaption><\/figure><\/div>\n\n\n\n<p>B\u00e2y gi\u1edd ch\u00fang ta c\u1ea7n train model sao cho khi \u0111\u01b0a v\u00e0o c\u00e1c th\u00f4ng s\u1ed1 b\u00f4ng hoa th\u00ec model s\u1ebd predict ra t\u00ean lo\u00e0i hoa.<\/p>\n\n\n\n<p>B\u00e0i n\u00e0y l\u00e0 b\u00e0i sample, c\u00f3 nhi\u1ec1u c\u00e1ch l\u00e0m nh\u01b0 SVM, KNN, &#8230;. nh\u01b0ng h\u00f4m nay m\u00ecnh s\u1ebd d\u00f9ng h\u1eb3n M\u1ea1ng n\u01a1 ron. L\u00fd do? \u0110\u01a1n gi\u1ea3n v\u00ec m\u00ecnh mu\u1ed1n demo cho c\u00e1c b\u1ea1n c\u00e1ch o\u00e1nh gi\u00e1 model l\u00e0 ch\u00ednh m\u00e0 :D. Gi\u1ea3i b\u00e0i to\u00e1n l\u00e0 ph\u1ee5 th\u00f4i.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Ph\u1ea7n 2 &#8211; Tri\u1ec3n khai b\u00e0i to\u00e1n<\/h2>\n\n\n\n<h5 class=\"wp-block-heading\">Load d\u1eef li\u1ec7u b\u00e0i to\u00e1n<\/h5>\n\n\n\n<p>Nh\u01b0 m\u00ecnh \u0111\u00e3 n\u00f3i, b\u00e0i n\u00e0y kh\u00f4ng c\u1ea7n d\u00f9ng d\u1eef li\u1ec7u ngo\u00e0i. C\u00e1c b\u1ea1n load th\u1eb3ng trong sklearn l\u00e0 okie:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n# import th\u01b0 vi\u1ec7n\nfrom sklearn.datasets import load_iris\n# Th\u1ef1c hi\u1ec7n load d\u1eef li\u1ec7u\niris_data = load_iris() \n\n# In ra 10 input \u0111\u1ea7u ti\u00ean\nprint('First 10 inputs: ')\nprint(iris_data.data&#91;:10])\n# In ra 10 output \u0111\u1ea7u ti\u00ean\nprint('First 10 output (label): ')\nprint(iris_data.target&#91;:10])<\/code><\/pre>\n\n\n\n<p>V\u00e0 ch\u00fang ta s\u1ebd c\u00f3 d\u1eef li\u1ec7u in ra nh\u01b0 sau l\u00e0 chu\u1ea9n r\u1ed3i:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>First 10 inputs: \n&#91;&#91;5.1 3.5 1.4 0.2]\n &#91;4.9 3.  1.4 0.2]\n &#91;4.7 3.2 1.3 0.2]\n &#91;4.6 3.1 1.5 0.2]\n &#91;5.  3.6 1.4 0.2]\n &#91;5.4 3.9 1.7 0.4]\n &#91;4.6 3.4 1.4 0.3]\n &#91;5.  3.4 1.5 0.2]\n &#91;4.4 2.9 1.4 0.2]\n &#91;4.9 3.1 1.5 0.1]]\nFirst 10 output (label): \n&#91;0 0 0 0 0 0 0 0 0 0]<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">Ti\u1ec1n x\u1eed l\u00fd d\u1eef li\u1ec7u v\u00e0 chia d\u1eef li\u1ec7u train, test<\/h5>\n\n\n\n<p>D\u1eef li\u1ec7u \u0111\u00e3 load th\u00e0nh c\u00f4ng, b\u00e2y gi\u1edd ta c\u1ea7n chu\u1ea9n h\u00f3a m\u1ed9t ch\u00fat. \u1ede \u0111\u00e2y output \u0111ang c\u00f3 d\u1ea1ng l\u00e0 0,1,2  v\u00e0 do \u0111\u00f3 ta c\u1ea7n \u0111\u01b0a v\u1ec1 OneHot cho ti\u1ec7n train model v\u1edbi h\u00e0m Softmax:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># G\u00e1n input v\u00e0o bi\u1ebfn X\nX = iris_data.data\n# G\u00e1n output v\u00e0o bi\u1ebfn y \ny = iris_data.target.reshape(-1,1)\n\n# Th\u1ef1c hi\u1ec7n Onehot transform\nencoder = OneHotEncoder(sparse=False)\ny = encoder.fit_transform(y)\nprint(\"Output after transform\")\nprint(y)\n\n# Chia d\u1eef li\u1ec7u train, test v\u1edbi t\u1ef7 l\u1ec7 80% cho train v\u00e0 20% cho test\nX_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.20)<\/code><\/pre>\n\n\n\n<p>V\u00e0 \u0111\u00e2y, d\u1eef li\u1ec7u y &#8211; output \u0111\u00e3 \u0111\u01b0\u1ee3c transform th\u00e0nh One hot vector:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Output after transform\n&#91;&#91;1. 0. 0.]\n &#91;1. 0. 0.]\n &#91;1. 0. 0.]\n &#91;1. 0. 0.]\n &#91;1. 0. 0.]\n &#91;1. 0. 0.]\n &#91;1. 0. 0.]\n &#91;1. 0. 0.]\n &#91;1. 0. 0.]\n &#91;1. 0. 0.]]<\/code><\/pre>\n\n\n\n<ins class=\"adsbygoogle\" style=\"display:block\" data-ad-client=\"ca-pub-5095883280136027\" data-ad-slot=\"7735063137\" data-ad-format=\"auto\" data-full-width-responsive=\"true\"><\/ins>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script>\n\n\n\n<h5 class=\"wp-block-heading\">C\u00e0i \u0111\u1eb7t m\u1ea1ng N\u01a1 ron<\/h5>\n\n\n\n<p>M\u1ecdi th\u1ee9 \u0111\u00e3 s\u1eb5n s\u00e0ng b\u00e2y gi\u1edd ch\u00fang ta s\u1ebd c\u00e0i \u0111\u1eb7t m\u1ea1ng NN th\u1eed nh\u00e9. \u0110\u1ec3 \u0111\u01a1n gi\u1ea3n h\u00f3a m\u00ecnh s\u1ebd d\u00f9ng m\u1ed9t m\u1ea1ng \u0111\u01a1n gi\u1ea3n v\u1edbi v\u00e0i l\u1edbp th\u00f4i:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Khai b\u00e1o model\nmodel = Sequential()\n\nmodel.add(Dense(128, input_shape=(4,), activation='relu', name='layer1'))\nmodel.add(Dense(128, activation='relu', name='layer2'))\nmodel.add(Dense(3, activation='softmax', name='output'))\n\n# C\u00e0i \u0111\u1eb7t h\u00e0m t\u1ed1i \u01b0u Adam \noptimizer = Adam()\nmodel.compile(optimizer, loss='categorical_crossentropy', metrics=&#91;'accuracy'])\n\n# In c\u1ea5u tr\u00fac m\u1ea1ng ra m\u00e0n h\u00ecnh\nprint('Detail of network: ')\nprint(model.summary())<\/code><\/pre>\n\n\n\n<p>V\u00e0 \u0111\u00e2y l\u00e0 k\u1ebft qu\u1ea3 tr\u00ean m\u00e0n h\u00ecnh<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Detail of network: \nModel: \"sequential_1\"\n_________________________________________________________________\nLayer (type)                 Output Shape              Param #   \n=================================================================\nlayer1 (Dense)               (None, 128)               640       \n_________________________________________________________________\nlayer2 (Dense)               (None, 128)               16512     \n_________________________________________________________________\noutput (Dense)               (None, 3)                 387       \n=================================================================\nTotal params: 17,539\nTrainable params: 17,539\nNon-trainable params: 0\n_________________________________________________________________\nNone<\/code><\/pre>\n\n\n\n<p>\u0110\u1ec3 \u00fd c\u00e1c b\u1ea1n s\u1ebd th\u1ea5y m\u1ea5y th\u00f4ng s\u1ed1 hay ho:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>C\u1ed9t Param# l\u00e0 s\u1ed1 tham s\u1ed1 c\u1ee7a m\u1ed7i layer.<\/li><li>\u1ede d\u01b0\u1edbi c\u00f9ng l\u00e0 c\u00f3 t\u1ed5ng s\u1ed1 tham s\u1ed1 c\u1ea7n train c\u1ee7a model l\u00e0 17,539.<\/li><li>H\u00e0m loss \u1edf \u0111\u00e2y l\u00e0 categorical_crossentropy (\u0111\u00e3 n\u00f3i \u1edf b\u00e0i Loss)<\/li><\/ul>\n\n\n\n<h5 class=\"wp-block-heading\">Train model v\u00e0 evaluate tr\u00ean t\u1eadp test<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code># Train model\nmodel.fit(X_train, y_train, batch_size=32, epochs=10)\n\n# Ki\u1ec3m tra tr\u00ean t\u1eadp test\nresults = model.evaluate(X_test, y_test)\n\nprint('Test loss: {:4f}'.format(results&#91;0]))\nprint('Test accuracy: {:4f}'.format(results&#91;1]))<\/code><\/pre>\n\n\n\n<p>M\u00ecnh train v\u1edbi batch_size=32 v\u00e0 10 epochs nh\u01b0ng k\u1ebft qu\u1ea3 kh\u00e1 t\u1ed1t v\u1edbi Test Loss l\u00e0 0.263 v\u00e0 Test Accuracy l\u00e0 0.9666<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Epoch 1\/10\n120\/120 &#91;==============================] - 0s 159us\/step - loss: 0.3818 - accuracy: 0.9833\nEpoch 2\/10\n120\/120 &#91;==============================] - 0s 139us\/step - loss: 0.3555 - accuracy: 0.9833\nEpoch 3\/10\n120\/120 &#91;==============================] - 0s 133us\/step - loss: 0.3323 - accuracy: 0.9583\nEpoch 4\/10\n120\/120 &#91;==============================] - 0s 122us\/step - loss: 0.3092 - accuracy: 0.9583\nEpoch 5\/10\n120\/120 &#91;==============================] - 0s 124us\/step - loss: 0.2900 - accuracy: 0.9750\nEpoch 6\/10\n120\/120 &#91;==============================] - 0s 126us\/step - loss: 0.2712 - accuracy: 0.9833\nEpoch 7\/10\n120\/120 &#91;==============================] - 0s 120us\/step - loss: 0.2543 - accuracy: 0.9750\nEpoch 8\/10\n120\/120 &#91;==============================] - 0s 119us\/step - loss: 0.2424 - accuracy: 0.9833\nEpoch 9\/10\n120\/120 &#91;==============================] - 0s 129us\/step - loss: 0.2289 - accuracy: 0.9667\nEpoch 10\/10\n120\/120 &#91;==============================] - 0s 117us\/step - loss: 0.2065 - accuracy: 0.9833\n30\/30 &#91;==============================] - 0s 1ms\/step\nTest loss: 0.263040\nTest accuracy: 0.966667<\/code><\/pre>\n\n\n\n<p>Nh\u01b0 v\u1eady l\u00e0 b\u00e0i to\u00e1n c\u1ee7a ch\u00fang ta \u0111\u00e3 xong v\u1ec1 m\u1eb7t tri\u1ec3n khai. Nh\u01b0ng nh\u01b0 v\u1eady th\u00ec c\u1ee5t qu\u00e1 nh\u1edf. Ch\u00fang ta h\u00e3y th\u00eam th\u1eaft t\u00fd cho n\u00f3 phong ph\u00fa \u0111a d\u1ea1ng nh\u1edf. \u0110i ti\u1ebfp nh\u00e9!<\/p>\n\n\n\n<ins class=\"adsbygoogle\" style=\"display:block\" data-ad-client=\"ca-pub-5095883280136027\" data-ad-slot=\"7735063137\" data-ad-format=\"auto\" data-full-width-responsive=\"true\"><\/ins>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script>\n\n\n\n<h2 class=\"wp-block-heading\">Ph\u1ea7n 3 &#8211; \u0110\u00e1nh gi\u00e1 model qua Graph v\u00e0 c\u00e1c th\u00f4ng s\u1ed1 Precision , Recall v\u00e0 F Score<\/h2>\n\n\n\n<h5 class=\"wp-block-heading\">V\u1ebd \u0111\u1ed3 th\u1ecb loss v\u00e0 accuracy<\/h5>\n\n\n\n<p>B\u00e2y gi\u1edd vi\u1ec7c \u0111\u1ea7u ti\u00ean l\u00e0 ta s\u1ebd in ra \u0111\u1ed3 th\u1ecb Loss v\u00e0 Accuracy nh\u00e9. \u0110\u1ec3 l\u00e0m vi\u1ec7c \u0111\u00f3 m\u00ecnh t\u0103ng s\u1ed1 epoch l\u00ean 200 cho \u0111\u1ed3 th\u1ecb n\u00f3 \u0111\u1eb9p:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Train model\nimport matplotlib.pyplot as pyplot\nhistory = model.fit(X_train, y_train, batch_size=32, epochs=200,validation_data=(X_test,y_test))\n\n# plot loss v\u00e0 accuracy\npyplot.figure(figsize=(20,10))\npyplot.subplot(211)\npyplot.title('Loss')\npyplot.plot(history.history&#91;'loss'], label='train')\npyplot.plot(history.history&#91;'val_loss'], label='test')\npyplot.legend()\n# plot accuracy during training\npyplot.subplot(212)\npyplot.title('Accuracy')\npyplot.plot(history.history&#91;'accuracy'], label='train')\npyplot.plot(history.history&#91;'val_accuracy'], label='test')\npyplot.legend()\npyplot.show()<\/code><\/pre>\n\n\n\n<p>V\u00e0 \u0111\u00e2y l\u00e0 \u0111\u1ed3 th\u1ecb n\u00e0y! Nh\u00ecn c\u00f3 v\u1ebb chuy\u1ec3n nghi\u1ec7p v\u00ea l\u1edd anh em nh\u1edf =)). Ch\u00fang ta ko b\u00e0n v\u1ec1 \u0111\u1ed9 ch\u00ednh x\u00e1c c\u1ee7a model nh\u00e9, th\u1ef1c h\u00e0nh c\u00e1ch \u0111\u00e1nh gi\u00e1 th\u00f4i \ud83d\ude42<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/github.com\/thangnch\/MiAI_Model_-Evaluate\/blob\/master\/download.png?raw=true\" alt=\"\u0111\u00e1nh gi\u00e1 model\"\/><\/figure>\n\n\n\n<h5 class=\"wp-block-heading\">T\u00ednh to\u00e1n Confusion Matirix, Precision, Recall v\u00e0 F1-Score<\/h5>\n\n\n\n<p>R\u1ed3i nh\u01b0 v\u1eady l\u00e0 loss v\u00e0 acc \u0111\u00e3 xong, b\u00e2y gi\u1edd t\u00ednh m\u1ea5y c\u00e1i m\u00f3n n\u00e0y cho n\u00f3 c\u00f3 v\u1ebb p\u1edd r\u1ed3 n\u00e0o.<\/p>\n\n\n\n<p>M\u00ecnh n\u00f3i c\u00f3 v\u1ebb pro v\u00ec th\u01b0 vi\u1ec7n sklearn \u0111\u00e3 h\u1ed7 tr\u1ee3 kh\u00e1 t\u1ed1t r\u1ed3i, anh em ch\u1ec9 c\u1ea7n g\u1ecdi ra cho \u0111\u00fang l\u00e0 okie. Anh em n\u00e0o c\u1ea7n t\u00ecm hi\u1ec3u chi ti\u1ebft c\u00e1c h\u00e0m th\u00ec c\u00f3 \u0111\u00e2y lu\u00f4n: <strong><a href=\"http:\/\/scikit-learn.org\/stable\/modules\/model_evaluation.html\" target=\"_blank\" aria-label=\"undefined (opens in a new tab)\" rel=\"noreferrer noopener\">t\u1ea1i \u0111\u00e2y<\/a><\/strong>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from sklearn.metrics import accuracy_score\nfrom sklearn.metrics import precision_score\nfrom sklearn.metrics import recall_score\nfrom sklearn.metrics import f1_score\nfrom sklearn.metrics import roc_auc_score\nfrom sklearn.metrics import confusion_matrix<\/code><\/pre>\n\n\n\n<ins class=\"adsbygoogle\" style=\"display:block\" data-ad-client=\"ca-pub-5095883280136027\" data-ad-slot=\"7735063137\" data-ad-format=\"auto\" data-full-width-responsive=\"true\"><\/ins>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script>\n\n\n\n<p>\u0110\u00f3, th\u01b0 vi\u1ec7n t\u1eadn r\u0103ng v\u00e0 b\u00e2y gi\u1edd l\u00e0 g\u1ecdi :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>y_hat = model.predict(X_test)\ny_pred = np.argmax(y_hat, axis=1)\ny_test_label =  np.argmax(y_test, axis=1)\n\n\n# T\u00ednh accuracy: (tp + tn) \/ (p + n)\naccuracy = accuracy_score(y_test_label, y_pred)\nprint('Accuracy: %f' % accuracy)\n# T\u00ednh precision tp \/ (tp + fp)\nprecision = precision_score(y_test_label, y_pred, average='macro')\nprint('Precision: %f' % precision)\n# T\u00ednh recall: tp \/ (tp + fn)\nrecall = recall_score(y_test_label, y_pred, average='macro')\nprint('Recall: %f' % recall)\n# T\u00ednh f1: 2 tp \/ (2 tp + fp + fn)\nf1 = f1_score(y_test_label, y_pred, average='macro')\nprint('F1 score: %f' % f1)\n# T\u00ednh Area under ROC\nauc = roc_auc_score(y_test, y_hat, multi_class='ovr')\nprint('ROC AUC: %f' % auc)\n# T\u00ednh confusion matrix\nmatrix = confusion_matrix(y_test_label, y_pred)\nprint(matrix)<\/code><\/pre>\n\n\n\n<p>\u0110o\u1ea1n source tr\u00ean anh em ch\u00fa \u00fd m\u1ea5y \u0111i\u1ec3m sau:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>H\u00e0m t\u00ednh Acc, Precision, Recall v\u00e0 F1 m\u00ecnh d\u00f9ng ph\u01b0\u01a1ng ph\u00e1p trung b\u00ecnh macro nh\u00e9. N\u1ebfu anh em ko c\u00f3 tham s\u1ed1 n\u00e0y n\u00f3 s\u1ebd phun ra c\u1ea3 1 m\u1ea3ng v\u1edbi m\u1ed7i ph\u1ea7n t\u1eed l\u00e0 gi\u00e1 tr\u1ecb cho 1 class. (one -vs-rest v\u00ec b\u00e0i to\u00e1n l\u00e0 multi classs)<\/li><li>H\u00e0m roc_auc_score m\u00ecnh c\u0169ng th\u00eam multi_class = &#8216;ovr&#8217; l\u00e0 One-vs-rest \u0111\u1ec3 n\u00f3 hi\u1ec3u. <\/li><\/ul>\n\n\n\n<p>V\u00e0 k\u1ebft qu\u1ea3 ngon l\u00e0nh cho anh em:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Accuracy: 0.933333\nPrecision: 0.944444\nRecall: 0.939394\nF1 score: 0.936364\nROC AUC: 0.993477\n&#91;&#91; 9  0  0]\n &#91; 0  9  2]\n &#91; 0  0 10]]<\/code><\/pre>\n\n\n\n<p>\u0110\u1ebfn b\u01b0\u1edbc n\u00e0y anh em l\u1ea1i th\u1ea5y r\u1eb1ng c\u00e1i Confusion matrix c\u00f3 v\u1ebb ch\u01b0a clear l\u1eafm, nh\u00ecn nh\u01b0 n\u00e0y th\u00ec ai bi\u1ebft ph\u00e1n nh\u01b0 n\u00e0o. Okie! Ta l\u1ea1i v\u1ebd n\u00f3 ra cho tr\u1ef1c quan:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import pandas as pd\nimport seaborn as sn\ndf_cm = pd.DataFrame(matrix, index = &#91;i for i in \"012\"],\n                  columns = &#91;i for i in \"012\"])\npyplot.figure(figsize = (10,7))\nsn.heatmap(df_cm, annot=True)<\/code><\/pre>\n\n\n\n<p>\u1ede \u0111\u00e2y ta d\u00f9ng th\u01b0 vi\u1ec7n pandas v\u00e0 searborn \u0111\u1ec3 v\u1ebd \u0111\u1ed3 th\u1ecb Heatmap v\u00e0 k\u1ebft qu\u1ea3 \u0111\u00e2y r\u1ed3i:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/github.com\/thangnch\/MiAI_Model_-Evaluate\/blob\/master\/heatmap.png?raw=true\" alt=\"\u0111\u00e1nh gi\u00e1 model\"\/><\/figure>\n\n\n\n<p>R\u1ed3i b\u00e2y gi\u1edd th\u00ec r\u00f5 nh\u01b0 ban ng\u00e0y v\u00e0 ph\u00e1n th\u00f4i nh\u1ec9?<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>C\u00f3 t\u1ea5t c\u1ea3 9 m\u1eabu s\u1ed1 0 v\u00e0 \u0111\u01b0\u1ee3c predict \u0111\u00fang h\u1ebft v\u00e0o class 0. Ngon!<\/li><li>C\u00f3 t\u1ea5t c\u1ea3 11 m\u1eabu s\u1ed1 1 v\u00e0 \u0111\u01b0\u1ee3c predict \u0111\u00fang 9 m\u1eabu v\u00e0o class 1 v\u00e0 2 m\u1eabu b\u1ecb sai (predict v\u00e0o class 2)<\/li><li>T\u01b0\u01a1ng t\u1ef1, c\u00f3 10 m\u1eabu s\u1ed1 2 v\u00e0 predict \u0111\u00fang c\u1ea3 \ud83d\ude00<\/li><\/ul>\n\n\n\n<p>K\u1ebft lu\u1eadn, model ngon l\u00e0nh kaka!<\/p>\n\n\n\n<p>V\u00e0 do b\u1ea1n \u0111\u00e3 ki\u00ean nh\u1eabn \u0111\u1ecdc \u0111\u1ebfn cu\u1ed1i b\u00e0i n\u00ean qu\u00e0 t\u1eb7ng m\u00ecnh d\u00e0nh cho b\u1ea1n l\u00e0 source m\u00ecnh \u0111\u00e3 code s\u1eb5n <strong><a aria-label=\"undefined (opens in a new tab)\" href=\"https:\/\/github.com\/thangnch\/MiAI_Model_Evaluate\" target=\"_blank\" rel=\"noreferrer noopener\">t\u1ea1i \u0111\u00e2y<\/a><\/strong>. C\u00e1c b\u1ea1n c\u00f3 th\u1ec3 t\u1ea3i v\u1ec1 v\u00e0 th\u1eed lu\u00f4n nh\u00e9.<\/p>\n\n\n\n<ins class=\"adsbygoogle\" style=\"display:block\" data-ad-client=\"ca-pub-5095883280136027\" data-ad-slot=\"7735063137\" data-ad-format=\"auto\" data-full-width-responsive=\"true\"><\/ins>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script>\n\n\n\n<p>Okie, v\u1eady l\u00e0 m\u00ecnh \u0111\u00e3 guide c\u00e1c b\u1ea1n c\u00e1ch tri\u1ec3n khai \u0111\u00e1nh gi\u00e1 model ph\u00e2n lo\u1ea1i classify theo c\u00e1c m\u00f3n Loss, Acc, Pre, Recall, Confusion Matrix&#8230;. <\/p>\n\n\n\n<p>M\u00ecnh xin d\u1eebng b\u00e0i n\u00e0y l\u1ea1i \u0111\u00e2y. H\u1eb9n g\u1eb7p l\u1ea1i c\u00e1c b\u1ea1n trong c\u00e1c b\u00e0i ti\u1ebfp theo nh\u00e9!<\/p>\n\n\n\n<p><strong><em>H\u00e3y join c\u00f9ng c\u1ed9ng \u0111\u1ed3ng M\u00ec AI nh\u00e9!<\/em><\/strong><\/p>\n\n\n\n<p>Fanpage:&nbsp;<a rel=\"noreferrer noopener\" href=\"http:\/\/facebook.com\/miaiblog\" target=\"_blank\">http:\/\/facebook.com\/miaiblog<\/a><br>Group trao \u0111\u1ed5i, chia s\u1ebb:&nbsp;<a rel=\"noreferrer noopener\" href=\"https:\/\/www.facebook.com\/groups\/miaigroup\" target=\"_blank\">https:\/\/www.facebook.com\/groups\/miaigroup<\/a><br>Website:&nbsp;<a href=\"https:\/\/miai.vn\/\">https:\/\/miai.vn\/<\/a><br>Youtube:&nbsp;<a rel=\"noreferrer noopener\" href=\"http:\/\/bit.ly\/miaiyoutube\" target=\"_blank\">http:\/\/bit.ly\/miaiyoutube<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Xin ch\u00e0o c\u00e1c member M\u00ec AI, h\u00f4m nay ch\u00fang ta c\u00f9ng \u0111i ti\u1ebfp series \u201cO\u00e1nh gi\u00e1\u201d model AI theo c\u00e1ch M\u00ec \u0103n li\u1ec1n v\u1edbi m\u1ed9t b\u00e0i th\u1ef1c h\u00e0nh \u0111\u00e1nh gi\u00e1 model b\u1eb1ng Python. Trong 2 b\u00e0i tr\u01b0\u1edbc trong series ch\u00fang ta \u0111\u00e3 l\u00e0m quen v\u1edbi c\u00e1c kh\u00e1i ni\u1ec7m Loss, Accuracy, Precision, Recall, F1 Score. B\u1ea1n [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[302,310,311,304,312,305,306,307,136,308,309,313],"class_list":["post-1036","post","type-post","status-publish","format-standard","hentry","category-basic","tag-accuracy","tag-area-under-the-curve","tag-auc","tag-do-chinh-xac","tag-f1-score","tag-ham-loss","tag-loss","tag-loss-va-accuracy","tag-model","tag-precision","tag-recall","tag-roc"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Th\u1ef1c h\u00e0nh \u0111\u00e1nh gi\u00e1 model v\u1edbi Loss, Accuracy, Precision, Recall - M\u00ec AI<\/title>\n<meta name=\"description\" content=\"Xin ch\u00e0o c\u00e1c member M\u00ec AI, h\u00f4m nay ch\u00fang ta c\u00f9ng \u0111i ti\u1ebfp series \u201cO\u00e1nh gi\u00e1\u201d model AI theo c\u00e1ch M\u00ec \u0103n li\u1ec1n v\u1edbi m\u1ed9t b\u00e0i th\u1ef1c h\u00e0nh \u0111\u00e1nh gi\u00e1 model b\u1eb1ng Python.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/miai.vn\/?p=1036\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Th\u1ef1c h\u00e0nh \u0111\u00e1nh gi\u00e1 model v\u1edbi Loss, Accuracy, Precision, Recall - M\u00ec AI\" \/>\n<meta property=\"og:description\" content=\"Xin ch\u00e0o c\u00e1c member M\u00ec AI, h\u00f4m nay ch\u00fang ta c\u00f9ng \u0111i ti\u1ebfp series \u201cO\u00e1nh gi\u00e1\u201d model AI theo c\u00e1ch M\u00ec \u0103n li\u1ec1n v\u1edbi m\u1ed9t b\u00e0i th\u1ef1c h\u00e0nh \u0111\u00e1nh gi\u00e1 model b\u1eb1ng Python.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/miai.vn\/?p=1036\" \/>\n<meta property=\"og:site_name\" content=\"M\u00ec AI\" \/>\n<meta property=\"article:published_time\" content=\"2020-06-25T00:03:08+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/thegoodpython.com\/assets\/images\/iris-species.png\" \/>\n<meta name=\"author\" content=\"Ch\u1ee7 ti\u1ec7m M\u00ec\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ch\u1ee7 ti\u1ec7m M\u00ec\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"11 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/miai.vn\\\/?p=1036#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/miai.vn\\\/?p=1036\"},\"author\":{\"name\":\"Ch\u1ee7 ti\u1ec7m M\u00ec\",\"@id\":\"https:\\\/\\\/miai.vn\\\/#\\\/schema\\\/person\\\/cc8bc24bb90bd3f596add82f3a59948c\"},\"headline\":\"\u201cO\u00e1nh gi\u00e1\u201d model AI theo c\u00e1ch M\u00ec \u0103n li\u1ec1n \u2013 Ch\u01b0\u01a1ng 3. Th\u1ef1c h\u00e0nh v\u1edbi Python\",\"datePublished\":\"2020-06-25T00:03:08+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/miai.vn\\\/?p=1036\"},\"wordCount\":1540,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\\\/\\\/miai.vn\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/miai.vn\\\/?p=1036#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/thegoodpython.com\\\/assets\\\/images\\\/iris-species.png\",\"keywords\":[\"accuracy\",\"Area Under The Curve\",\"AUC\",\"\u0111\u1ed9 ch\u00ednh x\u00e1c\",\"F1 score\",\"h\u00e0m loss\",\"loss\",\"loss v\u00e0 accuracy\",\"model\",\"precision\",\"recall\",\"ROC\"],\"articleSection\":[\"Basic\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/miai.vn\\\/?p=1036#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/miai.vn\\\/?p=1036\",\"url\":\"https:\\\/\\\/miai.vn\\\/?p=1036\",\"name\":\"Th\u1ef1c h\u00e0nh \u0111\u00e1nh gi\u00e1 model v\u1edbi Loss, Accuracy, Precision, Recall - M\u00ec AI\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/miai.vn\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/miai.vn\\\/?p=1036#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/miai.vn\\\/?p=1036#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/thegoodpython.com\\\/assets\\\/images\\\/iris-species.png\",\"datePublished\":\"2020-06-25T00:03:08+00:00\",\"description\":\"Xin ch\u00e0o c\u00e1c member M\u00ec AI, h\u00f4m nay ch\u00fang ta c\u00f9ng \u0111i ti\u1ebfp series \u201cO\u00e1nh gi\u00e1\u201d model AI theo c\u00e1ch M\u00ec \u0103n li\u1ec1n v\u1edbi m\u1ed9t b\u00e0i th\u1ef1c h\u00e0nh \u0111\u00e1nh gi\u00e1 model b\u1eb1ng Python.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/miai.vn\\\/?p=1036#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/miai.vn\\\/?p=1036\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/miai.vn\\\/?p=1036#primaryimage\",\"url\":\"https:\\\/\\\/thegoodpython.com\\\/assets\\\/images\\\/iris-species.png\",\"contentUrl\":\"https:\\\/\\\/thegoodpython.com\\\/assets\\\/images\\\/iris-species.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/miai.vn\\\/?p=1036#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/miai.vn\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u201cO\u00e1nh gi\u00e1\u201d model AI theo c\u00e1ch M\u00ec \u0103n li\u1ec1n \u2013 Ch\u01b0\u01a1ng 3. Th\u1ef1c h\u00e0nh v\u1edbi Python\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/miai.vn\\\/#website\",\"url\":\"https:\\\/\\\/miai.vn\\\/\",\"name\":\"M\u00ec AI\",\"description\":\"H\u1ecdc AI theo c\u00e1ch M\u00ec \u0103n li\u1ec1n!\",\"publisher\":{\"@id\":\"https:\\\/\\\/miai.vn\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/miai.vn\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/miai.vn\\\/#organization\",\"name\":\"M\u00ec AI\",\"url\":\"https:\\\/\\\/miai.vn\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/miai.vn\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/miai.vn\\\/wp-content\\\/uploads\\\/2026\\\/05\\\/cropped-Logo_w_slogan.png\",\"contentUrl\":\"https:\\\/\\\/miai.vn\\\/wp-content\\\/uploads\\\/2026\\\/05\\\/cropped-Logo_w_slogan.png\",\"width\":240,\"height\":193,\"caption\":\"M\u00ec AI\"},\"image\":{\"@id\":\"https:\\\/\\\/miai.vn\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/miai.vn\\\/#\\\/schema\\\/person\\\/cc8bc24bb90bd3f596add82f3a59948c\",\"name\":\"Ch\u1ee7 ti\u1ec7m M\u00ec\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b0b5124b0d2c0a8054d7127d2c236bdc3dc7a50e2d4e8728ab32eee5b122a8d1?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b0b5124b0d2c0a8054d7127d2c236bdc3dc7a50e2d4e8728ab32eee5b122a8d1?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b0b5124b0d2c0a8054d7127d2c236bdc3dc7a50e2d4e8728ab32eee5b122a8d1?s=96&d=mm&r=g\",\"caption\":\"Ch\u1ee7 ti\u1ec7m M\u00ec\"},\"sameAs\":[\"https:\\\/\\\/miai.vn\"],\"url\":\"https:\\\/\\\/miai.vn\\\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Th\u1ef1c h\u00e0nh \u0111\u00e1nh gi\u00e1 model v\u1edbi Loss, Accuracy, Precision, Recall - M\u00ec AI","description":"Xin ch\u00e0o c\u00e1c member M\u00ec AI, h\u00f4m nay ch\u00fang ta c\u00f9ng \u0111i ti\u1ebfp series \u201cO\u00e1nh gi\u00e1\u201d model AI theo c\u00e1ch M\u00ec \u0103n li\u1ec1n v\u1edbi m\u1ed9t b\u00e0i th\u1ef1c h\u00e0nh \u0111\u00e1nh gi\u00e1 model b\u1eb1ng Python.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/miai.vn\/?p=1036","og_locale":"en_US","og_type":"article","og_title":"Th\u1ef1c h\u00e0nh \u0111\u00e1nh gi\u00e1 model v\u1edbi Loss, Accuracy, Precision, Recall - M\u00ec AI","og_description":"Xin ch\u00e0o c\u00e1c member M\u00ec AI, h\u00f4m nay ch\u00fang ta c\u00f9ng \u0111i ti\u1ebfp series \u201cO\u00e1nh gi\u00e1\u201d model AI theo c\u00e1ch M\u00ec \u0103n li\u1ec1n v\u1edbi m\u1ed9t b\u00e0i th\u1ef1c h\u00e0nh \u0111\u00e1nh gi\u00e1 model b\u1eb1ng Python.","og_url":"https:\/\/miai.vn\/?p=1036","og_site_name":"M\u00ec AI","article_published_time":"2020-06-25T00:03:08+00:00","og_image":[{"url":"https:\/\/thegoodpython.com\/assets\/images\/iris-species.png","type":"","width":"","height":""}],"author":"Ch\u1ee7 ti\u1ec7m M\u00ec","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Ch\u1ee7 ti\u1ec7m M\u00ec","Est. reading time":"11 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/miai.vn\/?p=1036#article","isPartOf":{"@id":"https:\/\/miai.vn\/?p=1036"},"author":{"name":"Ch\u1ee7 ti\u1ec7m M\u00ec","@id":"https:\/\/miai.vn\/#\/schema\/person\/cc8bc24bb90bd3f596add82f3a59948c"},"headline":"\u201cO\u00e1nh gi\u00e1\u201d model AI theo c\u00e1ch M\u00ec \u0103n li\u1ec1n \u2013 Ch\u01b0\u01a1ng 3. Th\u1ef1c h\u00e0nh v\u1edbi Python","datePublished":"2020-06-25T00:03:08+00:00","mainEntityOfPage":{"@id":"https:\/\/miai.vn\/?p=1036"},"wordCount":1540,"commentCount":2,"publisher":{"@id":"https:\/\/miai.vn\/#organization"},"image":{"@id":"https:\/\/miai.vn\/?p=1036#primaryimage"},"thumbnailUrl":"https:\/\/thegoodpython.com\/assets\/images\/iris-species.png","keywords":["accuracy","Area Under The Curve","AUC","\u0111\u1ed9 ch\u00ednh x\u00e1c","F1 score","h\u00e0m loss","loss","loss v\u00e0 accuracy","model","precision","recall","ROC"],"articleSection":["Basic"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/miai.vn\/?p=1036#respond"]}]},{"@type":"WebPage","@id":"https:\/\/miai.vn\/?p=1036","url":"https:\/\/miai.vn\/?p=1036","name":"Th\u1ef1c h\u00e0nh \u0111\u00e1nh gi\u00e1 model v\u1edbi Loss, Accuracy, Precision, Recall - M\u00ec AI","isPartOf":{"@id":"https:\/\/miai.vn\/#website"},"primaryImageOfPage":{"@id":"https:\/\/miai.vn\/?p=1036#primaryimage"},"image":{"@id":"https:\/\/miai.vn\/?p=1036#primaryimage"},"thumbnailUrl":"https:\/\/thegoodpython.com\/assets\/images\/iris-species.png","datePublished":"2020-06-25T00:03:08+00:00","description":"Xin ch\u00e0o c\u00e1c member M\u00ec AI, h\u00f4m nay ch\u00fang ta c\u00f9ng \u0111i ti\u1ebfp series \u201cO\u00e1nh gi\u00e1\u201d model AI theo c\u00e1ch M\u00ec \u0103n li\u1ec1n v\u1edbi m\u1ed9t b\u00e0i th\u1ef1c h\u00e0nh \u0111\u00e1nh gi\u00e1 model b\u1eb1ng Python.","breadcrumb":{"@id":"https:\/\/miai.vn\/?p=1036#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/miai.vn\/?p=1036"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/miai.vn\/?p=1036#primaryimage","url":"https:\/\/thegoodpython.com\/assets\/images\/iris-species.png","contentUrl":"https:\/\/thegoodpython.com\/assets\/images\/iris-species.png"},{"@type":"BreadcrumbList","@id":"https:\/\/miai.vn\/?p=1036#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/miai.vn\/"},{"@type":"ListItem","position":2,"name":"\u201cO\u00e1nh gi\u00e1\u201d model AI theo c\u00e1ch M\u00ec \u0103n li\u1ec1n \u2013 Ch\u01b0\u01a1ng 3. Th\u1ef1c h\u00e0nh v\u1edbi Python"}]},{"@type":"WebSite","@id":"https:\/\/miai.vn\/#website","url":"https:\/\/miai.vn\/","name":"M\u00ec AI","description":"H\u1ecdc AI theo c\u00e1ch M\u00ec \u0103n li\u1ec1n!","publisher":{"@id":"https:\/\/miai.vn\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/miai.vn\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/miai.vn\/#organization","name":"M\u00ec AI","url":"https:\/\/miai.vn\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/miai.vn\/#\/schema\/logo\/image\/","url":"https:\/\/miai.vn\/wp-content\/uploads\/2026\/05\/cropped-Logo_w_slogan.png","contentUrl":"https:\/\/miai.vn\/wp-content\/uploads\/2026\/05\/cropped-Logo_w_slogan.png","width":240,"height":193,"caption":"M\u00ec AI"},"image":{"@id":"https:\/\/miai.vn\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/miai.vn\/#\/schema\/person\/cc8bc24bb90bd3f596add82f3a59948c","name":"Ch\u1ee7 ti\u1ec7m M\u00ec","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/b0b5124b0d2c0a8054d7127d2c236bdc3dc7a50e2d4e8728ab32eee5b122a8d1?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/b0b5124b0d2c0a8054d7127d2c236bdc3dc7a50e2d4e8728ab32eee5b122a8d1?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/b0b5124b0d2c0a8054d7127d2c236bdc3dc7a50e2d4e8728ab32eee5b122a8d1?s=96&d=mm&r=g","caption":"Ch\u1ee7 ti\u1ec7m M\u00ec"},"sameAs":["https:\/\/miai.vn"],"url":"https:\/\/miai.vn\/?author=1"}]}},"_links":{"self":[{"href":"https:\/\/miai.vn\/index.php?rest_route=\/wp\/v2\/posts\/1036","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/miai.vn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/miai.vn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/miai.vn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/miai.vn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1036"}],"version-history":[{"count":0,"href":"https:\/\/miai.vn\/index.php?rest_route=\/wp\/v2\/posts\/1036\/revisions"}],"wp:attachment":[{"href":"https:\/\/miai.vn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1036"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/miai.vn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1036"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/miai.vn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1036"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}