<jupyter_start><jupyter_text>Read Network Info from file<jupyter_code>import pickle
import cv2
import os
import numpy as np
def sigmoid(s):
    return 1.0 / (np.exp(-s) + 1.0)

# Forward propagation
def forward(data , weights , biases):
    data = data.reshape(data.shape[0], 1)
    curr = data
    for i in range(len(biases)):
        bias = biases[i]
        weight = weights[i]
        mult = np.dot(weight , curr)
        curr = sigmoid(mult + bias)
        
    return curr
# saving network information from model
filename = "7_model.sav"
    
with open(filename , 'rb') as file:
    net_info = pickle.load(file)                    
    weights = net_info["weights"]           
    biases = net_info["biases"]<jupyter_output><empty_output><jupyter_text>Classify test data<jupyter_code>label_names = ['უ', 'ყ', 'მ', 'შ', 'ძ', 'წ', 'ს', 'ხ', 'ლ', 'ჩ' , '-']
def classify(data , weights , biases):
        ans = forward(data , weights , biases)
        res = [0] * len(ans)
        print("ans",ans)
        print("res",res)
        ind = -1
        for i in range(len(ans)):
            if ans[i] > 0.5:
                res[i] = 1
                ind = i
            else:
                res[i] = 0
        if (sum(res) > 1):
            return '-'
        return label_names[ind]
root_folder = "./data/ასოები/testing_data/"
data_list = []
for image_name in os.listdir(root_folder):
    img = cv2.imread(root_folder + image_name, cv2.IMREAD_GRAYSCALE)
    resized = cv2.resize(img, dsize=(25, 25), interpolation=cv2.INTER_CUBIC)
    (thresh, im_bw) = cv2.threshold(resized.astype(np.uint8), 128, 255, cv2.THRESH_BINARY | cv2.THRESH_OTSU)
    reshaped = im_bw.reshape((625, 1)).astype(int)
    data_list.append((reshaped, image_name))

classified_data = []
gamoicno = 0
ver_gamoicno = 0
for data, img_name in data_list:
    classified_label = classify(data, weights, biases)
    classified_data.append((img_name,classified_label))
    if img_name[0] == classified_label:
        gamoicno +=1
    else:
        ver_gamoicno +=1
print("gamoicno: " + str(gamoicno) + " ver gamoicno: " + str(ver_gamoicno))
print(classified_data)<jupyter_output>[('ლ_101.jpg', 'ლ'), ('ლ_102.jpg', 'ლ'), ('ლ_1026_ლ_git.jpg', 'ს'), ('ლ_103.jpg', 'ლ'), ('ლ_1038_ლ_git.jpg', 'ლ'), ('ლ_105.jpg', 'ლ'), ('ლ_106.jpg', 'ლ'), ('ლ_1070_ლ_git.jpg', 'ლ'), ('ლ_108_ლ_git.jpg', 'ლ'), ('ლ_110.jpg', '-'), ('ლ_1112_ლ_git.jpg', 'ლ'), ('ლ_1118_ლ_git.jpg', 'ლ'), ('ლ_112.jpg', 'ლ'), ('ლ_1139_ლ_git.jpg', 'ლ'), ('ლ_114.jpg', 'ლ'), ('ლ_1158_ლ_git.jpg', 'ლ'), ('ლ_116.jpg', 'ლ'), ('ლ_117.jpg', 'ლ'), ('ლ_1205_ლ_git.jpg', 'ლ'), ('ლ_122.jpg', 'ლ'), ('ლ_1223_ლ_git.jpg', '-'), ('ლ_123.jpg', 'მ'), ('ლ_1248_ლ_git.jpg', '-'), ('ლ_1264_ლ_git.jpg', 'მ'), ('ლ_1289_ლ_git.jpg', 'მ'), ('ლ_129.jpg', 'ლ'), ('ლ_131.jpg', 'ლ'), ('ლ_1311_ლ_git.jpg', '-'), ('ლ_132.jpg', 'ლ'), ('ლ_1321_ლ_git.jpg', 'ლ'), ('ლ_133.jpg', 'ლ'), ('ლ_1335_ლ_git.jpg', '-'), ('ლ_1352_ლ_git.jpg', 'მ'), ('ლ_1372_ლ_git.jpg', '-'), ('ლ_1390_ლ_git.jpg', '-'), ('ლ_1407_ლ_git.jpg', 'ლ'), ('ლ_141_ლ_git.jpg', 'ლ'), ('ლ_1445_ლ_git.jpg', 'ლ'), ('ლ_1500_ლ_git.jpg', '-'), ('ლ_1521_ლ_git.jpg', '-'), ('ლ_1527_ლ_git.jpg', 'ლ'), ('ლ_15[...]
{'fraction_non_alphanumeric': 0.21601016518424396, 'fraction_numerical': 0.06035578144853875, 'mean_word_length': 3.466666666666667, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '490478', 'license': 'MIT', 'n_tokens_mistral': 1424, 'n_tokens_neox': 1407, 'n_words': 242, 'path': '7_scoring.ipynb', 'repo_name': 'Gvantsats/ML-final-project', 'size': '3148'}