import torch import torch.nn as nn import auto_training as at import func import numpy as np import csv import pandas as pd sem = input('Enter the semester: ') # parameter INF = 123.0 K = 10 # prepare data and model stds = func.findAllStudent() allCos = func.findAllCos() score = func.findGrades(stds, allCos) score = np.float32(np.nan_to_num(score)) score = torch.FloatTensor(score) currentCos = func.findCurrentCos(sem) AutoEncoder = at.AutoEncoder autoencoder = torch.load('net2.pkl') # start encode print('Encoding') encoded, _ = autoencoder(score) encoded = encoded.detach().numpy() # get similarity print('Getting Similarity') s_len = len(encoded)
import func import json sem = '108-1' current_cos = func.findCurrentCos(sem) # current cos name all_cos = func.findAllCos() # all cos name all_student_id = func.findAllStudent() # all student id ## set up id pair in graph ## get student_id and it's passed cos name ## translate it to graph id id_pair = dict() # graph id pair max_id = 0 id_cos_pair = func.findIdCos() res_pair = dict() for std_id, coses in id_cos_pair.items(): if std_id not in id_pair: id_pair[std_id] = max_id max_id += 1 cos = [] for i in coses: if i not in id_pair: id_pair[i] = max_id max_id += 1 cos.append(str(id_pair[i])) graph_id = str(id_pair[std_id]) res_pair[graph_id] = cos ## output json file with open('input.json', 'w') as f: f.write(json.dumps(res_pair))