<jupyter_start><jupyter_text>Loading Data<jupyter_code># Here the data is available is STL format

stl_folder = "data/stl"

ply_folder = "data/ply"

if not os.path.exists(ply_folder):
    os.makedirs(ply_folder)<jupyter_output><empty_output><jupyter_text>Convertion to PLY<jupyter_code># Converting .stl files to .ply format for feature extraction

stl2ply_convert(stl_folder,ply_folder)<jupyter_output><empty_output><jupyter_text>Feature Extraction<jupyter_code>#Feature Extraction from .ply files

file_names, file_paths, features = feature_extract(ply_folder, model, device)

#Printing the different classes
unique_list = []

# traverse for all elements
for x in file_names:
    # check if exists in unique_list or not
    if x not in unique_list:
        unique_list.append(x)

for x in unique_list:
    print(x)
     
# It is adviced to pickle the extracted features to save time in execution next time

data = [file_names, file_paths, features]
with open("data/names_paths_features_featurenet.dat", "wb") as f:
    pickle.dump(data, f) 
    
#Unpickling the features

with open("data/names_paths_features_featurenet.dat", "rb") as f:
    file_names, file_paths, features = pickle.load(f)

print("shape of a sample feature vector:",features[0].shape)<jupyter_output>shape of a sample feature vector: (14, 32)<jupyter_text>Benchmarking<jupyter_code>N_files = len(features)

tested_files = list()
sim_list = list()
sorted_list = list()
check_1 = 0
check_5 = 0
for i in range(0,N_files):
    test_feature = features[i]
    tested_files.clear()
    sim_list.clear()
    for j in range(0,N_files):
        if file_names[j] not in tested_files:
            tested_files.append(file_names[j])
            db_feature = features[j]
            # finding out the similarity between features
            sim_list.append(abs(LA.norm(test_feature, 'fro') - LA.norm(db_feature, 'fro')))
    sorted_list = sort_list(file_names, sim_list)
    check_1 += (file_names[i] ==  sorted_list[0])
    if file_names[i] in sorted_list[0:4]:
        check_5 += 1     
print("Top-5 Accuracy with Frobenius Norm is "+"\t",check_5/N_files)
print("Accuracy with Frobenius Norm is is "+"\t",check_1/N_files)<jupyter_output>Top-5 Accuracy with Frobenius Norm is 	 0.847875
Accuracy with Frobenius Norm is is 	 0.311
{'fraction_non_alphanumeric': 0.10188019239177962, 'fraction_numerical': 0.014429383471797114, 'mean_word_length': 4.5, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '481272', 'license': 'MIT', 'n_tokens_mistral': 828, 'n_tokens_neox': 797, 'n_words': 203, 'path': 'Benchmarking_featurenet.ipynb', 'repo_name': 'kamalrbg/Machining-Feature-Retrieval', 'size': '2287'}