<jupyter_start><jupyter_text>SnaPEA Exact Mode<jupyter_code>SnaPEA = np.zeros((h_,l_))
for i in range(0,h_):
    for j in range(0,l_):
        for iter in range(len(weights)):
                SnaPEA[i][j]+=(X[i+weights[iter][0]][j+weights[iter][1]]*weights[iter][2])
                snapea_count+=1
                if SnaPEA[i][j]<0:
                   SnaPEA[i][j]=0
                   break<jupyter_output><empty_output><jupyter_text>Proposed Algorithm<jupyter_code>pos = []
neg = []
    
for l1 in range(f):
    for l2 in range(f):
          if W[l1][l2]>0:
              pos.append((l1,l2,W[l1][l2]))
          else:
              neg.append((l1,l2,W[l1][l2]))

pos = Sort_Tuple_Reverse(pos)
neg = Sort_Tuple(neg)

print(pos)
print(neg)

lim = min(len(pos),len(neg))
Prop = np.zeros((h_,l_))
for i in range(0,h_,1):
    for j in range(0,l_,1):
        partial_sum = 0
        for iter in range(lim):
            partial_sum+=(pos[iter][2]*(X[i+pos[iter][0]][j+pos[iter][1]])) + (neg[iter][2]*(X[i+neg[iter][0]][j+neg[iter][1]]))
            Prop[i][j] = partial_sum
            proposed_algo_count += 1
            if partial_sum<0:
               Prop[i][j]=0
               break;<jupyter_output><empty_output><jupyter_text>Original<jupyter_code>Orig = np.zeros((h_,l_))
for i in range(0,h_):
    for j in range(0,l_):
        for r in range(f):
            for c in range(f):
                Orig[i][j]+=(X[i+r][j+c]*W[r][c])
                original_count+= 1
        if Orig[i][j]<0:
            Orig[i][j]=0
       
S_TP = 0
S_TN = 0
S_FP = 0
S_FN = 0

Pr_TP = 0
Pr_TN = 0
Pr_FP = 0
Pr_FN = 0

for i in range(0,h_):
    for j in range(0,l_):
        if Orig[i][j]==0:
          if SnaPEA[i][j]==0:
             S_TP += 1
          if SnaPEA[i][j]>0:
             S_FP += 1
          if Prop[i][j]==0:
             Pr_TP += 1
          if Prop[i][j]>0:
             Pr_FP += 1
        else:
          if SnaPEA[i][j]>0:
             S_TN += 1
          if SnaPEA[i][j]==0:
             S_FN += 1
          if Prop[i][j]>0:
             Pr_TN += 1
          if Prop[i][j]==0:
             Pr_FN += 1
print("Original")
plt.imshow(Orig, cmap='seismic', interpolation='nearest')
plt.show()
print("Proposed")
plt.imshow(Prop, cmap='seismic', interpolation='nearest')
plt.show()
print("SnaPEA")
plt.imshow(SnaPEA, cmap='seismic', interpolation='nearest')
plt.show()
print("Snapea: ", snapea_count)
print("Proposed Algorithm: ", proposed_algo_count)
print("Original count: ", original_count)
snapea_precision = S_TP/(S_TP + S_FP)
snapea_recall = S_TP/(S_TP + S_FN)

prop_precision = Pr_TP/(Pr_TP + Pr_FP)
prop_recall = Pr_TP/(Pr_TP + Pr_FN)

print("Snapea Precision : ", snapea_precision)
print("Snapea Recall : ", snapea_recall)

print("Proposed Algorithm Precision: ", prop_precision)
print("Proposed Algorithm Recall: ", prop_recall)

S_F1 = 2*(snapea_recall*snapea_precision)/(snapea_precision+snapea_recall)
Pr_F1 = 2*(prop_recall*prop_precision)/(prop_precision+prop_recall)

print("Snapea F1 Score: ", S_F1)
print("Proposed Algorithm F1 Score: ", Pr_F1)<jupyter_output>Snapea Precision :  1.0
Snapea Recall :  0.8386917147797543
Proposed Algorithm Precision:  0.9962959080266974
Proposed Algorithm Recall:  0.8441450777202073
Snapea F1 Score:  0.9122700755522968
Proposed Algorithm F1 Score:  0.913931273240159
{'fraction_non_alphanumeric': 0.1599879481771618, 'fraction_numerical': 0.04911117806568244, 'mean_word_length': 2.8160919540229883, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '395015', 'license': 'MIT', 'n_tokens_mistral': 1453, 'n_tokens_neox': 1349, 'n_words': 237, 'path': 'Prototype/Algorithm1.ipynb', 'repo_name': 'yemaedahrav/CNN_Accelerators', 'size': '3319'}