예제 #1
0
import func
import pickle

test_year_sem_list = ['107-1', '107-2']
score = func.findGrads(func.findAllStudent_fromScore(), func.findAllCos(),
                       test_year_sem_list)
with open('data.pkl', 'wb') as f:
    pickle.dump(score, f)
예제 #2
0
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))
예제 #3
0
        os.mkdir('./res')

    std_cnt = [len(stds) for stds in clu_stds_list]
    plt.bar(range(len(std_cnt)), std_cnt)
    plt.xlabel('Cluster Idx')
    plt.ylabel('Student Number')
    plt.title(f'{method} Student Number')
    plt.savefig(f'res/{method}.png')
    plt.close()
    ###########################
    with open(f'res/{method}.json', 'w') as f:
        json.dump(res, f, indent=4)


all_student = func.Student_fromScore()
all_cos = func.findAllCos()
cos_to_num = {}
num_to_cos = {}
with open('cos_to_num.json', 'w') as f1, open('num_to_cos.json', 'w') as f2:
    for i in range(len(all_cos)):
        cos_to_num[all_cos[i]] = i
        num_to_cos[i] = all_cos[i]
    json.dump(cos_to_num, f1, indent=4, ensure_ascii=False)
    json.dump(num_to_cos, f2, indent=4, ensure_ascii=False)

score = func.findGrads(all_student, all_cos, skip_year_sem)
data = np.stack([i['data'] for i in score])
std_list = np.stack([i['std_id'] for i in score])
print('Spectral Clustering')
clustering = SpectralClustering(n_clusters=Number_Of_Cluster,
                                affinity='nearest_neighbors').fit(data)
예제 #4
0
# import torch.nn as nn
# import torch.utils.data as Data
# import torchvision
import func
import numpy as np

# Hyper parameter
MIN_COS_NUM = 0
EPOCH = 50
ITER_TIMES = 5
BATCH_SIZE = 30
LR = 0.00001
DROP_PROB = 0.2

# Data prepare
score = func.findGrades(func.findAllStudent_byGrades(), func.findAllCos())
score = np.float32(np.nan_to_num(score))
print(len(score[0]))
input()
cond = np.sum(score != 0, axis=1) > MIN_COS_NUM
score = score[cond]
train_loader = Data.DataLoader(dataset=score,
                               batch_size=BATCH_SIZE,
                               shuffle=True)


# NN define
class AutoEncoder(nn.Module):
    def __init__(self):
        super(AutoEncoder, self).__init__()