KM
Katerina MisikНаурыз 3, 2021, 7:25 Т.Ж.

не получаеться добавить списки в списокб ошибка в петле

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

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]etc

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)
seq3 = (KR508WW_1, KR508WW_2, KR508WW_3, KR508WW_4, KR508WW_5, KR508WW_6, KR508WW_7, KR508WW_8)

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)

    lista = []



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

        lists = []

        for sign in single_lp:
            #suma = 0


            #print(sign)
            Highest_score=0
            biglist = []

            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)
            listy.extend(lists)

            suma += Highest_score


            lists.append([Highest_score, i])
            listy.append(lists)
        lista.append(suma)

    print("SINGLE LISTS", lists)
    print("SUMA", suma)
    print("Test", lists)


print("Lista sum", lista)
print("Test", listy)

ma = max(lista)
print("mak", ma)
mi = min(lista)

def mergeSort(lista):
if len(lista) > 1:
mid = len(lista) // 2
left = lista[:mid]
right = lista[mid:]

    mergeSort(left)
    mergeSort(right)

    i = 0
    j = 0
    k = 0

    while i < len(left) and j < len(right):
        if left[i] < right[j]:
          lista[k] = left[i]
          i += 1
        else:
            lista[k] = right[j]
            j += 1
        k += 1

    while i < len(left):
        lista[k] = left[i]
        i += 1
        k += 1

    while j < len(right):
        lista[k]=right[j]
        j += 1
        k += 1

mergeSort(lista)
print("list", lista)

вместо вывода [[0.389, ‘J’], [0.348, ‘J’], [0.499, ‘7’], [0.369, ‘8’], [0.365, ‘8’], [0.289, ‘R’], [0.342, ‘K’]] [[0.384, ‘J’], [0.387, ‘J’], [0.282, ‘7’], [0.239, ‘8’], [0.25, ‘8’], [0.256, ‘R’], [0.357, ‘K’]] [[0.391, ‘J’], [0.379, ‘J’], [0.458, ‘7’], [0.235, ‘8’], [0.289, ‘8’], [0.275, ‘R’], [0.378, ‘K’]]

[[0.401, ‘J’], [0.462, ‘7’], [0.422, ‘J’], [0.287, ‘8’], [0.271, ‘8’], [0.286, ‘R’], [0.377, ‘K’]]

[[0.382, ‘J’], [0.35, ‘J’], [0.517, ‘7’], [0.36, ‘8’], [0.259, ‘8’], [0.331, ‘R’], [0.36, ‘K’]]

[[0.391, ‘J’], [0.366, ‘J’], [0.299, ‘7’], [0.234, ‘8’], [0.269, ‘8’], [0.239, ‘R’], [0.3, ‘K’]]

у меня отдельные списки нп: Test [[0.352, ‘J’], [0.36, ‘J’], [0.627, ‘7’], [0.412, ‘8’], [0.258, ‘8’], [0.317, ‘R’], [0.383, ‘K’]] Test [[0.389, ‘J’], [0.348, ‘J’], [0.499, ‘7’], [0.369, ‘8’], [0.365, ‘8’], [0.289, ‘R’], [0.342, ‘K’]]

Test [[0.384, ‘J’], [0.387, ‘J’], [0.282, ‘7’], [0.239, ‘8’], [0.25, ‘8’], [0.256, ‘R’], [0.357, ‘K’]]

Test [[0.391, ‘J’], [0.379, ‘J’], [0.458, ‘7’], [0.235, ‘8’], [0.289, ‘8’], [0.275, ‘R’], [0.378, ‘K’]]

Test [[0.401, ‘J’], [0.462, ‘7’], [0.422, ‘J’], [0.287, ‘8’], [0.271, ‘8’], [0.286, ‘R’], [0.377, ‘K’]]

Test [[0.382, ‘J’], [0.35, ‘J’], [0.517, ‘7’], [0.36, ‘8’], [0.259, ‘8’], [0.331, ‘R’], [0.36, ‘K’]]

Test [[0.391, ‘J’], [0.366, ‘J’], [0.299, ‘7’], [0.234, ‘8’], [0.269, ‘8’], [0.239, ‘R’], [0.3, ‘K’]]

Заранее спасибо!

Рекомендуем хостинг TIMEWEB
Рекомендуем хостинг TIMEWEB
Стабильный хостинг, на котором располагается социальная сеть EVILEG. Для проектов на Django рекомендуем VDS хостинг.

Ол саған ұнайды ма? Әлеуметтік желілерде бөлісіңіз!

1
KM
  • Наурыз 5, 2021, 2:25 Т.Ж.
  • Жауап шешім ретінде белгіленді.

решение:
с line 99:
listy = [] lista = []

for single_lp in max_list_from_all_plates:
    suma = 0
    lists = []


    for sign in single_lp:



        Highest_score=0
        biglist = []

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

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

            if n[0]>Highest_score:#znaleenie maksimum dla kazdego elementu
                Highest_score=n[0]

                sum = 0
                for i in n[2]:

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


                        for i in n:
                            print(i, n)
                            sum += float(Highest_score)


        suma += Highest_score
        lists.append([Highest_score, i])

    lista.append(suma)
    listy.append(lists)
    listy.index()

    Пікірлер

    Тек рұқсаты бар пайдаланушылар ғана пікір қалдыра алады.
    Кіріңіз немесе Тіркеліңіз
    AD

    C++ - Тест 004. Указатели, Массивы и Циклы

    • Нәтиже:50ұпай,
    • Бағалау ұпайлары-4
    m
    • molni99
    • Қаз. 26, 2024, 1:37 Т.Ж.

    C++ - Тест 004. Указатели, Массивы и Циклы

    • Нәтиже:80ұпай,
    • Бағалау ұпайлары4
    m
    • molni99
    • Қаз. 26, 2024, 1:29 Т.Ж.

    C++ - Тест 004. Указатели, Массивы и Циклы

    • Нәтиже:20ұпай,
    • Бағалау ұпайлары-10
    Соңғы пікірлер
    ИМ
    Игорь МаксимовҚар. 22, 2024, 11:51 Т.Ж.
    Django - Оқулық 017. Теңшелген Django кіру беті Добрый вечер Евгений! Я сделал себе авторизацию аналогичную вашей, все работает, кроме возврата к предидущей странице. Редеректит всегда на главную, хотя в логах сервера вижу запросы на правильн…
    Evgenii Legotckoi
    Evgenii LegotckoiҚаз. 31, 2024, 2:37 Т.Қ.
    Django - Сабақ 064. Python Markdown кеңейтімін қалай жазуға болады Добрый день. Да, можно. Либо через такие же плагины, либо с постобработкой через python библиотеку Beautiful Soup
    A
    ALO1ZEҚаз. 19, 2024, 8:19 Т.Ж.
    Qt Creator көмегімен fb3 файл оқу құралы Подскажите как это запустить? Я не шарю в программировании и кодинге. Скачал и установаил Qt, но куча ошибок выдается и не запустить. А очень надо fb3 переконвертировать в html
    ИМ
    Игорь МаксимовҚаз. 5, 2024, 7:51 Т.Ж.
    Django - Сабақ 064. Python Markdown кеңейтімін қалай жазуға болады Приветствую Евгений! У меня вопрос. Можно ли вставлять свои классы в разметку редактора markdown? Допустим имея стандартную разметку: <ul> <li></li> <li></l…
    d
    dblas5Шілде 5, 2024, 11:02 Т.Ж.
    QML - Сабақ 016. SQLite деректер қоры және онымен QML Qt-та жұмыс істеу Здравствуйте, возникает такая проблема (я новичок): ApplicationWindow неизвестный элемент. (М300) для TextField и Button аналогично. Могу предположить, что из-за более новой верси…
    Енді форумда талқылаңыз
    m
    moogoҚар. 22, 2024, 7:17 Т.Ж.
    Mosquito Spray System Effective Mosquito Systems for Backyard | Eco-Friendly Misting Control Device & Repellent Spray - Moogo ; Upgrade your backyard with our mosquito-repellent device! Our misters conce…
    Evgenii Legotckoi
    Evgenii LegotckoiМаусым 24, 2024, 3:11 Т.Қ.
    добавить qlineseries в функции Я тут. Работы оень много. Отправил его в бан.
    t
    tonypeachey1Қар. 15, 2024, 6:04 Т.Ж.
    google domain [url=https://google.com/]domain[/url] domain [http://www.example.com link title]
    NSProject
    NSProjectМаусым 4, 2022, 3:49 Т.Ж.
    Всё ещё разбираюсь с кешем. В следствии прочтения данной статьи. Я принял для себя решение сделать кеширование свойств менеджера модели LikeDislike. И так как установка evileg_core для меня не была возможна, ибо он писался…

    Бізді әлеуметтік желілерде бақылаңыз