{"id":340500,"date":"2022-10-31T09:00:42","date_gmt":"2022-10-31T09:00:42","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=340500"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=340500","title":{"rendered":"<span>Multiple Instance Learning (MIL) \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u043d\u0430\u0431\u043e\u0440\u043e\u0432 \u0433\u0438\u0441\u0442\u043e\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0441\u043e \u0441\u0432\u0435\u0442\u043b\u043e\u043a\u043b\u0435\u0442\u043e\u0447\u043d\u044b\u043c \u0440\u0430\u043a\u043e\u043c \u043f\u043e\u0447\u043a\u0438<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/061\/48a\/a7e\/06148aa7e1ef8a3a28f00966088685e6.png\" width=\"906\" height=\"285\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/061\/48a\/a7e\/06148aa7e1ef8a3a28f00966088685e6.png\"\/><figcaption><\/figcaption><\/figure>\n<h2>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0421 \u0443\u0447\u0451\u0442\u043e\u043c \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 Multiple instance learning (\u0434\u0430\u043b\u0435\u0435: MIL) \u0438, \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u043d\u0430\u043b\u0438\u0447\u0438\u044f \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0433\u0438\u0441\u0442\u043e\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439,\u00a0\u0440\u0435\u0448\u0438\u043b \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u0443\u0447\u0438\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0438 \u0441 \u0446\u0435\u043b\u044c\u044e \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u043d\u0430\u0431\u043e\u0440\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u0430 \u0442\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0435 \u0442\u043a\u0430\u043d\u0438 \u0438 \u0442\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u044e\u0442\u0441\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u043e \u0441\u0432\u0435\u0442\u043b\u043e\u043a\u043b\u0435\u0442\u043e\u0447\u043d\u044b\u043c \u0440\u0430\u043a\u043e\u043c \u043f\u043e\u0447\u043a\u0438.<\/p>\n<p><a href=\"https:\/\/github.com\/bluewhale28\/Multiple-Instance-Learning-MIL-with-Keras-using-clear-cell-renal-cell-carcinoma-dataset\" rel=\"noopener noreferrer nofollow\">GitHub &#8212; \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439<\/a><\/p>\n<p>\u0412 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0441\u044f \u043d\u0430 2 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043f\u043e \u0434\u0430\u043d\u043d\u043e\u0439 \u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0435 : <\/p>\n<ol>\n<li>\n<p> \u0418\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f MIL Attention layer \u043d\u0430 Keras &#8212; <a href=\"https:\/\/keras.io\/examples\/vision\/attention_mil_classification\/\" rel=\"noopener noreferrer nofollow\">\u0441\u0441\u044b\u043b\u043a\u0430 <\/a><\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0435\u043a\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 Attention-based Deep Multiple Instance Learning \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0433\u0438\u0441\u0442\u043e\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 &#8212; <a href=\"https:\/\/github.com\/utayao\/Atten_Deep_MIL\" rel=\"noopener noreferrer nofollow\">github <\/a><\/p>\n<\/li>\n<\/ol>\n<h2>\u0414\u0430\u0442\u0430\u0441\u0435\u0442<\/h2>\n<p>\u0414\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u044b, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0435 500, 1000 \u0438 2000 \u043d\u0430\u0431\u043e\u0440\u043e\u0432 (bags of instances). \u0421\u043e\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u043f\u043e\u0437\u0438\u0442\u0438\u0432\u043d\u044b\u0445 (\u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0445 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u043e \u0441\u0432\u0435\u0442\u043b\u043e\u043a\u043b\u0435\u0442\u043e\u0447\u043d\u044b\u043c \u0440\u0430\u043a\u043e\u043c \u043f\u043e\u0447\u043a\u0438) \u0438 \u043d\u0435\u0433\u0430\u0442\u0438\u0432\u043d\u044b\u0445 (\u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0445 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0435 \u0442\u043a\u0430\u043d\u0438) \u0431\u044b\u043b\u043e 1:1. \u0412 \u043a\u0430\u0436\u0434\u043e\u043c \u043d\u0430\u0431\u043e\u0440\u0435 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u043b\u043e 40 \u0446\u0432\u0435\u0442\u043d\u044b\u0445 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439\u00a0 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 .jpeg \u0441 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c 256\u0445256 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u0441 \u043f\u043e\u043b\u043d\u043e\u0441\u043b\u0430\u0439\u0434\u043e\u0432\u044b\u0445 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f CPTAC-CCRCC (WSI \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u0435 \u043d\u0430 \u0441\u0430\u0439\u0442\u0435 Cancer Imaging Archive). \u0412 \u043f\u043e\u0437\u0438\u0442\u0438\u0432\u043d\u044b\u0445 \u043d\u0430\u0431\u043e\u0440\u0430\u0445\u00a0 20 \u0438\u0437 40 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0431\u044b\u043b\u0438 \u0441\u043e \u0441\u0432\u0435\u0442\u043b\u043e\u043a\u043b\u0435\u0442\u043e\u0447\u043d\u044b\u043c \u0440\u0430\u043a\u043e\u043c \u043f\u043e\u0447\u043a\u0438.<\/p>\n<p>\u0410\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e WSI \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u043b \u044f \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e ( \u0442.\u043a. \u043f\u043e \u043f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u0438 \u044f\u0432\u043b\u044f\u044e\u0441\u044c \u043f\u0430\u0442\u043e\u043b\u043e\u0433\u043e\u0430\u043d\u0430\u0442\u043e\u043c\u043e\u043c) \u0438 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043e\u043f\u0438\u0441\u0430\u043b \u0432 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 (<a href=\"https:\/\/habr.com\/ru\/post\/668044\/\" rel=\"noopener noreferrer nofollow\">\u0441\u0441\u044b\u043b\u043a\u0430<\/a>) .\u00a0<\/p>\n<p>\u0412\u0441\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0435 \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430 2 \u043a\u043b\u0430\u0441\u0441\u0430 : <strong>\u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0435 \u0442\u043a\u0430\u043d\u0438 <\/strong>(\u043a\u0440\u043e\u0432\u044c, \u0441\u0442\u0440\u043e\u043c\u0430, \u0436\u0438\u0440\u043e\u0432\u0430\u044f \u0442\u043a\u0430\u043d\u044c, \u0442\u043a\u0430\u043d\u044c \u043f\u043e\u0447\u043a\u0438) \u0438 <strong>\u0441\u0432\u0435\u0442\u043b\u043e\u043a\u043b\u0435\u0442\u043e\u0447\u043d\u044b\u0439 \u0440\u0430\u043a \u043f\u043e\u0447\u043a\u0438 (CCRCC)<\/strong>.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a25\/045\/da5\/a25045da5d5fc4d92e2dacf44c5d70c3.png\" alt=\"\u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \" title=\"\u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \" width=\"2052\" height=\"1328\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a25\/045\/da5\/a25045da5d5fc4d92e2dacf44c5d70c3.png\"\/><figcaption>\u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 <\/figcaption><\/figure>\n<p>\u0414\u0430\u0442\u0430\u0441\u0435\u0442\u044b \u0431\u044b\u043b\u0438 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043f\u0443\u0442\u0451\u043c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u0432\u044b\u0431\u043e\u0440\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0438\u0437 \u043f\u0443\u043b\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0445 \u0442\u043a\u0430\u043d\u0435\u0439 \u0438 \u0440\u0430\u043a\u0430, \u0431\u0435\u0437 \u0437\u0430\u043c\u0435\u043d\u044b (\u0442.\u0435. \u043e\u0434\u043d\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043c\u043e\u0433\u043b\u043e \u043f\u043e\u043f\u0430\u0441\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043e\u0434\u0438\u043d \u043d\u0430\u0431\u043e\u0440).<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/5db\/17e\/90b\/5db17e90b04da7d0c55825063af2d754.png\" alt=\"\u0420\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0432 \u043f\u0443\u043b\u0430\u0445, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043b\u0441\u044f Train, Validation \u0438 Test \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u044b\" title=\"\u0420\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0432 \u043f\u0443\u043b\u0430\u0445, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043b\u0441\u044f Train, Validation \u0438 Test \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u044b\" width=\"1257\" height=\"291\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5db\/17e\/90b\/5db17e90b04da7d0c55825063af2d754.png\"\/><figcaption>\u0420\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0432 \u043f\u0443\u043b\u0430\u0445, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043b\u0441\u044f Train, Validation \u0438 Test \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u044b<\/figcaption><\/figure>\n<h2>\u041c\u043e\u0434\u0435\u043b\u044c<\/h2>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u043c\u043e\u0434\u0435\u043b\u0438<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">from tensorflow import keras from tensorflow.keras import layers from keras.layers import Flatten from keras.layers import Input, Dense, Layer, Dropout, Conv2D, MaxPooling2D, Flatten, multiply from MILAttentionLayer import MILAttentionLayer  def SimpleModel(instance_shape,bag_size):     \"\"\" Create Keras model for Multiply Instance Learning     Parameters     -------------------     instance_shape (tuple) - shape of 1 instance in the bag     bag_size (int) - size of the bag     Returns     -------------------      keras.Model     \"\"\"     # Extract features from inputs.     inputs, embeddings = [], []     conv1_1 = Conv2D(16, kernel_size=(2,2), activation='relu')      conv1_2 = Conv2D(16, kernel_size=(2,2), activation='relu')       mpool_1 = MaxPooling2D((2,2))      conv2_1 = Conv2D(32, kernel_size=(2,2),   activation='relu')       conv2_2 = Conv2D(32, kernel_size=(2,2),activation='relu')      mpool_2 = MaxPooling2D((2,2))      fc0 = Dense(512, activation='relu', name='fc0')      fc1 = Dense(512, activation='relu', name='fc1')      fc2 = Dense(256, activation= 'relu',  name='fc2')          for _ in range(bag_size):         inp = layers.Input(instance_shape)         inputs.append(inp)         x = conv1_1(inp)         x = conv1_2(x)         x = mpool_1(x)          x = conv2_1(x)         x = conv2_2(x)         x = mpool_2(x)          x = Flatten()(x)         x = fc0(x)         x = Dropout(0.5)(x)         x = fc1(x)         x = Dropout(0.5)(x)         x = fc2(x)         x = Dropout(0.2)(x)                  embeddings.append(x)      # \u0410ttention layer.     alpha = MILAttentionLayer(         weight_params_dim=1024,         kernel_regularizer=keras.regularizers.l2(0),# previous - 0.01         use_gated=True,          name=\"alpha\",     )(embeddings)      # Multiply attention weights with the input layers.     multiply_layers = [         layers.multiply([alpha[i], embeddings[i]]) for i in range(len(alpha))     ]      # Concatenate layers.     concat = layers.concatenate(multiply_layers, axis=1)      # Classification output node.     output = layers.Dense(2, activation = 'softmax')(concat)      return keras.Model(inputs, output) <\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0421 \u0446\u0435\u043b\u044c\u044e \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u0431\u044b\u043b\u0430 \u043e\u0431\u0443\u0447\u0435\u043d\u0430 \u043d\u0430 \u0442\u0440\u0451\u0445 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430\u0445 \u0441 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u043d\u0430\u0431\u043e\u0440\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 :<\/p>\n<ol>\n<li>\n<p><strong>Model_500<\/strong> &#8212; \u043c\u043e\u0434\u0435\u043b\u044c \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u0430\u044f \u043d\u0430 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0435, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0435\u043c 500 \u043d\u0430\u0431\u043e\u0440\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445<\/p>\n<\/li>\n<li>\n<p><strong>Model_1000<\/strong> &#8212; \u043c\u043e\u0434\u0435\u043b\u044c \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u0430\u044f \u043d\u0430 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0435, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0435\u043c 1000 \u043d\u0430\u0431\u043e\u0440\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445<\/p>\n<\/li>\n<li>\n<p><strong>Model_2000<\/strong> &#8212; \u043c\u043e\u0434\u0435\u043b\u044c \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u0430\u044f \u043d\u0430 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0435, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0435\u043c 2000 \u043d\u0430\u0431\u043e\u0440\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445<\/p>\n<\/li>\n<\/ol>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0435\u0439<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">import tensorflow as tf from CustomDataGenerator import CustomDataGenerator from SimpleModel import SimpleModel  def train_model (train_df, validation_df, model_save_path):     \"\"\"     Train SimpleModel          Parameters     -------------------     train_df (pandas DataFrame) - DataFrame with the training data. X (bag of instances) - list of images paths. y -label     validation_df (pandas DataFrame) - DataFrame with the validation data. X (bag of instances) - list of images paths. y -label     model_save_path (str) - path for model saving     Returns     -------------------     \"\"\"             # create generator of the training and validation data     train_generator = CustomDataGenerator(df = train_df, shuffle = True, augmentations = True )     validation_generator = CustomDataGenerator (df = validation_df, shuffle = False, augmentations = False )          # Callbacks     model_checkpoint = tf.keras.callbacks.ModelCheckpoint(         model_save_path,         monitor=\"val_loss\",         verbose=1,         mode=\"min\",         save_best_only=True,         save_weights_only= False)               es = tf.keras.callbacks.EarlyStopping(         monitor=\"val_loss\",         patience=10,         verbose=1,         mode=\"min\")          # optimizer     opt = tf.keras.optimizers.Adam(learning_rate=1e-3, decay=0.0005, beta_1=0.9, beta_2=0.999)          # create and compile model     model = SimpleModel(bag_size = 40, instance_shape = (256, 256, 3) )     model.compile(optimizer = opt,      loss='categorical_crossentropy', metrics=[\"accuracy\",tf.keras.metrics.AUC(name = 'AUC'),                                                         tf.keras.metrics.AUC(curve = 'PR',name = 'PR_AUC'),                                                          tf.keras.metrics.Precision(name = 'Precision', class_id = 1),                                                         tf.keras.metrics.Recall(name = 'Recall',class_id = 1)])     # model fitting     model.fit(         train_generator,         validation_data = validation_generator ,         epochs=100,         batch_size= 1,         callbacks=[model_checkpoint,es],          verbose=1)<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<h2>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f<\/h2>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td data-colwidth=\"103\" width=\"103\">\n<p align=\"center\">Model<\/p>\n<\/td>\n<td>\n<p align=\"center\">Set<\/p>\n<\/td>\n<td data-colwidth=\"82\" width=\"82\">\n<p align=\"center\">Loss<\/p>\n<\/td>\n<td data-colwidth=\"82\" width=\"82\">\n<p align=\"center\">Accuracy<\/p>\n<\/td>\n<td data-colwidth=\"82\" width=\"82\">\n<p align=\"center\">PR_AUC<\/p>\n<\/td>\n<td data-colwidth=\"95\" width=\"95\">\n<p align=\"center\">ROC_AUC<\/p>\n<\/td>\n<td data-colwidth=\"92\" width=\"92\">\n<p align=\"center\">Precision<\/p>\n<\/td>\n<td>\n<p align=\"center\">Recall<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td rowspan=\"2\" data-colwidth=\"103\" width=\"103\">\n<p align=\"center\">Model_500<\/p>\n<\/td>\n<td>\n<p align=\"center\">Train<\/p>\n<\/td>\n<td data-colwidth=\"82\" width=\"82\">\n<p align=\"right\">0.017599<\/p>\n<\/td>\n<td data-colwidth=\"82\" width=\"82\">\n<p align=\"right\">0.9940<\/p>\n<\/td>\n<td data-colwidth=\"82\" width=\"82\">\n<p align=\"right\">0.99985<\/p>\n<\/td>\n<td data-colwidth=\"95\" width=\"95\">\n<p align=\"right\">0.99985<\/p>\n<\/td>\n<td data-colwidth=\"92\" width=\"92\">\n<p align=\"right\">0.9940<\/p>\n<\/td>\n<td>\n<p align=\"right\">0.9940<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\">Val<\/p>\n<\/td>\n<td data-colwidth=\"82\" width=\"82\">\n<p align=\"right\">0.013762<\/p>\n<\/td>\n<td data-colwidth=\"82\" width=\"82\">\n<p align=\"right\">1<\/p>\n<\/td>\n<td data-colwidth=\"82\" width=\"82\">\n<p align=\"right\">1<\/p>\n<\/td>\n<td data-colwidth=\"95\" width=\"95\">\n<p align=\"right\">1<\/p>\n<\/td>\n<td data-colwidth=\"92\" width=\"92\">\n<p align=\"right\">1<\/p>\n<\/td>\n<td>\n<p align=\"right\">1<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td rowspan=\"2\" data-colwidth=\"103\" width=\"103\">\n<p align=\"center\">Model_1000<\/p>\n<\/td>\n<td>\n<p align=\"center\">Train<\/p>\n<\/td>\n<td data-colwidth=\"82\" width=\"82\">\n<p align=\"right\">0.0069<\/p>\n<\/td>\n<td data-colwidth=\"82\" width=\"82\">\n<p align=\"right\">0.9980<\/p>\n<\/td>\n<td data-colwidth=\"82\" width=\"82\">\n<p align=\"right\">1<\/p>\n<\/td>\n<td data-colwidth=\"95\" width=\"95\">\n<p align=\"right\">1<\/p>\n<\/td>\n<td data-colwidth=\"92\" width=\"92\">\n<p align=\"right\">0.9980<\/p>\n<\/td>\n<td>\n<p align=\"right\">0.9980<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\">Val<\/p>\n<\/td>\n<td data-colwidth=\"82\" width=\"82\">\n<p align=\"right\">0.00123<\/p>\n<\/td>\n<td data-colwidth=\"82\" width=\"82\">\n<p align=\"right\">1<\/p>\n<\/td>\n<td data-colwidth=\"82\" width=\"82\">\n<p align=\"right\">1<\/p>\n<\/td>\n<td data-colwidth=\"95\" width=\"95\">\n<p align=\"right\">1<\/p>\n<\/td>\n<td data-colwidth=\"92\" width=\"92\">\n<p align=\"right\">1<\/p>\n<\/td>\n<td>\n<p align=\"right\">1<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td rowspan=\"2\" data-colwidth=\"103\" width=\"103\">\n<p align=\"center\">Model_2000<\/p>\n<\/td>\n<td>\n<p align=\"center\">Train<\/p>\n<\/td>\n<td data-colwidth=\"82\" width=\"82\">\n<p align=\"right\">0.0117<\/p>\n<\/td>\n<td data-colwidth=\"82\" width=\"82\">\n<p align=\"right\">0.9970<\/p>\n<\/td>\n<td data-colwidth=\"82\" width=\"82\">\n<p align=\"right\">0.9992<\/p>\n<\/td>\n<td data-colwidth=\"95\" width=\"95\">\n<p align=\"right\">0.9994<\/p>\n<\/td>\n<td data-colwidth=\"92\" width=\"92\">\n<p align=\"right\">0.9970<\/p>\n<\/td>\n<td>\n<p align=\"right\">0.9970<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\">Val<\/p>\n<\/td>\n<td data-colwidth=\"82\" width=\"82\">\n<p align=\"right\"><strong>0.00010<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"82\" width=\"82\">\n<p align=\"right\">1<\/p>\n<\/td>\n<td data-colwidth=\"82\" width=\"82\">\n<p align=\"right\">1<\/p>\n<\/td>\n<td data-colwidth=\"95\" width=\"95\">\n<p align=\"right\">1<\/p>\n<\/td>\n<td data-colwidth=\"92\" width=\"92\">\n<p align=\"right\">1<\/p>\n<\/td>\n<td>\n<p align=\"right\">1<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u041b\u0443\u0447\u0448\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u0440\u0438 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0438 \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u0430 <strong>Model_2000<\/strong>, \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u0430\u044f \u043d\u0430 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0435, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0435\u043c \u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u0430\u043d\u043d\u044b\u0445.  <\/p>\n<h2>\u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0435\u0439<\/h2>\n<p>\u0414\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0431\u044b\u043b\u043e \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043e 4 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430 \u0441 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0432 \u043d\u0430\u0431\u043e\u0440\u0435<\/p>\n<p>\u0422\u0435\u0441\u0442\u043e\u0432\u044b\u0435 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u044b:<\/p>\n<ol>\n<li>\n<p><strong>Test_40_20<\/strong> &#8212; \u0434\u0430\u0442\u0430\u0441\u0435\u0442, \u0432 \u043f\u043e\u0437\u0438\u0442\u0438\u0432\u043d\u044b\u0445 \u043d\u0430\u0431\u043e\u0440\u0430\u0445 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e, \u0438\u0437 40 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439,  20 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u043b\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u043e \u0441\u0432\u0435\u0442\u043b\u043e\u043a\u043b\u0435\u0442\u043e\u0447\u043d\u044b\u043c \u0440\u0430\u043a\u043e\u043c \u043f\u043e\u0447\u043a\u0438.<\/p>\n<\/li>\n<li>\n<p><strong>Test_40_10<\/strong> &#8212; \u0434\u0430\u0442\u0430\u0441\u0435\u0442, \u0432 \u043f\u043e\u0437\u0438\u0442\u0438\u0432\u043d\u044b\u0445 \u043d\u0430\u0431\u043e\u0440\u0430\u0445 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e, \u0438\u0437 40 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439,  10 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u043b\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u043e \u0441\u0432\u0435\u0442\u043b\u043e\u043a\u043b\u0435\u0442\u043e\u0447\u043d\u044b\u043c \u0440\u0430\u043a\u043e\u043c \u043f\u043e\u0447\u043a\u0438.<\/p>\n<\/li>\n<li>\n<p><strong>Test_40_5<\/strong> &#8212; \u0434\u0430\u0442\u0430\u0441\u0435\u0442, \u0432 \u043f\u043e\u0437\u0438\u0442\u0438\u0432\u043d\u044b\u0445 \u043d\u0430\u0431\u043e\u0440\u0430\u0445 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e, \u0438\u0437 40 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439,  5 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u043b\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u043e \u0441\u0432\u0435\u0442\u043b\u043e\u043a\u043b\u0435\u0442\u043e\u0447\u043d\u044b\u043c \u0440\u0430\u043a\u043e\u043c \u043f\u043e\u0447\u043a\u0438.<\/p>\n<\/li>\n<li>\n<p><strong>Test_40_1<\/strong> &#8212; \u0434\u0430\u0442\u0430\u0441\u0435\u0442, \u0432 \u043f\u043e\u0437\u0438\u0442\u0438\u0432\u043d\u044b\u0445 \u043d\u0430\u0431\u043e\u0440\u0430\u0445 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e, \u0438\u0437 40 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439,  1 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u043b\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u043e \u0441\u0432\u0435\u0442\u043b\u043e\u043a\u043b\u0435\u0442\u043e\u0447\u043d\u044b\u043c \u0440\u0430\u043a\u043e\u043c \u043f\u043e\u0447\u043a\u0438.<\/p>\n<\/li>\n<\/ol>\n<p>\u0421 \u0446\u0435\u043b\u044c\u044e \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430 \u0445\u043e\u0442\u0435\u043b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u043a\u0430\u043a\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u043e\u043a\u0430\u0436\u0443\u0442 \u043c\u043e\u0434\u0435\u043b\u0438 \u043d\u0430 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430\u0445 \u0441 \u043c\u0435\u043d\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u043f\u043e\u0437\u0438\u0442\u0438\u0432\u043d\u044b\u0445 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0432 \u043d\u0430\u0431\u043e\u0440\u0435.<\/p>\n<h2>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f<\/h2>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/5c2\/c28\/c78\/5c2c28c78ce55615a72127c0b3afa969.png\" width=\"779\" height=\"571\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5c2\/c28\/c78\/5c2c28c78ce55615a72127c0b3afa969.png\"\/><figcaption><\/figcaption><\/figure>\n<details class=\"spoiler\">\n<summary>Confusion matrix<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/bc2\/213\/202\/bc2213202e6e10cc0069dcaa8e871451.png\" width=\"925\" height=\"355\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/bc2\/213\/202\/bc2213202e6e10cc0069dcaa8e871451.png\"\/><figcaption><\/figcaption><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/3bc\/091\/a1d\/3bc091a1d5bab0abd1d1c19226d6988c.png\" width=\"941\" height=\"337\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/3bc\/091\/a1d\/3bc091a1d5bab0abd1d1c19226d6988c.png\"\/><figcaption><\/figcaption><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c51\/a4c\/44e\/c51a4c44e5017c6060d3408b2f7b112c.png\" width=\"943\" height=\"337\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c51\/a4c\/44e\/c51a4c44e5017c6060d3408b2f7b112c.png\"\/><figcaption><\/figcaption><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/81b\/534\/f79\/81b534f797bb6d2ff09a3649c44f0ba3.png\" width=\"983\" height=\"327\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/81b\/534\/f79\/81b534f797bb6d2ff09a3649c44f0ba3.png\"\/><figcaption><\/figcaption><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041d\u0430\u0438\u043b\u0443\u0447\u0448\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043d\u0430 40_20 \u0438 40_10 \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u0430 <strong>Model_2000<\/strong> \u0441 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e \u0432 99.5 % \u0438 98.7 %  \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e. Recall (\u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u043d\u0435\u0435, \u0447\u0435\u043c \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c, \u0438\u0437-\u0437\u0430 \u043d\u0435\u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043b\u043e\u0436\u043d\u043e-\u043d\u0435\u0433\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u0439) \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u043b 1 \u0438 0.976. <\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u043d\u0430 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430\u0445 40_5 \u0438 40_1, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043b\u0438 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0441\u0432\u0435\u0442\u043b\u043e\u043a\u043b\u0435\u0442\u043e\u0447\u043d\u043e\u0433\u043e \u0440\u0430\u043a\u0430, \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u0441\u0435\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0441\u0438\u043b\u044c\u043d\u043e \u0441\u043d\u0438\u0437\u0438\u043b\u043e\u0441\u044c, \u0438 \u043b\u0443\u0447\u0448\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0443\u0436\u0435 \u0443 \u043c\u043e\u0434\u0435\u043b\u0438, \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u043e\u0439 \u043d\u0430 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 (<strong>Model_500<\/strong>) .<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/696270\/\"> https:\/\/habr.com\/ru\/post\/696270\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<h2>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0421 \u0443\u0447\u0451\u0442\u043e\u043c \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 Multiple instance learning (\u0434\u0430\u043b\u0435\u0435: MIL) \u0438, \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u043d\u0430\u043b\u0438\u0447\u0438\u044f \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0433\u0438\u0441\u0442\u043e\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439,\u00a0\u0440\u0435\u0448\u0438\u043b \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u0443\u0447\u0438\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0438 \u0441 \u0446\u0435\u043b\u044c\u044e \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u043d\u0430\u0431\u043e\u0440\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u0430 \u0442\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0435 \u0442\u043a\u0430\u043d\u0438 \u0438 \u0442\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u044e\u0442\u0441\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u043e \u0441\u0432\u0435\u0442\u043b\u043e\u043a\u043b\u0435\u0442\u043e\u0447\u043d\u044b\u043c \u0440\u0430\u043a\u043e\u043c \u043f\u043e\u0447\u043a\u0438.<\/p>\n<p><a href=\"https:\/\/github.com\/bluewhale28\/Multiple-Instance-Learning-MIL-with-Keras-using-clear-cell-renal-cell-carcinoma-dataset\" rel=\"noopener noreferrer nofollow\">GitHub &#8212; \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439<\/a><\/p>\n<p>\u0412 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0441\u044f \u043d\u0430 2 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043f\u043e \u0434\u0430\u043d\u043d\u043e\u0439 \u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0435 : <\/p>\n<ol>\n<li>\n<p> \u0418\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f MIL Attention layer \u043d\u0430 Keras &#8212; <a href=\"https:\/\/keras.io\/examples\/vision\/attention_mil_classification\/\" rel=\"noopener noreferrer nofollow\">\u0441\u0441\u044b\u043b\u043a\u0430 <\/a><\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0435\u043a\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 Attention-based Deep Multiple Instance Learning \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0433\u0438\u0441\u0442\u043e\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 &#8212; <a href=\"https:\/\/github.com\/utayao\/Atten_Deep_MIL\" rel=\"noopener noreferrer nofollow\">github <\/a><\/p>\n<\/li>\n<\/ol>\n<h2>\u0414\u0430\u0442\u0430\u0441\u0435\u0442<\/h2>\n<p>\u0414\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u044b, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0435 500, 1000 \u0438 2000 \u043d\u0430\u0431\u043e\u0440\u043e\u0432 (bags of instances). \u0421\u043e\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u043f\u043e\u0437\u0438\u0442\u0438\u0432\u043d\u044b\u0445 (\u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0445 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u043e \u0441\u0432\u0435\u0442\u043b\u043e\u043a\u043b\u0435\u0442\u043e\u0447\u043d\u044b\u043c \u0440\u0430\u043a\u043e\u043c \u043f\u043e\u0447\u043a\u0438) \u0438 \u043d\u0435\u0433\u0430\u0442\u0438\u0432\u043d\u044b\u0445 (\u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0445 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0435 \u0442\u043a\u0430\u043d\u0438) \u0431\u044b\u043b\u043e 1:1. \u0412 \u043a\u0430\u0436\u0434\u043e\u043c \u043d\u0430\u0431\u043e\u0440\u0435 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u043b\u043e 40 \u0446\u0432\u0435\u0442\u043d\u044b\u0445 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439\u00a0 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 .jpeg \u0441 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c 256\u0445256 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u0441 \u043f\u043e\u043b\u043d\u043e\u0441\u043b\u0430\u0439\u0434\u043e\u0432\u044b\u0445 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f CPTAC-CCRCC (WSI \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u0435 \u043d\u0430 \u0441\u0430\u0439\u0442\u0435 Cancer Imaging Archive). \u0412 \u043f\u043e\u0437\u0438\u0442\u0438\u0432\u043d\u044b\u0445 \u043d\u0430\u0431\u043e\u0440\u0430\u0445\u00a0 20 \u0438\u0437 40 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0431\u044b\u043b\u0438 \u0441\u043e \u0441\u0432\u0435\u0442\u043b\u043e\u043a\u043b\u0435\u0442\u043e\u0447\u043d\u044b\u043c \u0440\u0430\u043a\u043e\u043c \u043f\u043e\u0447\u043a\u0438.<\/p>\n<p>\u0410\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e WSI \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u043b \u044f \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e ( \u0442.\u043a. \u043f\u043e \u043f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u0438 \u044f\u0432\u043b\u044f\u044e\u0441\u044c \u043f\u0430\u0442\u043e\u043b\u043e\u0433\u043e\u0430\u043d\u0430\u0442\u043e\u043c\u043e\u043c) \u0438 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043e\u043f\u0438\u0441\u0430\u043b \u0432 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 (<a href=\"https:\/\/habr.com\/ru\/post\/668044\/\" rel=\"noopener noreferrer nofollow\">\u0441\u0441\u044b\u043b\u043a\u0430<\/a>) .\u00a0<\/p>\n<p>\u0412\u0441\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0435 \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430 2 \u043a\u043b\u0430\u0441\u0441\u0430 : <strong>\u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0435 \u0442\u043a\u0430\u043d\u0438 <\/strong>(\u043a\u0440\u043e\u0432\u044c, \u0441\u0442\u0440\u043e\u043c\u0430, \u0436\u0438\u0440\u043e\u0432\u0430\u044f \u0442\u043a\u0430\u043d\u044c, \u0442\u043a\u0430\u043d\u044c \u043f\u043e\u0447\u043a\u0438) \u0438 <strong>\u0441\u0432\u0435\u0442\u043b\u043e\u043a\u043b\u0435\u0442\u043e\u0447\u043d\u044b\u0439 \u0440\u0430\u043a \u043f\u043e\u0447\u043a\u0438 (CCRCC)<\/strong>.<\/p>\n<figure class=\"full-width\"><figcaption>\u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 <\/figcaption><\/figure>\n<p>\u0414\u0430\u0442\u0430\u0441\u0435\u0442\u044b \u0431\u044b\u043b\u0438 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043f\u0443\u0442\u0451\u043c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u0432\u044b\u0431\u043e\u0440\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0438\u0437 \u043f\u0443\u043b\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0445 \u0442\u043a\u0430\u043d\u0435\u0439 \u0438 \u0440\u0430\u043a\u0430, \u0431\u0435\u0437 \u0437\u0430\u043c\u0435\u043d\u044b (\u0442.\u0435. \u043e\u0434\u043d\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043c\u043e\u0433\u043b\u043e \u043f\u043e\u043f\u0430\u0441\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043e\u0434\u0438\u043d \u043d\u0430\u0431\u043e\u0440).<\/p>\n<figure class=\"full-width\"><figcaption>\u0420\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0432 \u043f\u0443\u043b\u0430\u0445, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043b\u0441\u044f Train, Validation \u0438 Test \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u044b<\/figcaption><\/figure>\n<h2>\u041c\u043e\u0434\u0435\u043b\u044c<\/h2>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u043c\u043e\u0434\u0435\u043b\u0438<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">from tensorflow import keras from tensorflow.keras import layers from keras.layers import Flatten from keras.layers import Input, Dense, Layer, Dropout, Conv2D, MaxPooling2D, Flatten, multiply from MILAttentionLayer import MILAttentionLayer  def SimpleModel(instance_shape,bag_size):     \"\"\" Create Keras model for Multiply Instance Learning     Parameters     -------------------     instance_shape (tuple) - shape of 1 instance in the bag     bag_size (int) - size of the bag     Returns     -------------------      keras.Model     \"\"\"     # Extract features from inputs.     inputs, embeddings = [], []     conv1_1 = Conv2D(16, kernel_size=(2,2), activation='relu')      conv1_2 = Conv2D(16, kernel_size=(2,2), activation='relu')       mpool_1 = MaxPooling2D((2,2))      conv2_1 = Conv2D(32, kernel_size=(2,2),   activation='relu')       conv2_2 = Conv2D(32, kernel_size=(2,2),activation='relu')      mpool_2 = MaxPooling2D((2,2))      fc0 = Dense(512, activation='relu', name='fc0')      fc1 = Dense(512, activation='relu', name='fc1')      fc2 = Dense(256, activation= 'relu',  name='fc2')          for _ in range(bag_size):         inp = layers.Input(instance_shape)         inputs.append(inp)         x = conv1_1(inp)         x = conv1_2(x)         x = mpool_1(x)          x = conv2_1(x)         x = conv2_2(x)         x = mpool_2(x)          x = Flatten()(x)         x = fc0(x)         x = Dropout(0.5)(x)         x = fc1(x)         x = Dropout(0.5)(x)         x = fc2(x)         x = Dropout(0.2)(x)                  embeddings.append(x)      # \u0410ttention layer.     alpha = MILAttentionLayer(         weight_params_dim=1024,         kernel_regularizer=keras.regularizers.l2(0),# previous - 0.01         use_gated=True,          name=\"alpha\",     )(embeddings)      # Multiply attention weights with the input layers.     multiply_layers = [         layers.multiply([alpha[i], embeddings[i]]) for i in range(len(alpha))     ]      # Concatenate layers.     concat = layers.concatenate(multiply_layers, axis=1)      # Classification output node.     output = layers.Dense(2, activation = 'softmax')(concat)      return keras.Model(inputs, output) <\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0421 \u0446\u0435\u043b\u044c\u044e \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u0431\u044b\u043b\u0430 \u043e\u0431\u0443\u0447\u0435\u043d\u0430 \u043d\u0430 \u0442\u0440\u0451\u0445 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430\u0445 \u0441 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u043d\u0430\u0431\u043e\u0440\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 :<\/p>\n<ol>\n<li>\n<p><strong>Model_500<\/strong> &#8212; \u043c\u043e\u0434\u0435\u043b\u044c \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u0430\u044f \u043d\u0430 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0435, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0435\u043c 500 \u043d\u0430\u0431\u043e\u0440\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445<\/p>\n<\/li>\n<li>\n<p><strong>Model_1000<\/strong> &#8212; \u043c\u043e\u0434\u0435\u043b\u044c \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u0430\u044f \u043d\u0430 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0435, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0435\u043c 1000 \u043d\u0430\u0431\u043e\u0440\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445<\/p>\n<\/li>\n<li>\n<p><strong>Model_2000<\/strong> &#8212; \u043c\u043e\u0434\u0435\u043b\u044c \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u0430\u044f \u043d\u0430 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0435, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0435\u043c 2000 \u043d\u0430\u0431\u043e\u0440\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445<\/p>\n<\/li>\n<\/ol>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0435\u0439<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">import tensorflow as tf from CustomDataGenerator import CustomDataGenerator from SimpleModel import SimpleModel  def train_model (train_df, validation_df, model_save_path):     \"\"\"     Train SimpleModel          Parameters     -------------------     train_df (pandas DataFrame) - DataFrame with the training data. X (bag of instances) - list of images paths. y -label     validation_df (pandas DataFrame) - DataFrame with the validation data. X (bag of instances) - list of images paths. y -label     model_save_path (str) - path for model saving     Returns     -------------------     \"\"\"             # create generator of the training and validation data     train_generator = CustomDataGenerator(df = train_df, shuffle = True, augmentations = True )     validation_generator = CustomDataGenerator (df = validation_df, shuffle = False, augmentations = False )          # Callbacks     model_checkpoint = tf.keras.callbacks.ModelCheckpoint(         model_save_path,         monitor=\"val_loss\",         verbose=1,         mode=\"min\",         save_best_only=True,         save_weights_only= False)               es = tf.keras.callbacks.EarlyStopping(         monitor=\"val_loss\",         patience=10,         verbose=1,         mode=\"min\")          # optimizer     opt = tf.keras.optimizers.Adam(learning_rate=1e-3, decay=0.0005, beta_1=0.9, beta_2=0.999)          # create and compile model     model = SimpleModel(bag_size = 40, instance_shape = (256, 256, 3) )     model.compile(optimizer = opt,      loss='categorical_crossentropy', metrics=[\"accuracy\",tf.keras.metrics.AUC(name = 'AUC'),                                                         tf.keras.metrics.AUC(curve = 'PR',name = 'PR_AUC'),                                                          tf.keras.metrics.Precision(name = 'Precision', class_id = 1),                                                         tf.keras.metrics.Recall(name = 'Recall',class_id = 1)])     # model fitting     model.fit(         train_generator,         validation_data = validation_generator ,         epochs=100,         batch_size= 1,         callbacks=[model_checkpoint,es],          verbose=1)<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<h2>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f<\/h2>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td data-colwidth=\"103\" width=\"103\">\n<p align=\"center\">Model<\/p>\n<\/td>\n<td>\n<p align=\"center\">Set<\/p>\n<\/td>\n<td data-colwidth=\"82\" width=\"82\">\n<p align=\"center\">Loss<\/p>\n<\/td>\n<td data-colwidth=\"82\" width=\"82\">\n<p align=\"center\">Accuracy<\/p>\n<\/td>\n<td data-colwidth=\"82\" width=\"82\">\n<p align=\"center\">PR_AUC<\/p>\n<\/td>\n<td data-colwidth=\"95\" width=\"95\">\n<p align=\"center\">ROC_AUC<\/p>\n<\/td>\n<td data-colwidth=\"92\" width=\"92\">\n<p align=\"center\">Precision<\/p>\n<\/td>\n<td>\n<p align=\"center\">Recall<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td rowspan=\"2\" data-colwidth=\"103\" width=\"103\">\n<p align=\"center\">Model_500<\/p>\n<\/td>\n<td>\n<p align=\"center\">Train<\/p>\n<\/td>\n<td data-colwidth=\"82\" width=\"82\">\n<p align=\"right\">0.017599<\/p>\n<\/td>\n<td data-colwidth=\"82\" width=\"82\">\n<p align=\"right\">0.9940<\/p>\n<\/td>\n<td data-colwidth=\"82\" width=\"82\">\n<p align=\"right\">0.99985<\/p>\n<\/td>\n<td data-colwidth=\"95\" width=\"95\">\n<p align=\"right\">0.99985<\/p>\n<\/td>\n<td data-colwidth=\"92\" width=\"92\">\n<p align=\"right\">0.9940<\/p>\n<\/td>\n<td>\n<p align=\"right\">0.9940<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\">Val<\/p>\n<\/td>\n<td data-colwidth=\"82\" width=\"82\">\n<p align=\"right\">0.013762<\/p>\n<\/td>\n<td data-colwidth=\"82\" width=\"82\">\n<p align=\"right\">1<\/p>\n<\/td>\n<td data-colwidth=\"82\" width=\"82\">\n<p align=\"right\">1<\/p>\n<\/td>\n<td data-colwidth=\"95\" width=\"95\">\n<p align=\"right\">1<\/p>\n<\/td>\n<td data-colwidth=\"92\" width=\"92\">\n<p align=\"right\">1<\/p>\n<\/td>\n<td>\n<p align=\"right\">1<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td rowspan=\"2\" data-colwidth=\"103\" width=\"103\">\n<p align=\"center\">Model_1000<\/p>\n<\/td>\n<td>\n<p align=\"center\">Train<\/p>\n<\/td>\n<td data-colwidth=\"82\" width=\"82\">\n<p align=\"right\">0.0069<\/p>\n<\/td>\n<td data-colwidth=\"82\" width=\"82\">\n<p align=\"right\">0.9980<\/p>\n<\/td>\n<td data-colwidth=\"82\" width=\"82\">\n<p align=\"right\">1<\/p>\n<\/td>\n<td data-colwidth=\"95\" width=\"95\">\n<p align=\"right\">1<\/p>\n<\/td>\n<td data-colwidth=\"92\" width=\"92\">\n<p align=\"right\">0.9980<\/p>\n<\/td>\n<td>\n<p align=\"right\">0.9980<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\">Val<\/p>\n<\/td>\n<td data-colwidth=\"82\" width=\"82\">\n<p align=\"right\">0.00123<\/p>\n<\/td>\n<td data-colwidth=\"82\" width=\"82\">\n<p align=\"right\">1<\/p>\n<\/td>\n<td data-colwidth=\"82\" width=\"82\">\n<p align=\"right\">1<\/p>\n<\/td>\n<td data-colwidth=\"95\" width=\"95\">\n<p align=\"right\">1<\/p>\n<\/td>\n<td data-colwidth=\"92\" width=\"92\">\n<p align=\"right\">1<\/p>\n<\/td>\n<td>\n<p align=\"right\">1<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td rowspan=\"2\" data-colwidth=\"103\" width=\"103\">\n<p align=\"center\">Model_2000<\/p>\n<\/td>\n<td>\n<p align=\"center\">Train<\/p>\n<\/td>\n<td data-colwidth=\"82\" width=\"82\">\n<p align=\"right\">0.0117<\/p>\n<\/td>\n<td data-colwidth=\"82\" width=\"82\">\n<p align=\"right\">0.9970<\/p>\n<\/td>\n<td data-colwidth=\"82\" width=\"82\">\n<p align=\"right\">0.9992<\/p>\n<\/td>\n<td data-colwidth=\"95\" width=\"95\">\n<p align=\"right\">0.9994<\/p>\n<\/td>\n<td data-colwidth=\"92\" width=\"92\">\n<p align=\"right\">0.9970<\/p>\n<\/td>\n<td>\n<p align=\"right\">0.9970<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\">Val<\/p>\n<\/td>\n<td data-colwidth=\"82\" width=\"82\">\n<p align=\"right\"><strong>0.00010<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"82\" width=\"82\">\n<p align=\"right\">1<\/p>\n<\/td>\n<td data-colwidth=\"82\" width=\"82\">\n<p align=\"right\">1<\/p>\n<\/td>\n<td data-colwidth=\"95\" width=\"95\">\n<p align=\"right\">1<\/p>\n<\/td>\n<td data-colwidth=\"92\" width=\"92\">\n<p align=\"right\">1<\/p>\n<\/td>\n<td>\n<p align=\"right\">1<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u041b\u0443\u0447\u0448\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u0440\u0438 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0438 \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u0430 <strong>Model_2000<\/strong>, \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u0430\u044f \u043d\u0430 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0435, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0435\u043c \u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u0430\u043d\u043d\u044b\u0445.  <\/p>\n<h2>\u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0435\u0439<\/h2>\n<p>\u0414\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0431\u044b\u043b\u043e \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043e 4 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430 \u0441 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0432 \u043d\u0430\u0431\u043e\u0440\u0435<\/p>\n<p>\u0422\u0435\u0441\u0442\u043e\u0432\u044b\u0435 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u044b:<\/p>\n<ol>\n<li>\n<p><strong>Test_40_20<\/strong> &#8212; \u0434\u0430\u0442\u0430\u0441\u0435\u0442, \u0432 \u043f\u043e\u0437\u0438\u0442\u0438\u0432\u043d\u044b\u0445 \u043d\u0430\u0431\u043e\u0440\u0430\u0445 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e, \u0438\u0437 40 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439,  20 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u043b\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u043e \u0441\u0432\u0435\u0442\u043b\u043e\u043a\u043b\u0435\u0442\u043e\u0447\u043d\u044b\u043c \u0440\u0430\u043a\u043e\u043c \u043f\u043e\u0447\u043a\u0438.<\/p>\n<\/li>\n<li>\n<p><strong>Test_40_10<\/strong> &#8212; \u0434\u0430\u0442\u0430\u0441\u0435\u0442, \u0432 \u043f\u043e\u0437\u0438\u0442\u0438\u0432\u043d\u044b\u0445 \u043d\u0430\u0431\u043e\u0440\u0430\u0445 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e, \u0438\u0437 40 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439,  10 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u043b\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u043e \u0441\u0432\u0435\u0442\u043b\u043e\u043a\u043b\u0435\u0442\u043e\u0447\u043d\u044b\u043c \u0440\u0430\u043a\u043e\u043c \u043f\u043e\u0447\u043a\u0438.<\/p>\n<\/li>\n<li>\n<p><strong>Test_40_5<\/strong> &#8212; \u0434\u0430\u0442\u0430\u0441\u0435\u0442, \u0432 \u043f\u043e\u0437\u0438\u0442\u0438\u0432\u043d\u044b\u0445 \u043d\u0430\u0431\u043e\u0440\u0430\u0445 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e, \u0438\u0437 40 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439,  5 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u043b\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u043e \u0441\u0432\u0435\u0442\u043b\u043e\u043a\u043b\u0435\u0442\u043e\u0447\u043d\u044b\u043c \u0440\u0430\u043a\u043e\u043c \u043f\u043e\u0447\u043a\u0438.<\/p>\n<\/li>\n<li>\n<p><strong>Test_40_1<\/strong> &#8212; \u0434\u0430\u0442\u0430\u0441\u0435\u0442, \u0432 \u043f\u043e\u0437\u0438\u0442\u0438\u0432\u043d\u044b\u0445 \u043d\u0430\u0431\u043e\u0440\u0430\u0445 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e, \u0438\u0437 40 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439,  1 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u043b\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u043e \u0441\u0432\u0435\u0442\u043b\u043e\u043a\u043b\u0435\u0442\u043e\u0447\u043d\u044b\u043c \u0440\u0430\u043a\u043e\u043c \u043f\u043e\u0447\u043a\u0438.<\/p>\n<\/li>\n<\/ol>\n<p>\u0421 \u0446\u0435\u043b\u044c\u044e \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430 \u0445\u043e\u0442\u0435\u043b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u043a\u0430\u043a\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u043e\u043a\u0430\u0436\u0443\u0442 \u043c\u043e\u0434\u0435\u043b\u0438 \u043d\u0430 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430\u0445 \u0441 \u043c\u0435\u043d\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u043f\u043e\u0437\u0438\u0442\u0438\u0432\u043d\u044b\u0445 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0432 \u043d\u0430\u0431\u043e\u0440\u0435.<\/p>\n<h2>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f<\/h2>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<details class=\"spoiler\">\n<summary>Confusion matrix<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041d\u0430\u0438\u043b\u0443\u0447\u0448\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043d\u0430 40_20 \u0438 40_10 \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u0430 <strong>Model_2000<\/strong> \u0441 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e \u0432 99.5 % \u0438 98.7 %  \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e. Recall (\u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u043d\u0435\u0435, \u0447\u0435\u043c \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c, \u0438\u0437-\u0437\u0430 \u043d\u0435\u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043b\u043e\u0436\u043d\u043e-\u043d\u0435\u0433\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u0439) \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u043b 1 \u0438 0.976. <\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u043d\u0430 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430\u0445 40_5 \u0438 40_1, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043b\u0438 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0441\u0432\u0435\u0442\u043b\u043e\u043a\u043b\u0435\u0442\u043e\u0447\u043d\u043e\u0433\u043e \u0440\u0430\u043a\u0430, \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u0441\u0435\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0441\u0438\u043b\u044c\u043d\u043e \u0441\u043d\u0438\u0437\u0438\u043b\u043e\u0441\u044c, \u0438 \u043b\u0443\u0447\u0448\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0443\u0436\u0435 \u0443 \u043c\u043e\u0434\u0435\u043b\u0438, \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u043e\u0439 \u043d\u0430 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 (<strong>Model_500<\/strong>) .<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/696270\/\"> https:\/\/habr.com\/ru\/post\/696270\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-340500","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/340500","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=340500"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/340500\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=340500"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=340500"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=340500"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}