LINUX.ORG.RU

Как найти максимумы в списке списков используя lists, [], len, append, [index] и подобные простые решения, спасибо!

 ,


0

1

import numpy as np
from pprint import pprint
import collections 
from itertools import chain
import pandas as pd
from itertools import islice

CATEGORIES = ["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","R","S","T","U","V","W","X","Y","Z"]
KR8877J = [[0.002,0.006,0.004,0.045,0.002,0.017,0.006,0.077,0.001,0.035,0.042,0.005,0.004,0.039,0.001,0.002,0.001,0.008,0.058,0.352,0.002,0.007,0.017,0.004,0.007,0.007,0.007,0.004,0.005,0.009,0.089,0.036,0.053,0.041,0.004],
[0.003,0.007,0.005,0.075,0.001,0.020,0.006,0.044,0.002,0.035,0.026,0.004,0.004,0.033,0.001,0.001,0.003,0.008,0.049,0.360,0.002,0.007,0.021,0.005,0.009,0.003,0.008,0.007,0.003,0.014,0.092,0.048,0.058,0.031,0.004],
[0.002,0.000,0.025,0.012,0.006,0.002,0.001,0.627,0.006,0.021,0.022,0.008,0.004,0.006,0.004,0.033,0.000,0.006,0.011,0.009,0.002,0.002,0.009,0.000,0.002,0.040,0.007,0.005,0.015,0.000,0.035,0.001,0.008,0.015,0.053],
[0.056,0.008,0.023,0.038,0.015,0.007,0.050,0.006,0.412,0.004,0.005,0.027,0.011,0.005,0.021,0.007,0.073,0.024,0.012,0.005,0.013,0.005,0.027,0.003,0.015,0.001,0.005,0.074,0.002,0.022,0.005,0.011,0.002,0.001,0.006],
[0.025,0.011,0.025,0.034,0.018,0.027,0.090,0.008,0.258,0.006,0.007,0.026,0.016,0.008,0.026,0.011,0.079,0.030,0.026,0.008,0.018,0.011,0.033,0.003,0.016,0.001,0.003,0.106,0.004,0.021,0.012,0.013,0.003,0.005,0.014],
[0.048,0.027,0.019,0.002,0.028,0.002,0.008,0.017,0.041,0.014,0.012,0.022,0.031,0.005,0.045,0.100,0.004,0.031,0.033,0.002,0.029,0.006,0.021,0.032,0.008,0.038,0.317,0.007,0.017,0.004,0.018,0.005,0.003,0.004,0.002],
[0.013,0.002,0.002,0.000,0.164,0.001,0.060,0.004,0.006,0.002,0.018,0.003,0.035,0.002,0.008,0.008,0.001,0.008,0.028,0.005,0.383,0.013,0.063,0.010,0.004,0.002,0.014,0.016,0.002,0.005,0.048,0.011,0.028,0.017,0.012]]
KR8877J_1 = [[0.004,0.007,0.005,0.042,0.002,0.014,0.011,0.054,0.002,0.032,0.051,0.005,0.005,0.044,0.001,0.002,0.002,0.008,0.056,0.389,0.003,0.008,0.023,0.005,0.009,0.005,0.009,0.006,0.004,0.010,0.070,0.029,0.049,0.031,0.005],
[0.005,0.005,0.005,0.034,0.002,0.006,0.005,0.083,0.002,0.062,0.053,0.004,0.006,0.039,0.001,0.002,0.001,0.008,0.055,0.348,0.002,0.005,0.020,0.005,0.011,0.011,0.018,0.004,0.005,0.008,0.086,0.018,0.055,0.020,0.004],
[0.001,0.001,0.024,0.009,0.013,0.003,0.002,0.499,0.006,0.011,0.022,0.011,0.007,0.006,0.006,0.048,0.000,0.008,0.013,0.009,0.004,0.002,0.007,0.000,0.002,0.053,0.009,0.007,0.030,0.000,0.030,0.001,0.009,0.021,0.123],
[0.039,0.008,0.029,0.041,0.013,0.008,0.054,0.005,0.369,0.004,0.005,0.023,0.011,0.005,0.020,0.005,0.100,0.022,0.012,0.005,0.012,0.007,0.028,0.002,0.015,0.000,0.003,0.102,0.001,0.021,0.006,0.012,0.002,0.002,0.007],
[0.031,0.007,0.018,0.032,0.015,0.017,0.075,0.008,0.365,0.005,0.005,0.028,0.015,0.005,0.022,0.011,0.075,0.027,0.014,0.005,0.020,0.006,0.025,0.002,0.014,0.001,0.004,0.099,0.003,0.016,0.008,0.009,0.002,0.002,0.010],
[0.046,0.022,0.022,0.002,0.031,0.003,0.008,0.022,0.047,0.011,0.010,0.039,0.035,0.005,0.048,0.110,0.002,0.028,0.031,0.003,0.029,0.006,0.016,0.022,0.007,0.059,0.289,0.005,0.016,0.003,0.013,0.004,0.002,0.004,0.003],
[0.019,0.004,0.002,0.000,0.134,0.004,0.088,0.006,0.004,0.003,0.016,0.007,0.037,0.004,0.016,0.014,0.002,0.014,0.026,0.005,0.342,0.019,0.049,0.024,0.004,0.003,0.021,0.009,0.005,0.009,0.049,0.012,0.017,0.026,0.006]]
KR8877J_2 = [[0.002,0.005,0.005,0.046,0.002,0.014,0.008,0.073,0.002,0.023,0.042,0.004,0.007,0.027,0.001,0.003,0.001,0.006,0.047,0.384,0.005,0.006,0.015,0.003,0.006,0.004,0.011,0.006,0.006,0.005,0.088,0.027,0.066,0.040,0.010],
[0.002,0.005,0.005,0.039,0.002,0.009,0.005,0.089,0.001,0.036,0.043,0.004,0.006,0.026,0.001,0.002,0.001,0.006,0.051,0.387,0.003,0.005,0.014,0.003,0.007,0.007,0.014,0.004,0.007,0.005,0.090,0.022,0.064,0.030,0.006],
[0.002,0.001,0.014,0.011,0.020,0.005,0.004,0.282,0.005,0.012,0.022,0.011,0.009,0.010,0.008,0.041,0.000,0.017,0.030,0.019,0.009,0.003,0.009,0.000,0.004,0.053,0.010,0.016,0.049,0.000,0.043,0.002,0.017,0.037,0.224],
[0.028,0.015,0.029,0.039,0.023,0.020,0.097,0.008,0.239,0.004,0.009,0.021,0.019,0.008,0.017,0.008,0.082,0.023,0.025,0.012,0.020,0.010,0.037,0.003,0.016,0.001,0.003,0.110,0.003,0.019,0.012,0.014,0.004,0.005,0.015],
[0.037,0.013,0.035,0.053,0.025,0.022,0.057,0.017,0.250,0.005,0.009,0.037,0.025,0.008,0.029,0.013,0.057,0.029,0.029,0.009,0.015,0.009,0.027,0.002,0.020,0.002,0.006,0.092,0.006,0.012,0.011,0.011,0.003,0.004,0.021],
[0.036,0.022,0.024,0.003,0.022,0.004,0.011,0.019,0.069,0.014,0.011,0.035,0.045,0.006,0.057,0.096,0.004,0.037,0.030,0.004,0.039,0.007,0.021,0.018,0.010,0.031,0.256,0.013,0.018,0.003,0.018,0.005,0.004,0.006,0.004],
[0.015,0.003,0.002,0.000,0.174,0.004,0.085,0.008,0.005,0.002,0.015,0.008,0.028,0.003,0.013,0.016,0.001,0.015,0.029,0.004,0.357,0.013,0.043,0.017,0.003,0.003,0.017,0.010,0.004,0.007,0.037,0.013,0.015,0.020,0.010]]
KR8877J_3 = [[0.005,0.006,0.006,0.055,0.002,0.017,0.009,0.076,0.003,0.035,0.032,0.007,0.005,0.050,0.001,0.002,0.002,0.011,0.050,0.391,0.002,0.005,0.018,0.003,0.012,0.009,0.009,0.005,0.005,0.012,0.068,0.032,0.032,0.017,0.006],
[0.009,0.005,0.007,0.064,0.002,0.022,0.009,0.040,0.003,0.030,0.026,0.010,0.006,0.069,0.001,0.001,0.004,0.011,0.040,0.379,0.002,0.009,0.021,0.005,0.017,0.007,0.009,0.005,0.003,0.034,0.063,0.035,0.029,0.017,0.006],
[0.001,0.001,0.014,0.011,0.011,0.004,0.003,0.458,0.004,0.012,0.023,0.010,0.007,0.009,0.006,0.039,0.000,0.012,0.016,0.014,0.005,0.003,0.007,0.000,0.002,0.052,0.008,0.009,0.039,0.000,0.036,0.001,0.013,0.032,0.139],
[0.042,0.012,0.023,0.029,0.043,0.015,0.111,0.010,0.235,0.004,0.009,0.036,0.023,0.010,0.018,0.010,0.039,0.029,0.024,0.012,0.025,0.009,0.041,0.003,0.019,0.002,0.005,0.084,0.004,0.018,0.013,0.012,0.004,0.005,0.023],
[0.030,0.008,0.017,0.033,0.011,0.020,0.103,0.009,0.289,0.004,0.006,0.030,0.022,0.007,0.021,0.011,0.108,0.031,0.013,0.008,0.020,0.006,0.023,0.002,0.018,0.001,0.004,0.102,0.005,0.012,0.007,0.007,0.002,0.003,0.009],
[0.034,0.024,0.018,0.003,0.025,0.005,0.008,0.025,0.053,0.010,0.008,0.045,0.036,0.006,0.050,0.119,0.002,0.035,0.028,0.003,0.029,0.005,0.014,0.017,0.007,0.060,0.275,0.006,0.019,0.002,0.013,0.004,0.003,0.006,0.005],
[0.016,0.004,0.002,0.000,0.130,0.003,0.080,0.005,0.004,0.003,0.017,0.005,0.038,0.002,0.015,0.014,0.002,0.011,0.027,0.004,0.378,0.016,0.051,0.019,0.004,0.002,0.020,0.012,0.004,0.006,0.040,0.013,0.023,0.020,0.008]]
KR8877J_4 = [[0.006,0.004,0.007,0.052,0.002,0.012,0.005,0.066,0.002,0.043,0.036,0.007,0.007,0.051,0.001,0.001,0.002,0.008,0.037,0.401,0.002,0.008,0.017,0.004,0.013,0.010,0.014,0.004,0.004,0.016,0.077,0.021,0.038,0.018,0.006],
[0.001,0.001,0.012,0.008,0.013,0.004,0.002,0.462,0.004,0.011,0.022,0.008,0.006,0.006,0.006,0.052,0.000,0.012,0.018,0.012,0.005,0.002,0.007,0.000,0.002,0.046,0.009,0.009,0.040,0.000,0.039,0.002,0.012,0.031,0.136],
[0.004,0.003,0.007,0.042,0.001,0.008,0.005,0.060,0.002,0.062,0.050,0.005,0.004,0.053,0.000,0.001,0.002,0.006,0.033,0.422,0.001,0.008,0.017,0.004,0.011,0.007,0.010,0.003,0.002,0.013,0.065,0.024,0.045,0.017,0.003],
[0.029,0.015,0.032,0.058,0.018,0.013,0.067,0.012,0.287,0.006,0.010,0.025,0.016,0.007,0.017,0.009,0.059,0.023,0.026,0.011,0.016,0.006,0.033,0.003,0.017,0.001,0.006,0.118,0.004,0.014,0.009,0.012,0.004,0.003,0.012],
[0.056,0.011,0.024,0.034,0.027,0.015,0.065,0.013,0.271,0.006,0.007,0.062,0.028,0.013,0.026,0.014,0.030,0.039,0.027,0.011,0.019,0.006,0.031,0.003,0.027,0.005,0.009,0.061,0.006,0.014,0.011,0.006,0.002,0.004,0.016],
[0.041,0.020,0.022,0.002,0.019,0.004,0.007,0.024,0.046,0.016,0.008,0.051,0.036,0.006,0.051,0.109,0.002,0.030,0.027,0.003,0.024,0.005,0.015,0.017,0.008,0.067,0.286,0.005,0.015,0.003,0.014,0.003,0.002,0.005,0.003],
[0.014,0.003,0.002,0.000,0.106,0.007,0.079,0.007,0.004,0.003,0.014,0.010,0.041,0.004,0.013,0.011,0.001,0.014,0.031,0.007,0.377,0.022,0.049,0.017,0.004,0.003,0.014,0.009,0.004,0.009,0.050,0.013,0.016,0.034,0.008]]
KR8877J_5 = [[0.008,0.004,0.008,0.064,0.001,0.018,0.009,0.041,0.003,0.043,0.035,0.008,0.005,0.076,0.001,0.001,0.004,0.009,0.037,0.382,0.001,0.011,0.024,0.005,0.015,0.006,0.007,0.005,0.002,0.030,0.057,0.031,0.029,0.017,0.004],
[0.002,0.004,0.004,0.044,0.001,0.012,0.005,0.068,0.001,0.043,0.052,0.003,0.005,0.030,0.001,0.002,0.001,0.007,0.041,0.350,0.003,0.007,0.019,0.005,0.007,0.004,0.011,0.005,0.003,0.007,0.099,0.035,0.076,0.038,0.004],
[0.001,0.001,0.015,0.011,0.009,0.004,0.002,0.517,0.004,0.012,0.028,0.007,0.005,0.007,0.005,0.035,0.000,0.011,0.014,0.012,0.005,0.003,0.010,0.000,0.002,0.030,0.006,0.009,0.029,0.000,0.039,0.002,0.016,0.034,0.114],
[0.026,0.010,0.036,0.064,0.011,0.009,0.052,0.010,0.360,0.004,0.007,0.022,0.015,0.005,0.017,0.006,0.067,0.019,0.017,0.008,0.013,0.006,0.026,0.002,0.015,0.001,0.004,0.121,0.003,0.011,0.006,0.010,0.003,0.002,0.011],
[0.044,0.017,0.027,0.037,0.024,0.016,0.079,0.010,0.259,0.006,0.009,0.032,0.023,0.009,0.022,0.012,0.064,0.031,0.026,0.010,0.019,0.007,0.034,0.004,0.021,0.002,0.007,0.086,0.005,0.018,0.011,0.011,0.003,0.003,0.011],
[0.033,0.013,0.021,0.002,0.014,0.003,0.006,0.023,0.033,0.015,0.009,0.048,0.040,0.007,0.056,0.098,0.002,0.032,0.023,0.003,0.023,0.006,0.013,0.015,0.009,0.069,0.331,0.005,0.018,0.002,0.012,0.003,0.002,0.005,0.003],
[0.017,0.004,0.002,0.000,0.096,0.008,0.095,0.007,0.004,0.003,0.013,0.012,0.045,0.006,0.017,0.013,0.002,0.016,0.029,0.007,0.360,0.023,0.045,0.023,0.005,0.004,0.018,0.008,0.005,0.010,0.042,0.011,0.013,0.032,0.007]]
KR8877J_6 = [[0.007,0.004,0.007,0.082,0.002,0.023,0.009,0.029,0.003,0.024,0.024,0.008,0.006,0.062,0.001,0.001,0.005,0.009,0.032,0.391,0.002,0.012,0.020,0.005,0.016,0.004,0.006,0.006,0.002,0.037,0.061,0.041,0.033,0.019,0.006],
[0.004,0.004,0.008,0.078,0.001,0.013,0.005,0.059,0.002,0.044,0.041,0.006,0.005,0.052,0.001,0.001,0.002,0.008,0.036,0.366,0.001,0.010,0.015,0.003,0.011,0.008,0.008,0.005,0.004,0.015,0.074,0.035,0.045,0.023,0.007],
[0.001,0.001,0.013,0.010,0.015,0.006,0.004,0.299,0.004,0.011,0.021,0.011,0.009,0.010,0.009,0.044,0.000,0.021,0.023,0.017,0.008,0.004,0.007,0.000,0.003,0.056,0.008,0.014,0.056,0.000,0.040,0.002,0.016,0.039,0.217],
[0.021,0.011,0.022,0.060,0.018,0.026,0.090,0.014,0.234,0.005,0.011,0.025,0.016,0.009,0.015,0.011,0.052,0.030,0.029,0.015,0.019,0.007,0.030,0.003,0.016,0.001,0.003,0.134,0.006,0.013,0.011,0.014,0.004,0.005,0.020],
[0.031,0.012,0.027,0.036,0.023,0.020,0.053,0.018,0.269,0.006,0.008,0.029,0.036,0.007,0.029,0.021,0.046,0.030,0.028,0.009,0.023,0.007,0.027,0.003,0.020,0.002,0.010,0.098,0.010,0.009,0.016,0.009,0.004,0.005,0.018],
[0.036,0.019,0.017,0.002,0.027,0.004,0.009,0.027,0.063,0.012,0.008,0.045,0.035,0.006,0.050,0.140,0.002,0.036,0.030,0.003,0.031,0.004,0.017,0.016,0.007,0.055,0.239,0.007,0.018,0.002,0.014,0.004,0.003,0.006,0.004],
[0.018,0.004,0.002,0.000,0.186,0.004,0.107,0.005,0.005,0.003,0.010,0.008,0.041,0.004,0.017,0.018,0.001,0.012,0.034,0.004,0.300,0.014,0.036,0.018,0.004,0.004,0.020,0.010,0.005,0.008,0.049,0.009,0.011,0.020,0.008]]

KR508WW_1 = [[0.006,0.022,0.004,0.041,0.023,0.045,0.008,0.062,0.008,0.005,0.019,0.008,0.003,0.005,0.004,0.021,0.002,0.055,0.037,0.029,0.019,0.004,0.025,0.022,0.003,0.005,0.017,0.014,0.007,0.012,0.038,0.303,0.078,0.030,0.018],[0.007,0.043,0.002,0.003,0.034,0.016,0.018,0.005,0.003,0.005,0.018,0.002,0.007,0.002,0.012,0.016,0.005,0.046,0.046,0.008,0.108,0.013,0.055,0.121,0.002,0.001,0.022,0.016,0.003,0.013,0.040,0.198,0.057,0.050,0.004],[0.037,0.016,0.016,0.006,0.056,0.013,0.073,0.014,0.030,0.016,0.027,0.009,0.034,0.011,0.029,0.015,0.018,0.033,0.059,0.018,0.080,0.030,0.057,0.021,0.019,0.004,0.017,0.045,0.009,0.020,0.043,0.045,0.039,0.020,0.021],[0.001,0.004,0.004,0.045,0.001,0.505,0.058,0.008,0.006,0.002,0.002,0.022,0.011,0.022,0.052,0.009,0.020,0.018,0.028,0.022,0.009,0.007,0.002,0.001,0.005,0.001,0.001,0.055,0.017,0.002,0.007,0.006,0.002,0.029,0.013],[0.031,0.023,0.019,0.004,0.011,0.006,0.011,0.020,0.041,0.016,0.016,0.030,0.045,0.006,0.043,0.063,0.006,0.033,0.025,0.007,0.048,0.007,0.019,0.039,0.008,0.015,0.341,0.012,0.011,0.003,0.015,0.009,0.007,0.006,0.003],[0.004,0.031,0.002,0.004,0.089,0.008,0.033,0.009,0.002,0.004,0.021,0.003,0.018,0.003,0.006,0.011,0.001,0.013,0.088,0.025,0.153,0.015,0.032,0.017,0.005,0.002,0.019,0.024,0.020,0.003,0.073,0.057,0.103,0.082,0.019]]
KR508WW_2 = [[0.024,0.037,0.003,0.003,0.114,0.036,0.056,0.010,0.014,0.005,0.017,0.025,0.005,0.010,0.010,0.028,0.004,0.123,0.088,0.011,0.021,0.011,0.032,0.049,0.004,0.009,0.011,0.013,0.006,0.052,0.027,0.117,0.007,0.009,0.008],[0.020,0.005,0.020,0.037,0.010,0.019,0.068,0.010,0.346,0.006,0.005,0.025,0.016,0.006,0.023,0.014,0.061,0.028,0.019,0.009,0.018,0.006,0.027,0.002,0.014,0.001,0.004,0.129,0.004,0.013,0.009,0.009,0.002,0.003,0.013],[0.024,0.023,0.007,0.008,0.081,0.018,0.070,0.007,0.008,0.007,0.016,0.031,0.017,0.063,0.004,0.003,0.003,0.053,0.084,0.104,0.019,0.026,0.056,0.005,0.056,0.018,0.006,0.015,0.014,0.028,0.046,0.012,0.013,0.035,0.020],[0.001,0.005,0.003,0.038,0.002,0.527,0.075,0.007,0.007,0.003,0.002,0.031,0.009,0.025,0.032,0.007,0.021,0.019,0.024,0.028,0.008,0.007,0.003,0.002,0.006,0.001,0.001,0.044,0.010,0.003,0.007,0.007,0.002,0.022,0.011],[0.031,0.013,0.018,0.002,0.012,0.003,0.007,0.028,0.022,0.021,0.019,0.035,0.036,0.009,0.044,0.086,0.002,0.034,0.029,0.005,0.028,0.007,0.015,0.026,0.008,0.066,0.338,0.005,0.019,0.002,0.014,0.004,0.004,0.006,0.002],[0.008,0.002,0.002,0.001,0.090,0.002,0.036,0.007,0.003,0.002,0.024,0.003,0.036,0.003,0.006,0.009,0.001,0.011,0.031,0.011,0.448,0.010,0.054,0.008,0.004,0.002,0.018,0.015,0.004,0.003,0.049,0.011,0.046,0.031,0.014]]
KR508WW_3 = [[0.012,0.059,0.002,0.007,0.019,0.034,0.011,0.007,0.006,0.004,0.009,0.008,0.003,0.003,0.006,0.013,0.004,0.072,0.032,0.013,0.015,0.007,0.012,0.102,0.002,0.004,0.025,0.006,0.003,0.029,0.013,0.427,0.020,0.007,0.004],[0.009,0.072,0.003,0.007,0.035,0.035,0.007,0.015,0.011,0.005,0.006,0.007,0.007,0.002,0.013,0.061,0.003,0.081,0.074,0.007,0.020,0.005,0.016,0.051,0.002,0.008,0.053,0.012,0.010,0.016,0.048,0.254,0.018,0.018,0.010],[0.024,0.006,0.023,0.039,0.014,0.031,0.098,0.011,0.270,0.005,0.007,0.028,0.020,0.008,0.023,0.013,0.071,0.027,0.023,0.010,0.019,0.009,0.026,0.002,0.016,0.001,0.003,0.112,0.005,0.015,0.009,0.010,0.002,0.004,0.016],[0.279,0.011,0.042,0.008,0.009,0.002,0.024,0.005,0.046,0.028,0.012,0.013,0.063,0.017,0.015,0.004,0.106,0.013,0.019,0.012,0.006,0.015,0.037,0.011,0.086,0.008,0.030,0.010,0.003,0.049,0.010,0.003,0.002,0.001,0.002],[0.001,0.004,0.003,0.085,0.001,0.557,0.023,0.007,0.004,0.004,0.002,0.017,0.005,0.032,0.029,0.005,0.025,0.022,0.028,0.028,0.003,0.006,0.002,0.002,0.005,0.001,0.001,0.037,0.009,0.003,0.009,0.011,0.003,0.022,0.006],[0.044,0.025,0.023,0.002,0.025,0.004,0.006,0.024,0.056,0.014,0.008,0.045,0.029,0.006,0.053,0.116,0.003,0.036,0.025,0.002,0.022,0.005,0.019,0.019,0.007,0.062,0.270,0.005,0.013,0.003,0.013,0.004,0.002,0.005,0.003],[0.014,0.001,0.003,0.000,0.086,0.002,0.052,0.009,0.007,0.003,0.020,0.006,0.039,0.004,0.009,0.010,0.001,0.014,0.022,0.009,0.430,0.015,0.059,0.007,0.005,0.003,0.015,0.015,0.003,0.005,0.049,0.011,0.027,0.022,0.021]]
KR508WW_4 = [[0.005,0.060,0.001,0.009,0.015,0.060,0.006,0.010,0.005,0.003,0.005,0.005,0.003,0.002,0.005,0.025,0.003,0.059,0.042,0.008,0.011,0.004,0.007,0.056,0.001,0.003,0.019,0.007,0.004,0.020,0.021,0.486,0.017,0.009,0.006],[0.016,0.069,0.004,0.004,0.089,0.021,0.017,0.011,0.016,0.005,0.008,0.009,0.011,0.002,0.018,0.070,0.003,0.069,0.067,0.005,0.048,0.006,0.030,0.065,0.002,0.008,0.053,0.013,0.008,0.020,0.040,0.151,0.016,0.017,0.010],[0.041,0.006,0.028,0.030,0.015,0.008,0.070,0.007,0.399,0.004,0.006,0.027,0.015,0.006,0.018,0.007,0.068,0.024,0.013,0.005,0.013,0.006,0.033,0.002,0.015,0.001,0.003,0.085,0.002,0.017,0.005,0.008,0.001,0.002,0.008],[0.315,0.009,0.027,0.008,0.009,0.002,0.011,0.004,0.032,0.039,0.006,0.010,0.063,0.022,0.010,0.003,0.058,0.012,0.024,0.016,0.005,0.010,0.022,0.008,0.137,0.017,0.043,0.008,0.004,0.047,0.012,0.002,0.002,0.001,0.002],[0.001,0.010,0.003,0.105,0.001,0.457,0.016,0.020,0.003,0.011,0.005,0.016,0.005,0.036,0.015,0.009,0.013,0.020,0.062,0.048,0.003,0.006,0.002,0.004,0.006,0.003,0.003,0.020,0.016,0.004,0.020,0.019,0.006,0.027,0.005],[0.034,0.016,0.018,0.002,0.016,0.004,0.006,0.028,0.034,0.014,0.009,0.049,0.033,0.007,0.051,0.115,0.002,0.035,0.024,0.003,0.023,0.005,0.013,0.019,0.007,0.072,0.312,0.004,0.016,0.002,0.011,0.003,0.002,0.005,0.003],[0.011,0.002,0.003,0.001,0.103,0.002,0.048,0.006,0.006,0.003,0.024,0.003,0.036,0.003,0.008,0.008,0.001,0.010,0.028,0.008,0.421,0.014,0.063,0.008,0.004,0.002,0.014,0.020,0.003,0.004,0.048,0.011,0.038,0.023,0.015]]
KR508WW_5 = [[0.003,0.029,0.001,0.009,0.008,0.048,0.005,0.007,0.004,0.002,0.003,0.003,0.002,0.001,0.003,0.017,0.002,0.043,0.033,0.010,0.007,0.003,0.004,0.029,0.001,0.002,0.011,0.006,0.003,0.019,0.020,0.635,0.015,0.006,0.007],[0.012,0.091,0.002,0.005,0.052,0.037,0.010,0.009,0.007,0.004,0.006,0.008,0.008,0.003,0.010,0.041,0.002,0.064,0.073,0.009,0.024,0.006,0.017,0.076,0.002,0.008,0.052,0.007,0.006,0.027,0.043,0.239,0.016,0.016,0.008],[0.029,0.011,0.031,0.043,0.018,0.019,0.090,0.008,0.236,0.004,0.010,0.026,0.025,0.011,0.022,0.007,0.065,0.026,0.030,0.012,0.017,0.014,0.032,0.002,0.022,0.001,0.003,0.117,0.005,0.015,0.011,0.010,0.003,0.005,0.019],[0.330,0.006,0.020,0.009,0.007,0.002,0.015,0.004,0.031,0.030,0.009,0.012,0.047,0.029,0.008,0.002,0.058,0.014,0.016,0.019,0.005,0.011,0.024,0.008,0.183,0.012,0.024,0.008,0.003,0.043,0.007,0.002,0.002,0.001,0.002],[0.001,0.004,0.002,0.067,0.001,0.644,0.015,0.007,0.002,0.005,0.002,0.020,0.003,0.031,0.017,0.006,0.009,0.018,0.030,0.027,0.002,0.006,0.001,0.002,0.003,0.001,0.001,0.015,0.005,0.004,0.010,0.014,0.002,0.020,0.004],[0.032,0.022,0.024,0.002,0.018,0.006,0.010,0.027,0.038,0.016,0.012,0.046,0.037,0.007,0.058,0.110,0.003,0.041,0.026,0.005,0.037,0.007,0.019,0.024,0.008,0.046,0.257,0.006,0.017,0.002,0.013,0.006,0.004,0.008,0.004],[0.014,0.003,0.002,0.000,0.087,0.005,0.097,0.007,0.004,0.003,0.017,0.007,0.041,0.004,0.015,0.013,0.002,0.013,0.024,0.006,0.413,0.018,0.046,0.017,0.004,0.002,0.016,0.011,0.005,0.006,0.038,0.010,0.018,0.023,0.008]]
KR508WW_6 = [[0.008,0.069,0.002,0.006,0.029,0.041,0.010,0.008,0.006,0.003,0.006,0.007,0.004,0.002,0.008,0.036,0.002,0.060,0.052,0.009,0.017,0.004,0.010,0.081,0.001,0.006,0.030,0.006,0.005,0.025,0.021,0.397,0.016,0.009,0.007],[0.010,0.087,0.002,0.008,0.019,0.041,0.008,0.006,0.005,0.004,0.006,0.006,0.004,0.003,0.010,0.025,0.004,0.057,0.047,0.010,0.017,0.006,0.010,0.100,0.002,0.005,0.041,0.008,0.006,0.027,0.024,0.357,0.019,0.011,0.004],[0.032,0.009,0.039,0.034,0.019,0.017,0.078,0.014,0.252,0.008,0.010,0.029,0.031,0.011,0.024,0.013,0.052,0.025,0.032,0.012,0.016,0.011,0.041,0.002,0.023,0.002,0.005,0.091,0.006,0.014,0.014,0.008,0.003,0.005,0.018],[0.368,0.005,0.019,0.009,0.010,0.002,0.025,0.004,0.059,0.019,0.007,0.017,0.038,0.025,0.011,0.002,0.068,0.016,0.013,0.012,0.006,0.010,0.029,0.008,0.116,0.010,0.018,0.009,0.002,0.051,0.005,0.003,0.002,0.001,0.002],[0.001,0.004,0.002,0.055,0.001,0.660,0.017,0.005,0.003,0.004,0.001,0.022,0.003,0.025,0.024,0.007,0.011,0.020,0.026,0.020,0.003,0.005,0.001,0.002,0.003,0.001,0.001,0.022,0.006,0.003,0.008,0.011,0.002,0.020,0.005],[0.039,0.015,0.019,0.001,0.027,0.004,0.009,0.028,0.057,0.012,0.007,0.062,0.041,0.006,0.054,0.141,0.002,0.029,0.029,0.003,0.026,0.005,0.015,0.012,0.007,0.082,0.221,0.004,0.016,0.002,0.013,0.002,0.002,0.005,0.005],[0.019,0.003,0.002,0.000,0.203,0.003,0.075,0.007,0.004,0.003,0.017,0.007,0.033,0.003,0.010,0.010,0.001,0.011,0.028,0.004,0.331,0.019,0.050,0.015,0.004,0.003,0.016,0.009,0.003,0.008,0.045,0.011,0.015,0.020,0.009]]
KR508WW_7 = [[0.006,0.080,0.002,0.009,0.017,0.070,0.009,0.011,0.004,0.004,0.006,0.009,0.003,0.003,0.007,0.032,0.002,0.064,0.053,0.013,0.012,0.005,0.007,0.074,0.002,0.010,0.026,0.004,0.007,0.022,0.021,0.368,0.017,0.015,0.006],[0.009,0.081,0.003,0.005,0.035,0.041,0.019,0.008,0.011,0.005,0.006,0.008,0.009,0.003,0.019,0.043,0.004,0.068,0.069,0.009,0.040,0.008,0.020,0.073,0.002,0.005,0.038,0.016,0.008,0.019,0.037,0.227,0.019,0.023,0.009],[0.041,0.007,0.025,0.017,0.026,0.016,0.109,0.009,0.280,0.005,0.007,0.050,0.032,0.010,0.026,0.014,0.035,0.029,0.024,0.010,0.023,0.010,0.034,0.002,0.019,0.003,0.005,0.066,0.004,0.016,0.011,0.008,0.002,0.004,0.018],[0.372,0.008,0.019,0.008,0.010,0.002,0.019,0.004,0.047,0.031,0.006,0.016,0.037,0.025,0.010,0.003,0.053,0.017,0.018,0.013,0.006,0.008,0.029,0.010,0.110,0.013,0.024,0.007,0.002,0.060,0.007,0.003,0.002,0.001,0.002],[0.001,0.006,0.002,0.054,0.001,0.599,0.029,0.008,0.003,0.005,0.003,0.025,0.004,0.031,0.023,0.007,0.011,0.018,0.029,0.029,0.004,0.007,0.002,0.002,0.003,0.001,0.001,0.020,0.007,0.003,0.010,0.011,0.003,0.033,0.005],[0.049,0.016,0.042,0.002,0.017,0.002,0.009,0.019,0.048,0.024,0.015,0.045,0.048,0.008,0.054,0.062,0.003,0.025,0.028,0.005,0.027,0.010,0.021,0.017,0.015,0.055,0.281,0.007,0.014,0.003,0.015,0.003,0.004,0.005,0.003],[0.015,0.002,0.003,0.001,0.109,0.002,0.063,0.007,0.008,0.004,0.021,0.005,0.048,0.004,0.011,0.010,0.002,0.010,0.029,0.008,0.362,0.019,0.065,0.008,0.007,0.002,0.015,0.018,0.005,0.006,0.061,0.008,0.026,0.023,0.013]]
KR508WW_8 = [[0.006,0.070,0.001,0.011,0.013,0.053,0.004,0.010,0.003,0.003,0.005,0.005,0.002,0.002,0.003,0.019,0.001,0.054,0.042,0.014,0.007,0.003,0.006,0.062,0.001,0.006,0.028,0.004,0.004,0.020,0.019,0.484,0.021,0.008,0.005],[0.008,0.057,0.003,0.005,0.143,0.022,0.017,0.020,0.007,0.004,0.017,0.010,0.006,0.003,0.011,0.052,0.001,0.073,0.094,0.008,0.055,0.007,0.034,0.047,0.002,0.009,0.025,0.012,0.012,0.010,0.041,0.098,0.028,0.046,0.015],[0.017,0.012,0.023,0.079,0.011,0.036,0.066,0.023,0.124,0.011,0.010,0.035,0.024,0.021,0.019,0.010,0.033,0.042,0.035,0.039,0.019,0.008,0.033,0.002,0.040,0.003,0.005,0.115,0.015,0.008,0.020,0.009,0.007,0.016,0.028],[0.277,0.007,0.025,0.012,0.007,0.003,0.022,0.004,0.042,0.037,0.009,0.019,0.058,0.034,0.013,0.002,0.052,0.013,0.023,0.024,0.008,0.013,0.026,0.011,0.139,0.011,0.033,0.011,0.003,0.046,0.008,0.003,0.003,0.001,0.002],[0.073,0.013,0.063,0.005,0.048,0.001,0.012,0.040,0.124,0.008,0.022,0.084,0.037,0.008,0.028,0.053,0.002,0.035,0.022,0.005,0.017,0.005,0.024,0.005,0.017,0.064,0.126,0.010,0.021,0.002,0.009,0.002,0.002,0.003,0.008],[0.015,0.002,0.001,0.000,0.361,0.001,0.046,0.015,0.002,0.002,0.025,0.010,0.026,0.004,0.003,0.016,0.000,0.012,0.031,0.007,0.233,0.005,0.043,0.005,0.003,0.011,0.020,0.004,0.006,0.002,0.037,0.005,0.010,0.017,0.017]]

KR8R544_1 = [[0.016,0.012,0.001,0.000,0.722,0.000,0.020,0.004,0.001,0.002,0.011,0.003,0.003,0.002,0.001,0.003,0.000,0.005,0.031,0.006,0.033,0.001,0.031,0.008,0.002,0.005,0.012,0.003,0.001,0.005,0.022,0.007,0.013,0.006,0.007],[0.001,0.004,0.002,0.057,0.001,0.573,0.029,0.005,0.005,0.002,0.002,0.013,0.008,0.014,0.032,0.008,0.032,0.021,0.023,0.021,0.006,0.005,0.002,0.001,0.004,0.000,0.001,0.063,0.012,0.003,0.009,0.013,0.003,0.017,0.008],[0.051,0.023,0.027,0.003,0.052,0.002,0.010,0.018,0.088,0.006,0.014,0.034,0.044,0.004,0.033,0.075,0.003,0.032,0.030,0.004,0.047,0.005,0.019,0.018,0.009,0.029,0.264,0.010,0.014,0.003,0.014,0.005,0.004,0.003,0.005],[0.052,0.009,0.034,0.032,0.025,0.007,0.066,0.009,0.377,0.003,0.009,0.034,0.018,0.006,0.020,0.007,0.048,0.025,0.013,0.006,0.016,0.007,0.034,0.003,0.015,0.001,0.005,0.074,0.003,0.015,0.006,0.009,0.002,0.002,0.011],[0.038,0.021,0.011,0.002,0.017,0.005,0.011,0.017,0.048,0.009,0.007,0.039,0.037,0.005,0.051,0.135,0.004,0.037,0.027,0.003,0.031,0.005,0.014,0.028,0.006,0.034,0.305,0.008,0.016,0.003,0.014,0.005,0.002,0.004,0.002],[0.018,0.003,0.002,0.000,0.154,0.003,0.086,0.006,0.005,0.003,0.015,0.007,0.037,0.004,0.014,0.011,0.001,0.011,0.031,0.005,0.337,0.019,0.050,0.017,0.004,0.003,0.017,0.011,0.004,0.009,0.052,0.011,0.018,0.024,0.008]]
KR8R544_2 = [[0.032,0.019,0.001,0.000,0.627,0.000,0.030,0.004,0.002,0.004,0.015,0.004,0.003,0.004,0.001,0.002,0.000,0.011,0.034,0.009,0.025,0.002,0.049,0.016,0.004,0.010,0.014,0.004,0.001,0.012,0.020,0.010,0.017,0.007,0.005],[0.021,0.025,0.001,0.000,0.612,0.000,0.054,0.004,0.002,0.003,0.014,0.004,0.003,0.004,0.001,0.003,0.000,0.009,0.034,0.009,0.035,0.002,0.046,0.016,0.003,0.005,0.010,0.005,0.001,0.011,0.022,0.014,0.016,0.009,0.005],[0.001,0.008,0.003,0.054,0.001,0.525,0.032,0.009,0.006,0.003,0.002,0.018,0.011,0.020,0.035,0.010,0.028,0.020,0.033,0.028,0.006,0.004,0.002,0.002,0.006,0.001,0.002,0.054,0.019,0.002,0.011,0.011,0.003,0.021,0.007],[0.058,0.022,0.039,0.002,0.046,0.002,0.013,0.016,0.087,0.014,0.019,0.031,0.052,0.005,0.036,0.054,0.004,0.026,0.034,0.004,0.052,0.007,0.031,0.020,0.010,0.020,0.233,0.012,0.010,0.004,0.019,0.004,0.005,0.004,0.004],[0.025,0.012,0.031,0.048,0.013,0.013,0.055,0.012,0.321,0.006,0.008,0.022,0.019,0.006,0.024,0.012,0.056,0.023,0.025,0.009,0.019,0.005,0.029,0.003,0.014,0.001,0.008,0.126,0.005,0.011,0.010,0.011,0.004,0.003,0.011],[0.037,0.032,0.020,0.003,0.029,0.006,0.012,0.021,0.055,0.011,0.010,0.037,0.040,0.007,0.060,0.113,0.004,0.039,0.034,0.003,0.035,0.007,0.019,0.023,0.008,0.040,0.225,0.010,0.022,0.003,0.016,0.006,0.004,0.007,0.004],[0.012,0.002,0.002,0.000,0.110,0.003,0.072,0.005,0.006,0.003,0.018,0.005,0.038,0.003,0.011,0.009,0.001,0.010,0.028,0.006,0.407,0.019,0.056,0.012,0.004,0.002,0.012,0.016,0.003,0.006,0.050,0.011,0.024,0.025,0.010]]
KR8R544_3 = [[0.019,0.019,0.001,0.000,0.720,0.000,0.026,0.003,0.001,0.002,0.011,0.003,0.003,0.002,0.001,0.002,0.000,0.005,0.031,0.007,0.030,0.001,0.025,0.012,0.002,0.007,0.014,0.002,0.001,0.005,0.016,0.005,0.013,0.006,0.004],[0.018,0.026,0.001,0.000,0.623,0.000,0.051,0.004,0.002,0.002,0.011,0.004,0.004,0.003,0.001,0.004,0.000,0.006,0.035,0.010,0.049,0.001,0.033,0.014,0.002,0.006,0.015,0.003,0.002,0.007,0.023,0.010,0.014,0.007,0.007],[0.001,0.003,0.002,0.033,0.001,0.694,0.026,0.005,0.004,0.001,0.001,0.017,0.005,0.013,0.026,0.009,0.017,0.016,0.015,0.015,0.004,0.003,0.001,0.001,0.003,0.001,0.000,0.036,0.010,0.002,0.006,0.007,0.001,0.016,0.006],[0.044,0.021,0.029,0.002,0.039,0.003,0.011,0.025,0.078,0.019,0.012,0.040,0.042,0.007,0.050,0.101,0.002,0.031,0.046,0.004,0.035,0.006,0.027,0.016,0.007,0.044,0.197,0.009,0.014,0.003,0.019,0.003,0.003,0.006,0.005],[0.053,0.021,0.022,0.027,0.043,0.021,0.119,0.016,0.157,0.005,0.014,0.048,0.030,0.015,0.019,0.014,0.034,0.039,0.032,0.017,0.027,0.007,0.043,0.006,0.023,0.004,0.010,0.058,0.007,0.018,0.014,0.010,0.004,0.006,0.015],[0.042,0.024,0.019,0.002,0.023,0.005,0.011,0.022,0.051,0.013,0.010,0.044,0.040,0.006,0.052,0.118,0.003,0.035,0.029,0.003,0.033,0.006,0.019,0.028,0.007,0.041,0.262,0.006,0.015,0.003,0.013,0.004,0.002,0.005,0.003],[0.015,0.002,0.002,0.000,0.105,0.003,0.077,0.006,0.005,0.003,0.019,0.006,0.037,0.004,0.012,0.010,0.002,0.012,0.025,0.006,0.402,0.017,0.054,0.016,0.004,0.002,0.016,0.013,0.004,0.007,0.046,0.011,0.023,0.023,0.009]]
KR8R544_4 = [[0.021,0.018,0.001,0.000,0.646,0.000,0.055,0.003,0.001,0.002,0.014,0.003,0.004,0.002,0.001,0.004,0.000,0.006,0.033,0.006,0.047,0.002,0.036,0.015,0.002,0.005,0.014,0.003,0.001,0.006,0.019,0.007,0.012,0.005,0.004],[0.015,0.020,0.001,0.000,0.574,0.000,0.043,0.005,0.002,0.002,0.013,0.003,0.006,0.002,0.001,0.006,0.000,0.005,0.050,0.010,0.068,0.002,0.042,0.012,0.002,0.005,0.019,0.004,0.002,0.006,0.035,0.010,0.017,0.009,0.009],[0.001,0.006,0.003,0.064,0.001,0.562,0.029,0.010,0.005,0.003,0.003,0.018,0.006,0.021,0.027,0.009,0.021,0.022,0.028,0.027,0.005,0.005,0.002,0.002,0.005,0.001,0.001,0.041,0.013,0.003,0.010,0.012,0.003,0.024,0.007],[0.042,0.020,0.021,0.003,0.017,0.004,0.012,0.020,0.074,0.016,0.010,0.045,0.049,0.007,0.051,0.082,0.004,0.033,0.030,0.005,0.038,0.005,0.018,0.020,0.009,0.030,0.274,0.012,0.014,0.003,0.016,0.004,0.003,0.005,0.004],[0.025,0.006,0.010,0.034,0.011,0.039,0.105,0.014,0.259,0.008,0.005,0.038,0.019,0.012,0.022,0.019,0.056,0.039,0.018,0.013,0.027,0.005,0.032,0.003,0.020,0.002,0.004,0.094,0.007,0.013,0.012,0.006,0.003,0.006,0.012],[0.037,0.027,0.014,0.002,0.027,0.005,0.011,0.018,0.053,0.008,0.008,0.031,0.047,0.005,0.044,0.111,0.004,0.032,0.028,0.003,0.040,0.005,0.014,0.027,0.007,0.032,0.293,0.009,0.019,0.003,0.018,0.006,0.003,0.006,0.003],[0.016,0.002,0.003,0.000,0.144,0.002,0.074,0.006,0.008,0.003,0.015,0.006,0.048,0.003,0.011,0.011,0.001,0.010,0.026,0.006,0.364,0.020,0.051,0.009,0.005,0.002,0.013,0.014,0.003,0.007,0.055,0.010,0.017,0.018,0.015]]
KR8R544_5 = [[0.029,0.023,0.001,0.000,0.651,0.000,0.040,0.006,0.001,0.003,0.016,0.004,0.003,0.003,0.001,0.005,0.000,0.009,0.031,0.006,0.024,0.001,0.045,0.014,0.002,0.013,0.016,0.002,0.002,0.007,0.018,0.006,0.008,0.005,0.003],[0.023,0.017,0.001,0.000,0.704,0.000,0.029,0.003,0.002,0.002,0.010,0.004,0.002,0.003,0.001,0.003,0.000,0.010,0.029,0.006,0.022,0.001,0.029,0.012,0.003,0.009,0.012,0.003,0.002,0.009,0.017,0.008,0.011,0.006,0.005],[0.001,0.002,0.002,0.025,0.001,0.603,0.078,0.005,0.007,0.001,0.001,0.025,0.008,0.015,0.030,0.008,0.019,0.017,0.015,0.016,0.008,0.006,0.002,0.001,0.004,0.000,0.000,0.047,0.009,0.002,0.004,0.005,0.001,0.016,0.013],[0.060,0.024,0.018,0.002,0.028,0.003,0.009,0.013,0.069,0.014,0.006,0.032,0.035,0.005,0.043,0.095,0.004,0.027,0.026,0.003,0.028,0.005,0.020,0.030,0.010,0.039,0.295,0.006,0.011,0.006,0.020,0.005,0.002,0.004,0.002],[0.058,0.010,0.022,0.022,0.042,0.012,0.071,0.016,0.243,0.005,0.009,0.041,0.044,0.013,0.023,0.013,0.028,0.036,0.022,0.012,0.035,0.007,0.032,0.004,0.029,0.005,0.013,0.063,0.008,0.012,0.013,0.006,0.005,0.006,0.020],[0.034,0.023,0.027,0.003,0.021,0.003,0.011,0.016,0.067,0.013,0.008,0.037,0.070,0.006,0.051,0.067,0.004,0.027,0.031,0.006,0.040,0.006,0.016,0.012,0.015,0.032,0.273,0.016,0.021,0.002,0.022,0.004,0.004,0.007,0.005],[0.018,0.003,0.001,0.000,0.500,0.001,0.051,0.004,0.002,0.001,0.013,0.006,0.024,0.002,0.006,0.012,0.000,0.009,0.035,0.003,0.151,0.011,0.035,0.007,0.003,0.004,0.013,0.005,0.003,0.006,0.040,0.006,0.006,0.011,0.007]]

#seq3 = (KR508WW_1, KR508WW_2, KR508WW_3, KR508WW_4, KR508WW_5, KR508WW_6, KR508WW_7, KR508WW_8)
seq = (KR8877J, KR8877J_1, KR8877J_2, KR8877J_3, KR8877J_4, KR8877J_5, KR8877J_6)
seq2 = (KR8R544_1, KR8R544_2, KR8R544_3, KR8R544_4, KR8R544_5)

def checklen():

    for a in seq:
        i = 0

        i = i + 1
        
        if (len(a[0]) == len(a[i])):
            #print("The same len", (a[0], a[i]))
            return print("Len of lists is equal")
        else:
            return print("Len of lists is not equal")

        #print(len(a))
            
def makelist(lst):
    
        lista = []
        for i in lst:
            index = np.argmax(i)
            lista.append(CATEGORIES[index])
        lista.reverse()
        return lista
 
def listaList():
    
    lists = []

    for a in seq:
        #print(makelist(a))
        lists.append(makelist(a))

        words = []
        freqs = []

        for i in lists:
           
            if i not in words: 
                words.append(i) 
                freqs.append(1)

            else:
                index = words.index(i) 
                freqs[index] += 1 
               
    print("Tests is succesfull, words:", (words), "probabilitys:", (freqs))


def listaList2():
    lists2 = []
    for a in seq2:
        #print(makelist(a))
        lists2.append(makelist(a))
        words = []
        freqs = []
        for i in lists2:
            if i not in words: 
                words.append(i) 
                freqs.append(1)
            else:
                index = words.index(i) 
                freqs[index] += 1 
    print("2 Tests is succesfull, words:", (words), "probabilitys:", (freqs))




def partition(nums, low, high):

    pivot = nums[(low + high) // 2]
    i = low - 1
    j = high + 1
    while True:
        i += 1
        while nums[i] < pivot:
            i += 1

        j -= 1
        while nums[j] > pivot:
            j -= 1

        if i >= j:
            return j

        nums[i], nums[j] = nums[j], nums[i]


def quick_sort(nums):

    def _quick_sort(items, low, high):
        if low < high:

            split_index = partition(items, low, high)
            _quick_sort(items, low, split_index)
            _quick_sort(items, split_index + 1, high)

    _quick_sort(nums, 0, len(nums) - 1)




if __name__ == "__main__":

    #checklen()
    #listaList()
    #listaList2()
    #a = 0

    max = -9999999
    max_index = 0
    max_list_from_all_plates = []

    threshold = 0.05
    

    for single_lp in seq:
        maximum_plate_prob = []
        possible_plate_prob = []
        max_list = []
        for sign in single_lp:
            high_indexes = []
            for prob_id in range(0,len(sign)):
                if threshold<sign[prob_id]:
                    high_indexes.append([sign[prob_id], prob_id, CATEGORIES[prob_id]])
            max_list.append(high_indexes)
        max_list_from_all_plates.append(max_list)


    for single_lp in max_list_from_all_plates:
        Highest_score=0

        for sign in single_lp:
            print(sign)

Результат это вероятности каждого символа, то есть для первого знака в первом списке [[0.077, 7, ‘7’], [0.058, 18, ‘I’], [0.352, 19, ‘J’], [0.089, 30, ‘V’], [0.053, 32, ‘X’]] и тд.:

[[0.077, 7, '7'], [0.058, 18, 'I'], [0.352, 19, 'J'], [0.089, 30, 'V'], [0.053, 32, 'X']]
[[0.075, 3, '3'], [0.36, 19, 'J'], [0.092, 30, 'V'], [0.058, 32, 'X']]
[[0.627, 7, '7'], [0.053, 34, 'Z']]
[[0.056, 0, '0'], [0.412, 8, '8'], [0.073, 16, 'G'], [0.074, 27, 'S']]
[[0.09, 6, '6'], [0.258, 8, '8'], [0.079, 16, 'G'], [0.106, 27, 'S']]
[[0.1, 15, 'F'], [0.317, 26, 'R']]
[[0.164, 4, '4'], [0.06, 6, '6'], [0.383, 20, 'K'], [0.063, 22, 'M']]
[[0.054, 7, '7'], [0.051, 10, 'A'], [0.056, 18, 'I'], [0.389, 19, 'J'], [0.07, 30, 'V']]
[[0.083, 7, '7'], [0.062, 9, '9'], [0.053, 10, 'A'], [0.055, 18, 'I'], [0.348, 19, 'J'], [0.086, 30, 'V'], [0.055, 32, 'X']]
[[0.499, 7, '7'], [0.053, 25, 'P'], [0.123, 34, 'Z']]
[[0.054, 6, '6'], [0.369, 8, '8'], [0.1, 16, 'G'], [0.102, 27, 'S']]
[[0.075, 6, '6'], [0.365, 8, '8'], [0.075, 16, 'G'], [0.099, 27, 'S']]
[[0.11, 15, 'F'], [0.059, 25, 'P'], [0.289, 26, 'R']]
[[0.134, 4, '4'], [0.088, 6, '6'], [0.342, 20, 'K']]
[[0.073, 7, '7'], [0.384, 19, 'J'], [0.088, 30, 'V'], [0.066, 32, 'X']]
[[0.089, 7, '7'], [0.051, 18, 'I'], [0.387, 19, 'J'], [0.09, 30, 'V'], [0.064, 32, 'X']]
[[0.282, 7, '7'], [0.053, 25, 'P'], [0.224, 34, 'Z']]
[[0.097, 6, '6'], [0.239, 8, '8'], [0.082, 16, 'G'], [0.11, 27, 'S']]
[[0.053, 3, '3'], [0.057, 6, '6'], [0.25, 8, '8'], [0.057, 16, 'G'], [0.092, 27, 'S']]
[[0.069, 8, '8'], [0.057, 14, 'E'], [0.096, 15, 'F'], [0.256, 26, 'R']]
[[0.174, 4, '4'], [0.085, 6, '6'], [0.357, 20, 'K']]
[[0.055, 3, '3'], [0.076, 7, '7'], [0.391, 19, 'J'], [0.068, 30, 'V']]
[[0.064, 3, '3'], [0.069, 13, 'D'], [0.379, 19, 'J'], [0.063, 30, 'V']]
[[0.458, 7, '7'], [0.052, 25, 'P'], [0.139, 34, 'Z']]
[[0.111, 6, '6'], [0.235, 8, '8'], [0.084, 27, 'S']]
[[0.103, 6, '6'], [0.289, 8, '8'], [0.108, 16, 'G'], [0.102, 27, 'S']]
[[0.053, 8, '8'], [0.119, 15, 'F'], [0.06, 25, 'P'], [0.275, 26, 'R']]
[[0.13, 4, '4'], [0.08, 6, '6'], [0.378, 20, 'K'], [0.051, 22, 'M']]
[[0.052, 3, '3'], [0.066, 7, '7'], [0.051, 13, 'D'], [0.401, 19, 'J'], [0.077, 30, 'V']]
[[0.462, 7, '7'], [0.052, 15, 'F'], [0.136, 34, 'Z']]
[[0.06, 7, '7'], [0.062, 9, '9'], [0.053, 13, 'D'], [0.422, 19, 'J'], [0.065, 30, 'V']]
[[0.058, 3, '3'], [0.067, 6, '6'], [0.287, 8, '8'], [0.059, 16, 'G'], [0.118, 27, 'S']]
[[0.056, 0, '0'], [0.065, 6, '6'], [0.271, 8, '8'], [0.062, 11, 'B'], [0.061, 27, 'S']]
[[0.051, 11, 'B'], [0.051, 14, 'E'], [0.109, 15, 'F'], [0.067, 25, 'P'], [0.286, 26, 'R']]
[[0.106, 4, '4'], [0.079, 6, '6'], [0.377, 20, 'K']]
[[0.064, 3, '3'], [0.076, 13, 'D'], [0.382, 19, 'J'], [0.057, 30, 'V']]
[[0.068, 7, '7'], [0.052, 10, 'A'], [0.35, 19, 'J'], [0.099, 30, 'V'], [0.076, 32, 'X']]
[[0.517, 7, '7'], [0.114, 34, 'Z']]
[[0.064, 3, '3'], [0.052, 6, '6'], [0.36, 8, '8'], [0.067, 16, 'G'], [0.121, 27, 'S']]
[[0.079, 6, '6'], [0.259, 8, '8'], [0.064, 16, 'G'], [0.086, 27, 'S']]
[[0.056, 14, 'E'], [0.098, 15, 'F'], [0.069, 25, 'P'], [0.331, 26, 'R']]
[[0.096, 4, '4'], [0.095, 6, '6'], [0.36, 20, 'K']]
[[0.082, 3, '3'], [0.062, 13, 'D'], [0.391, 19, 'J'], [0.061, 30, 'V']]
[[0.078, 3, '3'], [0.059, 7, '7'], [0.052, 13, 'D'], [0.366, 19, 'J'], [0.074, 30, 'V']]
[[0.299, 7, '7'], [0.056, 25, 'P'], [0.056, 28, 'T'], [0.217, 34, 'Z']]
[[0.06, 3, '3'], [0.09, 6, '6'], [0.234, 8, '8'], [0.052, 16, 'G'], [0.134, 27, 'S']]
[[0.053, 6, '6'], [0.269, 8, '8'], [0.098, 27, 'S']]
[[0.063, 8, '8'], [0.14, 15, 'F'], [0.055, 25, 'P'], [0.239, 26, 'R']]
[[0.186, 4, '4'], [0.107, 6, '6'], [0.3, 20, 'K']]

Очень хочу сделать в процентах. Потому что у каждой буквы есть число которое можно было бы сделать процентным соотношением но я не знаю какой метод использовать, и стараюсь делать простые понятные петли, алгоритмы. Заранее спасибо!



Последнее исправление: katemisik (всего исправлений: 2)

Вы шутите? Или, может, издеваетесь? Код оформите нормально.

fernandos ★★★
()
Ответ на: комментарий от slovazap

Ошибка в 8 строчке и в данных там где 0.005

Блин, точно! А в начале в конце нашел баг, а потом твой пост увидел, перепроверил - и точно, 8ая строчка. Красава!

anonymous
()

Потому что у каждой буквы есть число которое можно было бы сделать процентным соотношением

соотношением чего с чем?

но я не знаю какой метод использовать, и стараюсь делать простые понятные петли, алгоритмы.

WTF простая понятная петля? Что то с узлом Линча связано?

Такое ощущение что этот текст сгенерирован гугл транслейтом… Или это нейросеть учится кодить на питоне?

AntonI ★★★★★
()
Ответ на: комментарий от AntonI

она полячка

WTF простая понятная петля?

имеется в виду цикл

макском (или модеры), исправьте пост, пожалуйста. по ссылке — отформатированный код всего сообщения, просто замените оригинальное полностью: https://pastebin.com/raw/wfZnjcAP

anonymous
()
def checklen(seq):
    l1 = len(seq[0])
    return all(l1 == len(lst) for lst in seq)

def makelist(lst):
    lista = []
    for i in lst:
        index = np.argmax(i)
        lista.append(CATEGORIES[index])
    lista.reverse()
    return lista

def probabilities(seq):
    lists = [makelist(lst) for lst in seq]
    u, c = np.unique(lists, return_counts=True, axis=0)
    precents = c / sum(c) * 100
    return u.tolist(), precents.tolist()

if __name__ == '__main__':
    seq = (KR8877J, KR8877J_1, KR8877J_2, KR8877J_3, KR8877J_4, KR8877J_5, KR8877J_6)
    seq2 = (KR8R544_1, KR8R544_2, KR8R544_3, KR8R544_4, KR8R544_5)

    for s, s_name in [(seq,'seq'), (seq2,'seq2')]:
        if checklen(s):
            print(f"Len of lists in '{s_name}' are equal")
        else:
            lengths = [len(lst) for lst in s]
            err = f"Len of lists in '{s_name}' are not equal: {lengths}"
            raise Exception(err)
        
        print(s_name, 'probabilities:')
        w, p = probabilities(s)
        print("  Words:", w)
        print("  Probabilities, %:", p)

вывод:

Len of lists in 'seq' are equal
seq probabilities:
  Words: [['K', 'R', '8', '8', '7', 'J', 'J'], ['K', 'R', '8', '8', 'J', '7', 'J']]
  Probabilities, %: [85.71428571428571, 14.285714285714285]
Traceback (most recent call last):
  File "/tmp/temp/script.py", line 155, in <module>
    raise Exception(err)
Exception: Len of lists in 'seq2' are not equal: [6, 7, 7, 7, 7]
anonymous
()
Ответ на: комментарий от anonymous

она полячка

Понятно. Тогда ей наверное надо указать это в профиле. И задача все равно непонятна. Перевести в проценты это умножить на 100? И все?

AntonI ★★★★★
()
Ответ на: комментарий от AntonI

ну если я правильно понял, то нужно вероятности выразить в процентах, а не в «событиях». да, просто разделить на сумму всех событий и умножить на 100.

anonymous
()
Ответ на: комментарий от AntonI

литературное тестирование (по следам Дональда нашего Кнута)

посмотри презентацию Rigidus про Literate DevOps, и исходники его сайта на Emacs org-mode M-x org-babel-tangle

также посмотри на funnelweb (на гитхабе форк с поддержкой utf8: fw-utf8 ) – почитай мануал и примеры.

примеры применения funnelWeb есть например в парсере Eli : посмотри examples – пример сгенерированной FunnelWeb документации.

в целом, форк fw-utf8 можно допилить до нормальной поддержки русскоязычной документации на utf-8: там преамбула исходная на plain tex и шрифты cmr а например можно допилить до xelatex + TTF фонтов типа Times New Roman, Arial, Courier «из коробки» (см. примеры на overleaf про xelatex), также внедрение фонтов в xelatex делается просто.

в общем, можно юзать utf8+tex либо какой-нибудь SILE: + «дистрибутив» CaSILE

вместо TeX.

в целом: SILE это на Lua альтернативный typesetter типа Tex. из коробки utf8 и вёрстка фреймами, см. примеры, стили.

CaSILE: сборка SILE+pandoc+… чтобы можно было писать не в tex-подобной разметке (которая в SILE по дефолту) или в XML (которую SILE тоже поддерживает), а в Markdown.

люди книги в Markdown пишут через CaSILE+SILE+pandoc+…

также см. по ссылке отсюда вот этот пуллреквест там ссылка на нужный форк pandoc-а.

в целом, по твоему топику:

  1. хочешь нормальных ответов по теме – не забывай разрешать анонимусов. я например, на лоре регестрироваться не собираюсь. но иногда мне есть что сказать по теме.

  2. то что ты хочешь – вполне себе возможно готовыми инструментами с некоторыми настройками, насчёт которых придётся немного позаморачиваться, и мануалы почитать.

позаморачиваться придётся меньше если инструменты продуманные – например, есть проверка на ошибки, поддержка многоязычности (кода на нескольких языках программирования), как в funnelWeb, например.

  1. может быть, даже fw-utf8 нужно немного допилить и расширить. но в целом, там достаточно полный контроль над генерируемыми файлами. см. применение в Eli parser например, и мануалы.
anonymous
()
Ответ на: комментарий от anonymous

A tar file containing the specification and a small test suite is available, as is a PDF version of the document.

литературно-грамотное на funnelWeb, разумеется.

хотя тесты там, например не совсем литературные – запускаются шеллскриптом примеры из папки

– ничего в принципе не мешает в таком духе как ALGOL60.fw либо как в Makefile Odinfile – переписать и тесты в литературно-грамотное.

чтобы каждый отдельный пример из tests/* был не просто файл, а product file сгенерированный funnelWeb-ом из литературного исходника с тестами.

вот тебе и будет литературное тестирование.

вообще кратко идею про Literate DevOps можно подытожить как LitProg make-файлов или прочих docker для литературно-грамотного управления конфигурацией.

а тестирования соответственно – примеры наглядные с тестами.

помимо основного литературного исходника на саму программу.

anonymous
()
Ответ на: комментарий от anonymous

Спасибо за ответ.

  1. Не все анонимусы на ЛОРе одинаково полезны, у некоторых от меня баттхерт. Я не хочу срача в своих темах.

  2. Альтернативу ТеХ-у я в принципе не рассматриваю, по целому ряду причин.

AntonI ★★★★★
()
Ответ на: комментарий от anonymous

Спасибо за ваш ответ, но я имела ввиду что то вроде Words: [[‘K’, ‘R’, ‘8’, ‘8’, ‘7’, ‘J’, ‘J’], [‘K’, ‘R’, ‘8’, ‘8’, ‘J’, ‘7’, ‘J’]]

Probabilities in 1 word [[‘K’, ‘R’, ‘8’, ‘8’, ‘7’, ‘J’, ‘J’], for [K] %: K - 90% , R 88%, etc Probabilities in 1 word [[‘K’, ‘R’, ‘8’, ‘8’, ‘7’, ‘J’, ‘J’], for [R] %: r - 90% , K 88%, etc Probabilities in 1 word [[‘K’, ‘R’, ‘8’, ‘8’, ‘7’, ‘J’, ‘J’], for [8] %: 8 - 99% , K 6%, etc

katemisik
() автор топика
Ответ на: комментарий от anonymous

или что то вроде Спасибо за ваш ответ, но я имела ввиду что то вроде Words: [[‘K’, ‘R’, ‘8’, ‘8’, ‘7’, ‘J’, ‘J’], [‘K’, ‘R’, ‘8’, ‘8’, ‘J’, ‘7’, ‘J’]]

Probabilities in 1 word [[‘K’, ‘R’, ‘8’, ‘8’, ‘7’, ‘J’, ‘J’]: ‘K’, ‘R’, ‘8’, ‘8’, ‘7’, ‘J’, ‘J’ - 99 % ‘R’, ‘R’, ‘8’, ‘8’, ‘7’, ‘J’, ‘J’ - 1% опять таки исходи из рассчетов каждой буквы: for [K] %: - 99% , R - 1%, etc

то есть иметь хотя бы первые три вероятности с каждой таблицы

katemisik
() автор топика

Я уже не первый раз правлю за тобой оформление постов.

Запомни, пожалуйста, код надо оформлять тройными апострофами:

```
<код>
```

или, для подстветки синтаксиса,

```python
<код>
```

Новые треды с некорректным оформлением кода будут расцениваться как троллинг.

alpha ★★★★★
()
Ответ на: комментарий от katemisik

извини, я не понимаю вероятности чего тебе нужны.

допустим, есть у нас итоговый список слов:

KR887JJ
KR887JJ
KR887JJ
KR887JJ
KR88J7J
KR887JJ
KR887JJ

в нём:

1. вероятность появления 'KR887JJ' равна 6/7
2. вероятность появления любой одинарной буквы в слове — 1/7
3. вероятность появления двойной буквы в слове — 2/7
4. вероятность появления буквы 'K' во всём списке слов равна 7/(7*7) = 1/7
5. вероятность появления буквы 'K' в первой колонке — 7/7 = 100%
6. вероятность появления буквы 'J' в пятой колонке — 1/7
anonymous
()
Ответ на: комментарий от AntonI

Альтернативу ТеХ-у я в принципе не рассматриваю, по целому ряду причин.

SILE это забавная альтернатива. поглядев на LuaTex, XeLaTeX и прочие «TeX на Lua» кажется, вполне себе здоровая идея: переписать сам TeX на Lua с плюшками и батарейками.

в SILE примерно это и реализовали: взяли проверенный алгоритм вёрстки из TeX (на основе боксов и клея подбираются «красивые» типографически переносы строк, чтобы пустого пространства было минимально), и допилили в новой среде:

  1. реализована вёрстка фреймами (типа как в DTP вроде InDesign, ну или «в ворде текстовые блоки») – на которой реализованы стили например параллельных текстов для переводов, подстрочников и т.п. – см. в примере стили про библию с цитатами, переводы.

  2. умеет без всяких настроек и заморочек «из коробки» создавать PDF с внедрёнными шрифтами.

в общем, Дональд Кнут конечно крут – создал свои собственные инструменты, которые позволили ему разработать свой типографически красивый typesetter, в дисциплине ограничений «грамотное программирование» + метод stepwise refinement Дейкстры. и поскольку с алгоритмами у него всё было хорошо, программирование как алгоритмизация = подстройка последовательности изложения программы не в логике, навязываемой структурой языка программирования (паскаль оригинальный как язык реализации tex изначального через метаинструменты web.pas/tangle.pas / поддерживающую дисциплину обеспечивающую метасистему / метасистемный переход (с) «Феномен науки», В. Ф. Турчин) – а в логике, навязываемой логикой книги – ему этого было достаточно, чтобы оживить и запустить прототип, и далее его поддерживать.

однако. почти все проектные решения были не совсем правильны. в том смысле, что собственные шрифты на языке metafont, собственный page description language – DVI, собственное всё остальное – не совсем правильное изобретение велосипедов и NIH синдром.

а с другой стороны, ну что же делать, если существующие на тот момент альтернативы – были не то. ну разве что troff выделяется программируемостью, но там как раз алгоритм вёрстки не такой красивый типографически. например, тот же уникод появился через лет 10 после самого теха.

в итоге, вполне себе здравая идея возникает переодически: переосмыслить реализацию tex-а в новой среде. в которой сразу PDF вместо DVI/PS/…, 8-bit-free и прочая уникодопрозрачность, ну и стили и конфиги выглядят вроде как попроще в этой среде, да и с расширяемостью несколько получше.

например, в том же SILE: можно считать что это такой минималистичный LuaTeX + вёрстка фреймами + свои стили + поддержка XML формата.

например, как они делают вёрстку из XML: пишем свои «команды» которые соответствуют тегам. и встроенный парсер запускает обработку этими командами. а само SILE может на входе понимать как TeX-подобную разметку, так и XML.

далее берём например документ из ворда, и через LibreOffice сохраняем в DocBook XML (ну или тот же ODT достаём XML из ODT=.XML.ZIP)

и дописываем обработку DocBook тегов, «командами». в итоге получаем вёрстку из ворда в PDF через типа LaTeX, упрощённо.

через pandoc можно и по нормальному конвертировать, не только из, но и в ворд в такое вот XML. или опять же, DITA та же, которая вся на XML по идее легко интегрируется.

в итоге: литературно-грамотным способом можно разрабатывать и ворд документы (если это кому-то важно).

в CaSILE есть пример настройки pandoc таким способом, в своём особом форке pandoc-а. вроде они собираются в mainline pandoc-а патчи назад интегрировать.

ну то есть, CaSILE для SILE примерно соответствует LaTeX или ConTeX для TeX-а : дистрибутив с конфигами и набором макросов.

anonymous
()
Ответ на: комментарий от anonymous

Все это так, но тех я знаю и он меня устраивает. А учить доп средства верстки и пр… зачем? Я даже математические выкладки в техе а не на бумаги делаю

AntonI ★★★★★
()
Ответ на: комментарий от anonymous

не совсем, вот к примеру к первому знаку есть такие вероятности:

[[0.077, 7, ‘7’], [0.058, 18, ‘I’],[0.352, 19, ‘J’], [0.089, 30, ‘V’], [0.053, 32, ‘X’]] 0.352 - масимум

второму знаку: [[0.075, 3, ‘3’], [0.36, 19, ‘J’], [0.092, 30, ‘V’], [0.058, 32, ‘X’]]

мы видим максимум: 0.352 dla J, 0.36, dla следующего символп что эквивалент для ячейки 19 в категориях тобиш снова ‘J’.

если взять первые максимумы то будет как бы самая вероятная комбинация -> KR8877J но как же мне вычислить вторую такую комбинацию правильно и быстро! без дополнительных инстументов что неоднократно предлагали ниже.

katemisik
() автор топика
Ответ на: комментарий от katemisik

как же мне вычислить вторую такую комбинацию

что значит «такую»?

если я правильно понимаю, то, например, для массива с именем KR8877J самая вероятная комбинация будет

['K'   'R'   '8'   '8'   '7'   'J'   'J']
значения комбинации:
[0.383 0.317 0.258 0.412 0.627 0.36  0.352]

следующая по убыванию суммы вероятностей комбинация будет

['K'   'R'   'S'   '8'   '7'   'J'   'J']
значения комбинации:
[0.383 0.317 0.106 0.412 0.627 0.36  0.352]

то есть меняется всего одно значение и, соответственно, только одна буква.

но может быть тебе не так надо? может тебе надо просто из каждой последовательности вероятностей выбрать вторую самую большую вероятность, чтобы получилось

['4'   'F'   'S'   'S'   'Z'   'V'   'V']
[0.164 0.1   0.106 0.074 0.053 0.092 0.089]

давай посмотрим на более простой пример. допустим, у нас есть такой массив вероятностей:

[[2, 1],
 [6, 3]]

выберем самые большие числа из каждой строки: [2, 6]. следующие какие надо брать? [1, 6] или [1, 3]?

если [1, 6] то, я так понимаю, надо считать все суммы различных комбинаций вероятностей, сортировать эти суммы и брать вероятности, которые входят в самые большие суммы.

а если [1, 3], тот тут всё просто: бери вторую самую большую вероятность из каждой строки — и готово.

как будем делать? и сколько тебе самых самых комбинаций надо?

anonymous
()
Ответ на: комментарий от anonymous

[‘4’ ‘F’ ‘S’ ‘S’ ‘Z’ ‘V’ ‘V’] [0.164 0.1 0.106 0.074 0.053 0.092 0.089] Спасибо за ответ, думаю что, предложенный Вами варинт самый подходящий. Просто я не знаю как его реализовать. На данный моментя пытаюсь все сделать максимально просто, используя фор == < > len range и тд, чтобы каждая из строк проходила через решето калькуляций чтобы в итоге получить самые вероятные значения, и стараюсь не использовать Сорт и другие готовые решения, быстрее в моей ситуации подходить итерация b += b чтобы делать все динамически. Буду благодарна любым предпологающим решение варинтам.

katemisik
() автор топика
Ответ на: комментарий от katemisik
NP_CATEGORIES = np.array(CATEGORIES)

def numpy_get_nth_most_probable(arr, n):
    arr = np.array(arr)
    sorted_i = np.flip(np.argsort(arr))
    return NP_CATEGORIES[sorted_i.T[n]]

print(numpy_get_nth_most_probable(KR8877J, 0))
print(numpy_get_nth_most_probable(KR8877J, 1))
['K' 'R' '8' '8' '7' 'J' 'J']
['4' 'F' 'S' 'S' 'Z' 'V' 'V']
def pure_python_get_nth_most_probable(arr, n):
    indexed_lists = [[(i,v) for i,v in enumerate(lst)] for lst in arr]
    srtd = [sorted(lst, key=lambda iv:-iv[1]) for lst in indexed_lists]
    return [CATEGORIES[i] for lst in srtd for i,v in [lst[n]]][::-1]

print(pure_python_get_nth_most_probable(KR8877J, 0))
print(pure_python_get_nth_most_probable(KR8877J, 1))
['K', 'R', '8', '8', '7', 'J', 'J']
['4', 'F', 'S', 'S', 'Z', 'V', 'V']

без «сорт» можно, конечно, но это ты уже сама давай подумай.

anonymous
()
Ответ на: комментарий от anonymous

К сожалению такой вероятности даже и близко нет в реальности. [‘4’, ‘F’, ‘S’, ‘S’, ‘Z’, ‘V’, ‘V’]. Подобные решения уже были но это не вариант, мне нужна скорость и точность. Но спасибо большое, что Вы ответили, если был бы вопрос попроще то этот форум очень выручает точшее програмисты с форума

katemisik
() автор топика
Ответ на: комментарий от katemisik

ну а так?

NP_CATEGORIES = np.array(CATEGORIES)

def numpy_get_nth_most_probable_combination(arr, n):
    '''`n` must not exceed 2**len(arr)-1'''
    arr = np.array(arr)
    
    sorted_i = np.argsort(arr)
    sorted_v = np.take_along_axis(arr, sorted_i, axis=1)

    best2_i = sorted_i.T[-1:-3:-1]
    best2_v = sorted_v.T[-1:-3:-1]
    
    indices = np.arange(2**len(arr)).reshape((2**len(arr), 1))
    swap_indices = (indices & (1 << np.arange(len(arr))) > 0).astype(int)
    swapped = np.take_along_axis(best2_v, swap_indices, axis=0)
    
    sums = np.sum(swapped, axis=1)
    sorted_sums_i = np.argsort(sums)[::-1]
    i = sorted_sums_i[n]
    sum_n = sums[i]
    
    swap_n = swap_indices[i].reshape((1, len(arr)))
    swapped_i = np.take_along_axis(best2_i, swap_n, axis=0)[0][::-1]
    
    return NP_CATEGORIES[swapped_i], sum_n

for i in [*range(0, 3), *range(125, 128)]:
    word, p_sum = numpy_get_nth_most_probable_combination(KR8877J, i)
    print(f'{i:>3}: [{"".join(word)}] Σp={p_sum:.3f}')

правда я пока писал, сам запутался xD

смысл в чём: мы сортируем каждый список вероятностей (каждую строку) по убыванию; потом берём два первых столбца с самыми максимальными значениями (в столбце получается по 7 элементов, для твоих массивов); считаем суммы вероятностей всех возможных вариантов попарных перестановок вероятностей между двумя этими столбцами; сортируем суммы по убыванию; берём индекс той, которая идёт под номером n; от него высчитываем вариант перестановки для этой суммы и далее индексы из оригинального массива для вычисления самих букв.

андерстенд? или опять не то?

anonymous
()
Ответ на: комментарий от anonymous

вывод:

  0: [KR887JJ] Σp=2.709
  1: [KRS87JJ] Σp=2.557
  2: [KF887JJ] Σp=2.492
125: [4RSSZVV] Σp=0.895
126: [4F8SZVV] Σp=0.830
127: [4FSSZVV] Σp=0.678
anonymous
()
Ответ на: комментарий от anonymous
< 
извините, вот значения максимумов:

['K', 'R', '8', '8', '7', 'J', 'J']
['K', 'R', '8', '8', '7', 'J', 'J']
['K', 'R', '8', '8', '7', 'J', 'J']
['K', 'R', '8', '8', '7', 'J', 'J']
['K', 'R', '8', '8', 'J', '7', 'J']
['K', 'R', '8', '8', '7', 'J', 'J']
['K', 'R', '8', '8', '7', 'J', 'J']


исходя из старого варинта кода:



def makelist(lst):
    
        lista = []
        for i in lst:
            index = np.argmax(i)
            lista.append(CATEGORIES[index])
        lista.reverse()
        return lista

>
katemisik
() автор топика
Ответ на: комментарий от katemisik

как же мне вычислить вторую такую комбинацию правильно и быстро

вторую такую

какую «такую»-то? я не понимайт.

anonymous
()
Ответ на: комментарий от anonymous

логика которую вы описываете совпадает с тем к чему я стремлюсь. попробую понять/разобрать Ваш код сначала, совсем недавно занимаюсь пайтон обраткой данных. Спасибо за Вашу помощь!

katemisik
() автор топика
Ответ на: комментарий от anonymous

можно у вас попросить прокоментировать линии?? много нового тяжело разобраться

katemisik
() автор топика
Ответ на: комментарий от anonymous
    indices = np.arange(2**len(arr)).reshape((2**len(arr), 1))
    swap_indices = (indices & (1 << np.arange(len(arr))) > 0).astype(int)
    swapped = np.take_along_axis(best2_v, swap_indices, axis=0)


```тут какая то черная магия 
katemisik
() автор топика
Ответ на: комментарий от katemisik

тут конструируется массив, содержащий все возможные комбинации перемешивания двух столбцов. например, пускай у нас будут такие два столбца:

1 a
2 b
3 c

тогда, если заменять значения первого столбца на значения второго, но из тех же строк, то получатся такие комбинации первого столбца:

1 a 1 a 1 a 1 a
2 2 b b 2 2 b b
3 3 3 3 c c c c

паттерн замены похож на комбинацию битов обычного числа. пускай 0 будет обозначать, что мы берём содержимое из ячейки первого столбца, а 1 — из второго, тогда получится:

0 1 0 1 0 1 0 1
0 0 1 1 0 0 1 1
0 0 0 0 1 1 1 1

что соответствует битовым комбинациям чисел от 0 до 7 или от 0 до 2**(количество строк) - 1. этот массив нулей и единиц похож на swap_indices.

indices = np.arange(2**len(arr)).reshape((2**len(arr), 1))

здесь мы выстраиваем столбец со всеми числами от 0 до 2**len(arr) подряд.

swap_indices = (indices & (1 << np.arange(len(arr))) > 0).astype(int)

а тут генерируем из этих числел их битовые маски, в виде отдельного массива нулей и единиц для каждого из чисел:

1 << np.arange(len(arr))

даст нам массив степеней двойки, так как, например, если единицу сдвинуть на 0 бит влево, то получим 1 — это 2**0, а если единицу сдвинуть на 3 бита влево, то получим 8 = 2**3, то есть, в результате такой массив будет выглядеть как [1, 2, 4, 8, 16 ...]; до 2**(len(arr)-1), всего len(arr) чисел (столько же, сколько и строк).

indices & (1 << np.arange(len(arr)))

теперь если логически умножить (&, логическое и) массив степеней двойки на каждое число из нашего списка indices, то мы получим массив размерностью (2**len(arr), len(arr)), который и будет списком всех возможных комбинаций перестановок значений в двух столбцах. такой список будет содержать только 0 и 1, которые как раз годятся в качестве индекса при выборе одного из двух столбцов при помощи np.take_along_axis().

anonymous
()
Ответ на: комментарий от anonymous

теперь если логически умножить (&, логическое и) массив степеней двойки на каждое число из нашего списка indices, то мы получим массив, который и будет списком всех возможных комбинаций перестановок значений в двух столбцах. такой список будет содержать только 0 и 1

нули и единицы там образуются после сравнения с нулём: indices & (...) > 0.

если, например, число 5 разложить на биты и каждому биту указать его значение, то получится такой список: [4, 0, 1], сумма этих числел которого и даст 5. а чтобы перевести каждое число в 1 или 0, надо просто привести число к типу bool или сравнить его с нулём: [4>0, 0>0, 1>0] = [1, 0, 1].

anonymous
()
Ответ на: комментарий от anonymous

Ваше решение просто супер, но я постараюсь с вашего кода забрать только логику решения, очень трудной способ для моего понимания. пока что мой код такой:

if __name__ == "__main__":

    max_index = 0
    max_list_from_all_plates = []

    threshold = 0.05
    

    for single_lp in seq:
        maximum_plate_prob = []
        possible_plate_prob = []
        max_list = []
        for sign in single_lp:
            high_indexes = []
            for prob_id in range(0,len(sign)):
                if threshold<sign[prob_id]:
                    high_indexes.append([sign[prob_id], prob_id, CATEGORIES[prob_id]])
            max_list.append(high_indexes)
        max_list_from_all_plates.append(max_list)
        print(max_list)
        print(max_list_from_all_plates)

        for single_lp in max_list_from_all_plates: 
            suma = 0#bylo ok tylko dla maximum

            for sign in single_lp:
                #suma = 0#wtedy suma jest rowna sumie testu co nie jest prawda


                #print(sign)
                Highest_score=0

                for b in range(0,len(sign)):

                    n = sign[b]
                    b = 0
                    b += b

                    if n[0]>Highest_score:
                        Highest_score=n[0]

                        sum = 0
                        for i in n[2]:

                            if i == (len(n)-1):
                                sum = 0

                                for i in n:

                                    sum += float(Highest_score)
                        #print("SUM", sum)


                print("test", Highest_score, i)
suma += Highest_score
                print("SUMA", suma)


вывод правильный только для первого максимума пока что. Спасибо Вам за помощь! Output:


[[[0.077, 7, '7'], [0.058, 18, 'I'], [0.352, 19, 'J'], [0.089, 30, 'V'], [0.053, 32, 'X']], [[0.075, 3, '3'], [0.36, 19, 'J'], [0.092, 30, 'V'], [0.058, 32, 'X']], [[0.627, 7, '7'], [0.053, 34, 'Z']], [[0.056, 0, '0'], [0.412, 8, '8'], [0.073, 16, 'G'], [0.074, 27, 'S']], [[0.09, 6, 
'6'], [0.258, 8, '8'], [0.079, 16, 'G'], [0.106, 27, 'S']], [[0.1, 15, 'F'], [0.317, 26, 'R']], [[0.164, 4, '4'], [0.06, 6, '6'], [0.383, 20, 'K'], [0.063, 22, 'M']]]
[[[[0.077, 7, '7'], [0.058, 18, 'I'], [0.352, 19, 'J'], [0.089, 30, 'V'], [0.053, 32, 'X']], [[0.075, 3, '3'], [0.36, 19, 'J'], [0.092, 30, 'V'], [0.058, 32, 'X']], [[0.627, 7, '7'], [0.053, 34, 'Z']], [[0.056, 0, '0'], [0.412, 8, '8'], [0.073, 16, 'G'], [0.074, 27, 'S']], [[0.09, 6, '6'], [0.258, 8, '8'], [0.079, 16, 'G'], [0.106, 27, 'S']], [[0.1, 15, 'F'], [0.317, 26, 'R']], [[0.164, 4, '4'], [0.06, 6, '6'], [0.383, 20, 'K'], [0.063, 22, 'M']]]]
test 0.352 J
SUMA 0.352
test 0.36 J
SUMA 0.712
test 0.627 7
SUMA 1.339
test 0.412 8
SUMA 1.751
test 0.258 8
SUMA 2.009
test 0.317 R
SUMA 2.326
test 0.383 K
SUMA 2.709
[[[0.054, 7, '7'], [0.051, 10, 'A'], [0.056, 18, 'I'], [0.389, 19, 'J'], [0.07, 30, 'V']], [[0.083, 7, '7'], [0.062, 9, '9'], [0.053, 10, 'A'], [0.055, 18, 'I'], [0.348, 19, 'J'], [0.086, 30, 'V'], [0.055, 32, 'X']], [[0.499, 7, '7'], [0.053, 25, 'P'], [0.123, 34, 'Z']], [[0.054, 6, 
'6'], [0.369, 8, '8'], [0.1, 16, 'G'], [0.102, 27, 'S']], [[0.075, 6, '6'], [0.365, 8, '8'], [0.075, 16, 'G'], [0.099, 27, 'S']], [[0.11, 15, 'F'], [0.059, 25, 'P'], [0.289, 26, 'R']], [[0.134, 4, '4'], [0.088, 6, '6'], [0.342, 20, 'K']]]
[[[[0.077, 7, '7'], [0.058, 18, 'I'], [0.352, 19, 'J'], [0.089, 30, 'V'], [0.053, 32, 'X']], [[0.075, 3, '3'], [0.36, 19, 'J'], [0.092, 30, 'V'], [0.058, 32, 'X']], [[0.627, 7, '7'], [0.053, 34, 'Z']], [[0.056, 0, '0'], [0.412, 8, '8'], [0.073, 16, 'G'], [0.074, 27, 'S']], [[0.09, 6, '6'], [0.258, 8, '8'], [0.079, 16, 'G'], [0.106, 27, 'S']], [[0.1, 15, 'F'], [0.317, 26, 'R']], [[0.164, 4, '4'], [0.06, 6, '6'], [0.383, 20, 'K'], [0.063, 22, 'M']]], [[[0.054, 7, '7'], [0.051, 10, 'A'], [0.056, 18, 'I'], [0.389, 19, 'J'], [0.07, 30, 'V']], [[0.083, 7, '7'], [0.062, 9, '9'], [0.053, 10, 'A'], [0.055, 18, 'I'], [0.348, 19, 'J'], [0.086, 30, 'V'], [0.055, 32, 'X']], [[0.499, 7, '7'], [0.053, 25, 'P'], [0.123, 34, 'Z']], [[0.054, 6, '6'], [0.369, 8, '8'], [0.1, 16, 'G'], [0.102, 27, 'S']], [[0.075, 6, '6'], [0.365, 8, '8'], [0.075, 16, 'G'], [0.099, 27, 'S']], [[0.11, 15, 'F'], [0.059, 25, 'P'], [0.289, 26, 'R']], [[0.134, 4, '4'], [0.088, 6, '6'], [0.342, 20, 'K']]]]
test 0.352 J
SUMA 0.352
test 0.36 J
SUMA 0.712
test 0.627 7
SUMA 1.339
test 0.412 8
SUMA 1.751
test 0.258 8
SUMA 2.009
test 0.317 R
SUMA 2.326
test 0.383 K
SUMA 2.709
test 0.389 J
SUMA 0.389
test 0.348 J
SUMA 0.737
test 0.499 7
SUMA 1.236
test 0.369 8
SUMA 1.605
test 0.365 8
SUMA 1.97
test 0.289 R
SUMA 2.259
test 0.342 K
SUMA 2.601
[[[0.073, 7, '7'], [0.384, 19, 'J'], [0.088, 30, 'V'], [0.066, 32, 'X']], [[0.089, 7, '7'], [0.051, 18, 'I'], [0.387, 19, 'J'], [0.09, 30, 'V'], [0.064, 32, 'X']], [[0.282, 7, '7'], [0.053, 25, 'P'], [0.224, 34, 'Z']], [[0.097, 6, '6'], [0.239, 8, '8'], [0.082, 16, 'G'], [0.11, 27, 'S']], [[0.053, 3, '3'], [0.057, 6, '6'], [0.25, 8, '8'], [0.057, 16, 'G'], [0.092, 27, 'S']], [[0.069, 8, '8'], [0.057, 14, 'E'], [0.096, 15, 'F'], [0.256, 26, 'R']], [[0.174, 4, '4'], [0.085, 6, '6'], [0.357, 20, 'K']]]
[[[[0.077, 7, '7'], [0.058, 18, 'I'], [0.352, 19, 'J'], [0.089, 30, 'V'], [0.053, 32, 'X']], [[0.075, 3, '3'], [0.36, 19, 'J'], [0.092, 30, 'V'], [0.058, 32, 'X']], [[0.627, 7, '7'], [0.053, 34, 'Z']], [[0.056, 0, '0'], [0.412, 8, '8'], [0.073, 16, 'G'], [0.074, 27, 'S']], [[0.09, 6, '6'], [0.258, 8, '8'], [0.079, 16, 'G'], [0.106, 27, 'S']], [[0.1, 15, 'F'], [0.317, 26, 'R']], [[0.164, 4, '4'], [0.06, 6, '6'], [0.383, 20, 'K'], [0.063, 22, 'M']]], [[[0.054, 7, '7'], [0.051, 10, 'A'], [0.056, 18, 'I'], [0.389, 19, 'J'], [0.07, 30, 'V']], [[0.083, 7, '7'], [0.062, 9, '9'], [0.053, 10, 'A'], [0.055, 18, 'I'], [0.348, 19, 'J'], [0.086, 30, 'V'], [0.055, 32, 'X']], [[0.499, 7, '7'], [0.053, 25, 'P'], [0.123, 34, 'Z']], [[0.054, 6, '6'], [0.369, 8, '8'], [0.1, 16, 'G'], [0.102, 27, 'S']], [[0.075, 6, '6'], [0.365, 8, '8'], [0.075, 16, 'G'], [0.099, 27, 'S']], [[0.11, 15, 'F'], [0.059, 25, 'P'], [0.289, 26, 'R']], [[0.134, 4, '4'], [0.088, 6, '6'], [0.342, 20, 'K']]], [[[0.073, 7, '7'], [0.384, 19, 'J'], [0.088, 30, 'V'], [0.066, 32, 'X']], [[0.089, 7, '7'], [0.051, 18, 'I'], [0.387, 19, 'J'], [0.09, 30, 'V'], [0.064, 32, 'X']], [[0.282, 7, '7'], [0.053, 25, 'P'], [0.224, 34, 'Z']], [[0.097, 6, '6'], [0.239, 8, '8'], [0.082, 16, 'G'], [0.11, 27, 'S']], [[0.053, 3, '3'], [0.057, 6, '6'], [0.25, 8, '8'], [0.057, 16, 'G'], [0.092, 27, 'S']], [[0.069, 8, '8'], [0.057, 14, 'E'], [0.096, 15, 'F'], [0.256, 26, 'R']], [[0.174, 4, '4'], [0.085, 6, '6'], [0.357, 20, 'K']]]]


 etc

Логика алгоритма step one: create lists+(done)

step two count maximums signs+(done)

step tree count sum of maximums for ech signle plate list for step 3 i could use (чтобы не потеярть XD) squares = [1, 4, 9, 16] sum = 0 for num in squares: sum += num print sum ## 30

step four sort the most probable from max to min use qiuck sort(?)

'''

katemisik
() автор топика
Ответ на: комментарий от evgeny_aa

Ну и зачем ты тут сидишь? не помогаешь и еще чета ноешь… Форум для обсуждений, а не для твоих личный предпочтений людей на форуме

katemisik
() автор топика
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.