LINUX.ORG.RU

Сообщения katemisik

 

Помогите понять почему не работает imshow?

Форум — Development
import cv2
import numpy as np

#cap = cv2.VideoCapture('C:/Users/Kate/PycharmProjects/pythonProject/NVR_ch1_main_20210124075900_20210124080000.asf')
image = cv2.imread("2.jpg")
#image2 = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

low_red = np.array([161, 155, 84])
high_red = np.array([179, 255, 255])

image2 = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)

filtermask = cv2.inRange(image, low_red, high_red)
find_lights = cv2.bitwise_and(image, image, mask=filtermask)

cv2.imshow("Red", find_lights)
cv2.imshow("filters", filtermask)

Перемещено leave из general

 ,

katemisik
()

проблема с Tuple из картинок и break тоже не работает.

Форум — Development

Добрый день пожалуйста помогите исправить tuple. новичок с пайтон, заранее спасибо


import numpy as np


import cv2

image1 = cv2.imread("2.jpg")
image2 = cv2.imread("3.jpg")

font = cv2.FONT_HERSHEY_COMPLEX
while True:
    image = image1, image2

    hav = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)


blue1 = np.array([141,155,84])
blue2 = np.array([179,255,255])

mask = (hav, blue1, blue2)
bluecnts = cv2.findContours(mask.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)[-2]

if len(bluecnts)>0:
    blue_area = max(bluecnts, key=cv2.contourArea)
    (xg,yg,wg,hg)=cv2.boundingRect(blue_area)
    cv2.rectangle(image, (xg,yg), (xg+wg,yg+hg), (0,255,2),2)
    cv2.putText(image, "LIGHTS",(xg,yg-15),font,1, (220,0,0), 2, cv2.LINE_AA)

cv2.imshow('image', image)
cv2.imshow('mask', mask)

#k=cv2.waitKey(5)

#if k == 1:
#    break



Перемещено xaizek из general

 

katemisik
()

Разбираю пример кода, подскажите пожалуйста как поправить чтобы найти только красные(фонарики с фото)

Форум — Development

Разбираю пример кода, хочу его изменить чтобы искать красные источники света, с open cv опыта нет. Помогите пожалуйста куда вписать дополнительный фильтр цвета, если это возможно.

import numpy as np
import argparse
import cv2
import imutils
from imutils import contours
import skimage
from skimage import measure
import argparse

image = cv2.imread("2.jpg")

gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
blurred = cv2.GaussianBlur(gray, (11, 11), 0)
thresh = cv2.threshold(blurred, 200, 255, cv2.THRESH_BINARY)[1]
thresh = cv2.erode(thresh, None, iterations=2)
thresh = cv2.dilate(thresh, None, iterations=4)

labels = measure.label(thresh, connectivity=1, background=0)
mask = np.zeros(thresh.shape, dtype="uint8")

for label in np.unique(labels):

	if label == 0:
		continue

	labelMask = np.zeros(thresh.shape, dtype="uint8")
	labelMask[labels == label] = 255
	numPixels = cv2.countNonZero(labelMask)

	if numPixels > 300:
		mask = cv2.add(mask, labelMask)

cnts = cv2.findContours(mask.copy(), cv2.RETR_EXTERNAL,
	cv2.CHAIN_APPROX_SIMPLE)
cnts = imutils.grab_contours(cnts)
cnts = contours.sort_contours(cnts)[0]

for (i, c) in enumerate(cnts):

	(x, y, w, h) = cv2.boundingRect(c)
	((cX, cY), radius) = cv2.minEnclosingCircle(c)
	cv2.circle(image, (int(cX), int(cY)), int(radius),
		(0, 0, 255), 3)
	cv2.putText(image, "#{}".format(i + 1), (x, y - 15),
		cv2.FONT_HERSHEY_SIMPLEX, 0.45, (0, 0, 255), 2)

cv2.imshow("Image", image)
cv2.waitKey(0)

Огромное спасибо админу и учасникам форума!

Перемещено xaizek из general

 ,

katemisik
()

Ошибка «label() got an unexpected keyword argument 'neighbors'» 'это стандратная строка, библиотека тоже работает почему у меня ошибка?

Форум — Development

Работаю над кодом с использованием Open CV. Не понимаю почему у меян ошибка в стандартной строке(labels = measure.label(thresh, neighbors=8, background=0) а именно «Exception has occurred: TypeError label() got an unexpected keyword argument ‘neighbors’» )

import numpy as np
import argparse
import cv2
import imutils
from imutils import contours
import skimage
from skimage import measure
import argparse

ap = argparse.ArgumentParser()
ap.add_argument("-i", "--image", help = "path to the image file")
ap.add_argument("-r", "--radius", type = int,
	help = "radius of Gaussian blur; must be odd")
args = vars(ap.parse_args())
# load the image and convert it to grayscale
#image = cv2.imread(args["image"])
image = cv2.imread("2.jpg")

#image = cv2.imread(args["image"])
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
blurred = cv2.GaussianBlur(gray, (11, 11), 0)
thresh = cv2.threshold(blurred, 200, 255, cv2.THRESH_BINARY)[1]
thresh = cv2.erode(thresh, None, iterations=2)
thresh = cv2.dilate(thresh, None, iterations=4)
#print(image)

labels = measure.label(thresh, neighbors=8, background=0)
mask = np.zeros(thresh.shape, dtype="uint8")
# loop over the unique components
for label in np.unique(labels):
	#if this is the background label, ignore it
	if label == 0:
		continue
	# otherwise, construct the label mask and count the
	# number of pixels 
	labelMask = np.zeros(thresh.shape, dtype="uint8")
	labelMask[labels == label] = 255
	numPixels = cv2.countNonZero(labelMask)
	# if the number of pixels in the component is sufficiently
	# large, then add it to our mask of "large blobs"
	if numPixels > 300:
		mask = cv2.add(mask, labelMask)
		cv2.imshow("Image", image)
		cv2.waitKey(0)

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

Перемещено xaizek из general

Перемещено leave из linux-install

 ,

katemisik
()

Django как воспользоваться результатом c метода?

Форум — Development


        Priv = 2020
        Now = 2021
        Next = 2022
     
        Rok = (
        (None, "Nie wybran"),
        (Priv, '2020'),
        (Now, '2021'),
        (Next, '2022')
        )
     
        Rok = models.IntegerField(choices=Rok, default=Now)
     
        def checkRok(self):
     
            strrok = str(self.Rok)
     
            return strrok

     
     
     
        Tydzien = models.DateField(datetime.date(year=checkRok, month=11, week=1))

Я хочу в последней строке использовать strrok как значение года. Подскажите пожалуйста как это сделать??
Почти все пока делаю в models и не хочу задействовать киких то вью или форм.. Заранее благодарю!

 ,

katemisik
()

HTML локация пользователя как константа для сдедующих шагов в коде

Форум — Development

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

const storeLocation = [22.568, 51.246];

то что я пытаюсь сделать, но не знаю как…

function getLocation() {
  if (navigator.geolocation) {
    navigator.geolocation.watchPosition(showPosition);
  } else {
    x.innerHTML = "Geolocation is not supported by this browser.";
  }
}
function showPosition(position) {
  const storeLocation = [position.coords.latitude, position.coords.longitude];

}

 

katemisik
()

как передать данные о локации пользователя ? HTML, CSS, JS

Форум — Development

как оно работало:

const storeLocation = [22.568, 51.246];

файл 2: то как я хочу передать местоположение

function getLocation() {
  if (navigator.geolocation) {
    navigator.geolocation.watchPosition(showPosition);
  } else {
    x.innerHTML = "Geolocation is not supported by this browser.";
  }
}
function showPosition(position) {
  const storeLocation = [position.coords.latitude, position.coords.longitude];

}


 

katemisik
()

Как сравнить длину списков по принципу связного списка?

Форум — Development

Список списков = max_list_from_all_plates Как поменять код чтобы сравнить с помощью итерации c условием? то есть:

output

list1 list 2 #(if equal, take the current list to compare with next list ) list2 list 3 #(if not equal, do not take the current/or next list to compare with the next list)



 def makelist(self):
        for n in range(0, len(self.max_list_from_all_plates)-1): 

            self.lenx = len(self.max_list_from_all_plates[n])
            self.leny = len(self.max_list_from_all_plates[n+1])
            
            if self.leny == self.lenx:
                
                print(self.leny, self.lenx)
                print(self.max_list_from_all_plates[n], '         ', self.max_list_from_all_plates[n+1])

else: # (What to do if lists not equal?? do not take the current/or next list to compare with the next  list? I just want to get only equal length lists. But how? 0_o)


output
7 7

7 7

7 7

7 7

7 7

7 7

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

Перемещено leave из desktop

 

katemisik
()

Как найти индекс елемента списка

Форум — Development

есть два списка:

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

и списки textPlate:

                textPlate.append(znakMax)
                sumplate += valMax

                print(textPlate)
output:
['J', 'J'] 
['J', 'J', '7'] 
['J', 'J', '7', '8'] 
['J', 'J', '7', '8', '8'] 
['J', 'J', '7', '8', '8', 'R'] 
['J', 'J', '7', '8', '8', 'R', 'K'] 

как найти индексы с категорий для списков textPlate? Заранее спасибо!

Пока что нашла решение

                print(CATEGORIES)
                for t in CATEGORIES:
                    for s in textPlate:
                        if t == s:
                            print(CATEGORIES.index(t))

но стараюсь понять как упростить чтобы иметь сразу результат без петли… что то вроде стандартного list.index(x, [start [, end]])

 

katemisik
()

хочу добавить функцию чтобы сравнить каждый список и использовать self. __init__

Форум — Development
class PlateString:

    def __init__(self, threshold=0.05):
        self.threshold = threshold
        self.max_list_from_all_plates = []
        for single_lp in seq:
            max_list = []
            plateresults = []
            for sign in single_lp:
                high_indexes = []
                for prob_id in range(0,len(sign)):
                    if self.threshold<sign[prob_id]:
                        high_indexes.append([sign[prob_id], prob_id, CATEGORIES[prob_id]])
                max_list.append(high_indexes)
            self.max_list_from_all_plates.append(max_list)
            self.listaMain = []

    def makelist(self):
        list1 = []
        list2 = []
        for plate in self.max_list_from_all_plates:
            #maxlen = 0
            #if len(plate) > maxlen:
            #    maxlen = len(plate)
            #if len(plate) == maxlen:
            #    pass
            textPlate : str= ""
            sumplate = 0 
            for probabilities in plate:
                znakMax : str = ""
                probabilityMax : float = 0
                for probability in probabilities:
                    if(probabilityMax<probability[0]):
                        probabilityMax = probability[0]
                        znakMax = probability[2]
                        valMax = probability[0]
                textPlate += znakMax
                sumplate += valMax
            list1.append(textPlate)
            list2.append(sumplate)

        for i in range(len(list1)):
            info = [list1[i], list2[i]]
            self.listaMain.append(info)
        print(self.listaMain)
        self.findtotal()


    def findtotal(self):
        for i in self.listaMain:
            print(i)
            itemmax = (max(i[-1] for i in self.listaMain))
            return (itemmax)

    

if __name__ == '__main__':
    PlateString(threshold=0.05).makelist()
    #PlateString(threshold=0.05).findtotal()

output:

[['JJ788RK', 2.709], ['JJ788RK', 2.601], ['JJ788RK', 2.155], ['JJ788RK', 2.4050000000000002], ['J7J88RK', 2.5060000000000002], ['JJ788RK', 2.5589999999999997], ['JJ788RK', 2.098]]
['JJ788RK', 2.709]

 

katemisik
()

как сравнить и обьеденить елементы в списках?

Форум — Development

Данные:

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

seq = (KR8877J, KR8877J_1, KR8877J_2, KR8877J_3, KR8877J_4, KR8877J_5, KR8877J_6)

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

    for m in range(len(max_list_from_all_plates)-1):    #for max_list in max_list_from_all_plates:
        for n in range(min(len(max_list_from_all_plates[m]), len(max_list_from_all_plates[m+1]))): # for high_indexes in max_list:
            #print(high_indexes)
            for j in max_list_from_all_plates[m][n]:
                a = j[-1]
                c = j[0]
            for j in max_list_from_all_plates[m+1][n]:
                b = j[-1]
                d = j[0]
            #print([a[-1] for a in max_list_from_all_plates[m][n]], [b[-1] for b in max_list_from_all_plates[m+1][n]])

            #if [a[-1] for a in max_list_from_all_plates[m][n]] == [b[-1] for b in max_list_from_all_plates[m+1][n]]:
                #suma = [c[0] + d[0] for c, d in zip(max_list_from_all_plates[m][n] , max_list_from_all_plates[m+1][n])]
            for a in max_list_from_all_plates[m][n]:
                #print(a[-1])
                for g in max_list_from_all_plates[m+1][n]:
                    #print(g[-1])
                    if a[-1] == g[-1]:
                        print('test+', a[-1], g[-1], a[0], g[0])
                        t = a[0] 
                        t += g[0]
                    else:
                        print("test-", a[-1], g[-1])


output :


test+ [0.064, 0.052, 0.36, 0.067, 0.121] [0.06, 0.09, 0.234, 0.052, 0.134] ['3', '6', '8', 'G', 'S'] ['3', '6', '8', 'G', 'S']
['6', '8', 'G', 'S'] ['6', '8', 'S']
test ['6', '8', 'G', 'S'] ['6', '8', 'S']
['E', 'F', 'P', 'R'] ['8', 'F', 'P', 'R']
test ['E', 'F', 'P', 'R'] ['8', 'F', 'P', 'R']
['4', '6', 'K'] ['4', '6', 'K']
test+ [0.096, 0.095, 0.36] [0.186, 0.107, 0.3] ['4', '6', 'K'] ['4', '6', 'K']

как Вы видите списки имеют общие элементы test [‘7’, ‘A’, ‘J’, ‘V’, ‘X’] [‘3’, ‘7’, ‘D’, ‘J’, ‘V’] 7 и 7, J и V

хочу иметь возможность обьеденить их.

ну и вывести список в котором будут все варианты вместе как бы смержены (merge)

[‘7’, ‘A’, ‘J’, ‘V’, ‘X’] + [‘3’, ‘7’, ‘D’, ‘J’, ‘V’] = [‘7’, ‘A’, ‘J’, ‘V’, ‘X’, ‘3’, ‘D’]

ну и оставить их значения на пример [[[‘7’], [0.096]], [[‘A’], [0.096]],и т.д.

вроде бы должно работать, но не знаю почему не обновляеться значение: if a[-1] == g[-1]: print(‘test+’, a[-1], g[-1], a[0], g[0]) t = a[0] t += g[0]

test+ K K 0.36 0.3

остаеться таким же, хотя по идее должен возрастать

Перемещено xaizek из general

 

katemisik
()

как обьеденить два списка?

Форум — Development

zip выдает ошибку связаную с неправильной работой памяти.. Да и вообще, если есть возможность обьеденить эти списки без zip будет только лучше print(result) <zip object at 0x0000021482613400>

                    s = [a[0] + b[0] for a, b in zip(max_list_from_all_plates[k][n] , max_list_from_all_plates[k+1][n])]
                    x = [a[-1] for a in max_list_from_all_plates[k][n]]
                    result = zip(s, x)
                    print(s, x)

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

сами списки: [0.14600000000000002, 0.138, 0.773, 0.118] [‘3’, ‘D’, ‘J’, ‘V’] я хочу получить: [[0.14600000000000002],[‘3’]], [[0.138],[‘D’]], и т.д.

Перемещено Shaman007 из general

 

katemisik
()

сравнение, «==»

Форум — Development
        for max_list in max_list_from_all_plates:
            for high_indexes in max_list:
                print([row[2] for row in high_indexes])
   
                i = 0
                i += 1
                for i in range(len(high_indexes)):
                    print("index", i)


                    print("high_indexes", high_indexes[i][2])
                    if high_indexes[i][2] == high_indexes[i+1][2]: # ошибка тут
                        print("equal")
                    else:
                        print("not equal")

output

['8', 'F', 'P', 'R']
index 0
high_indexes 8
index 1
high_indexes F
index 2
high_indexes P
index 3
high_indexes R
['4', '6', 'K']
index 0
high_indexes 4
index 1
high_indexes 6
index 2
high_indexes K

Не могу сравнить символы, думаю что проблема с итерацией символов

Перемещено xaizek из general

 

katemisik
()

итерация

Форум — Development

У меня есть список со списками, который называется - max_list_from_all_plates

и я хочу получить print(high_indexes[r][2]) и high_indexes[r+1][2]) Но у меня где-то есть логическая ошибка:

for max_list_list_from_all_plates:
   
        
        for high_indexes in max_list:
            print("max_list", max_list)
            print("high_indexes", high_indexes)

            r = 0
            r +=r

            print(high_indexes[r][2], high_indexes[r+1][2])

Но я не понимаю, почему итерация не работает.

Output:

max_list [[[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']]]]].
high_indexes [[0.186, 4, '4'], [0.107, 6, '6'], [0.3, 20, 'K']].
4 6 

Я получаю только два из трех элементов…. Спасибо заранее.

Перемещено xaizek из general

 

katemisik
()

Списки, хочу сравнить динамически созданные списки но у них нет индекса, как это сделать не создавая новый список?

Форум — Development

Добрый день У меня есть 2 списка, которые я хочу сравнить, используя последний индекс каждого элемента[2], который представляет собой букву.

списки которые я хочу сравнить это maximum и maximum2

import copy

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

 
seq = (KR8877J, KR8877J_1, KR8877J_2, KR8877J_3, KR8877J_4, KR8877J_5, KR8877J_6)
if __name__ == "__main__":
 
    max_index = 0
    max_list_from_all_plates = []
    Secondplate =None
    threshold = 0.05
    listy  = []

    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)
        h = high_indexes[0]
        newlist = copy.deepcopy(max_list)

        maximum = [max(h) for h in max_list]
        listy.append(maximum)

        m = [max(h) for h in newlist]
            

        n = 0 
        for i in newlist:
            i.remove(m[n])
            n += 1

        maximum2 = [max(h) for h in newlist]
        
        print(maximum, maximum2)
    print(max_list_from_all_plates)

My output: [[0.352, 19, 'J'], [0.36, 19, 'J'], [0.627, 7, '7'], [0.412, 8, '8'], [0.258, 8, '8'], [0.317, 26, 'R'], [0.383, 20, 'K']] [[0.089, 30, 'V'], [0.092, 30, 'V'], [0.053, 34, 'Z'], [0.074, 27, 'S'], [0.106, 27, 'S'], [0.1, 15, 'F'], [0.164, 4, '4']]

I want to compare letters more or less like K || K, R || R or KR8877J || KR8877J to see if they are the same.

 

katemisik
()

Пытаюсь удалить один елемент из копии списка

Форум — Development

max_list_from_all_plates это мой главный список the main list max_list это список в списке и newlist это его копия, я пытаюсь удалить все максимумы из копии, но получаю ошибку: list.remove(x): x not in list

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)
        h = high_indexes[0]

        newlist = max_list
        ma = [max(h) for h in max_list]
        print("max_list", ma)

        #m = [max() for h in newlist]
    #print(max_list_from_all_plates)

        for i in newlist:
            x = i[0] 
            m = [max(x) for x in newlist]
            #print(m)
        print(m)
        newlist.remove(m)

Перемещено leave из general

 

katemisik
()

'int' object is not subscriptable

Форум — Development

Добрый день, хотела бы исправить ошибку во второй части алгоритма на пайтон .код на пайтон:

  


if __name__ == "__main__":

    max_index = 0
    max_list_from_all_plates = []
    accuracy = 0
    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)
        listy = []
        lista = []
        #print(max_list_from_all_plates)
        print(high_indexes)



        maxProbIds = []
        currentMaxIDs = []
        for letterProbability in max_list:
            ids = []
            maxValID = 0
            for probabilityId in range(0, len(letterProbability)):
                if(letterProbability[probabilityId]>letterProbability[maxValID]):
                    maxValID = probabilityId

                print("letterProbability", letterProbability[probabilityId])
                if(letterProbability[probabilityId][0]>threshold):
                    ids.append(probabilityId)
            if(len(ids)==0):
                ids.append(maxValID)
            accuracy += letterProbability[maxValID][0]
            maxProbIds.append(ids)
            currentMaxIDs.append(maxValID)
 
        accuracy /= float(len(high_indexes))
        
        currentText = ""
        predictionShow = ""
        for i in range(len(currentMaxIDs)):
            print("i", i)
            print("currentMaxIDs", currentMaxIDs)

            predictionShow += CATEGORIES[currentMaxIDs[0][i]]+ ": " + str(high_indexes[0][i][currentMaxIDs[i]]) + "  "

high_indexes = список данных нп.

[[0.164, 4, ‘4’], [0.06, 6, ‘6’], [0.383, 20, ‘K’], [0.063, 22, ‘M’]]

 

katemisik
()

сортирую по первому елементу, где я ошибаюсь?

Форум — Development

хочу посортировать елементы по первому значению [[[[0.052 -по пера, 3, ‘3’], [0.066, 7, ‘7’], [0.051, 13, ‘D’], [0.401, 19, ‘J’], [0.077, 30, ‘V’]],

#for index in listy:
    l = len(max_list_from_all_plates)
    for i in range(0, l):
        print(l)
        #for j in range(0, l):
        for j in range(0, l-i-1):
            print(j)
            if (max_list_from_all_plates[j][0] > max_list_from_all_plates[j+ 1][0]):
                temp = max_list_from_all_plates[j]
                max_list_from_all_plates[j]= max_list_from_all_plates[j + 1]
                max_list_from_all_plates[j + 1]= temp
    return max_list_from_all_plates
print("max_list_from_all_plates", Sorting(max_list_from_all_plates))
output:
max_list_from_all_plates [[[[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.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.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.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.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.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']]]]      

Перемещено Zhbert из general

 lists,

katemisik
()

Подскажите какие направления самые востребованые на рынке труда, речь о направлениях для (Software developer) и или графический дизайнер

Форум — General

Подскажите какие направления самые востребованые на рынке труда, речь о направлениях для (Software developer) и или графический дизайнер ? может кто то хотел бы поделиться своим опытом, историей успешного айтишника и тд. Наиболее меня интересуют програмы в которых вы работаете, технологии и языки программирования. спасибо

 ,

katemisik
()

добрый день пожалуйста опищите как сделать сортировку используя последний елемент списка?Сортирую Списки «lists» в общий список который их хранит и называеться «listy»

Форум — General
suma += Highest_score
                lists.append([Highest_score, i])
            lists.extend([suma])
            listy.append(lists)


for index in listy:

    for i in range(0, len(index)): 
  
        if i == (len(index)-1): 
 
            print(listy, i)  

i - это последний елемент. Как посортировать не используя готового sort()?

Пример в стадии разработки:

for n in listy: 
    def Sort(n): 

        l = len(n)

        #print(i)
        #for i in range(0, len(n)):
        for i in range(0, l):
            #if i == l-1:
            for j in range(0, l-i-1): 
                float(j)
                if (n[j][1] > n[j + 1][1]): 
                    tempo = n[j] 
                    n[j]= n[j + 1] 
                    n[j + 1]= tempo 
            print("Sorted", n)

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

def Sort(sub_li): 
    l = len(sub_li) 
    for i in range(0, l): 
        for j in range(0, l-i-1): 
            if (sub_li[j][1] > sub_li[j + 1][1]): 
                tempo = sub_li[j] 
                sub_li[j]= sub_li[j + 1] 
                sub_li[j + 1]= tempo 
    return sub_li 
  
# Driver Code 
sub_li =[['rishav', 10], ['akash', 5], ['ram', 20], ['gaurav', 15]] 
print(Sort(sub_li)) 

 

katemisik
()

RSS подписка на новые темы