def find_least_frequent(filtered_signal):
least_frequent_.clear()
frequent = mode(filtered_signal)
for i in range(0, len(filtered_signal)):
if filtered_signal[i] != frequent:
least_frequent_.append(i)
i = None
del i
return least_frequent_
def search_by_similarity(leastfreq, filteredsignal):
sample1.clear()
sample2.clear()
fullcycle = []
fullcycle.clear()
similarity.clear()
for i in range(0, round(len(leastfreq)/2)):
for j in range(0, leastfreq[i+1]-1):
sample1.append(filteredsignal[j])
j = None
for j in range(leastfreq[i+1], leastfreq[i+1] + len(sample1)):
sample2.append(filteredsignal[j])
j = None
if len(sample1) == len(sample2):
for j in range(0, len(sample1)):
if sample1[j] == sample2[j]:
similarity.append(True)
j = None
if ((len(similarity)/len(sample1)*100)) >= 95:
fullcycle = sample1
i = None
return(fullcycle)
Pergunta
leandro Riato
Estou tendo problemas com o índex de um loop for
Algoritmo:
similarity = []
sample1 = []
sample2 = []
least_frequent_ = []
engine_phase_high_filtered = [20, 20, 20, 20, 2, 2, 2, 2, 20, 20, 20, 20, 20, 20, 20, 2, 2, 2, 2, 20, 20, 20, 20, 20, 20, 20, 2, 2, 2, 2, 20, 20, 20, 20, 20, 20, 20, 2, 2, 2, 2, 20, 20, 20, 20, 20, 20, 20, 2, 2, 2, 2, 20, 20, 20, 20, 20, 20, 20, 2, 2, 2, 20, 20, 20, 20, 2, 2, 2, 2, 20, 20, 20, 20, 20, 20, 20, 2, 2, 2, 2, 20, 20, 20, 20, 20, 20, 20, 2, 2, 2, 2, 20, 20, 20, 20, 20, 20, 20, 2, 2, 2, 2, 20, 20, 20, 20, 20, 20, 20, 2, 2, 2, 2, 20, 20, 20, 20, 20, 20, 20, 2, 2, 2, 20, 20, 20, 20, 2, 2, 2, 2, 20, 20, 20, 20, 20, 20, 20, 2, 2, 2, 2, 20, 20, 20, 20, 20, 20, 20, 2, 2, 2, 2, 20, 20, 20, 20, 20, 20, 20, 2, 2, 2, 2, 20, 20, 20, 20, 20, 20, 20, 2, 2, 2, 2, 20, 20, 20, 20, 20, 20, 20, 2, 2, 2]
def find_least_frequent(filtered_signal):
least_frequent_.clear()
frequent = mode(filtered_signal)
for i in range(0, len(filtered_signal)):
if filtered_signal[i] != frequent:
least_frequent_.append(i)
i = None
del i
return least_frequent_
def search_by_similarity(leastfreq, filteredsignal):
sample1.clear()
sample2.clear()
fullcycle = []
fullcycle.clear()
similarity.clear()
for i in range(0, round(len(leastfreq)/2)):
for j in range(0, leastfreq[i+1]-1):
sample1.append(filteredsignal[j])
j = None
for j in range(leastfreq[i+1], leastfreq[i+1] + len(sample1)):
sample2.append(filteredsignal[j])
j = None
if len(sample1) == len(sample2):
for j in range(0, len(sample1)):
if sample1[j] == sample2[j]:
similarity.append(True)
j = None
if ((len(similarity)/len(sample1)*100)) >= 95:
fullcycle = sample1
i = None
return(fullcycle)
least_frequent = find_least_frequent(engine_phase_high_filtered)
search = search_by_similarity(least_frequent, engine_phase_high_filtered)
Preciso que esse algoritmo encontra um ciclo que tenha 95% ou mais de precisão nos valores.
Link para o comentário
Compartilhar em outros sites
0 respostass a esta questão
Posts Recomendados
Participe da discussão
Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.