'''spec: OE, MN, FK, FM'''
# students = win.getStudents(shuffle=False)

# cl = students[0].class_
# sp = students[0].spec
# anno = []
# anno2 = []
# for ii, st in enumerate(students):
#     if st.class_ != cl:
#         anno.append((ii - 1, students[ii - 1].class_))
#         cl = st.class_
#     if st.spec != sp:
#         anno2.append((ii - 1, students[ii - 1].spec))
#         sp = st.spec
# anno.append(((len(students) - 1), students[-1].class_))
# anno2.append(((len(students) - 1), students[-1].spec))
# anno = anno + anno2

students = win.getData(shuffle=False, spec='FK')

# win.shuffleIt(students, 2)
# win.shuffleIt(students, 1)

# st_corr = pairwise_distances(students, students, 'jaccard')
co_corr = pairwise_distances(students.T, students.T, 'jaccard')

heatmap.plotheat(co_corr, xlabels=win.getCoursesNames(), ylabels=win.getCoursesNames(), mode='special')
# heatmap.plotheat(st_corr, changeTicks=False, annotation=anno, mode='special')
matplotlib.rcParams["text.usetex"] = True
# win.shuffleIt(students, 2)
# win.shuffleIt(students, 1)

# st_corr = np.corrcoef(students)

# shuffle C
students = win.getData()
win.shuffleIt(students, 2)
co_corr = np.corrcoef(students, rowvar=0)
heatmap.plotheat(
    co_corr,
    xlabels=[pl_en[x][1] for x in win.getCoursesNames()],
    ylabels=["" for x in win.getCoursesNames()],
    rotation=90,
    num_levels_=6,
    mode="special",
    vmin=vmin,
    vmax=vmax,
    showplot=False,
    removebar=True,
)
savePic(name="c_heat_shufC.eps", path="/home/luke/Documents/APPA/img/fifth/")
# real
students = win.getData()
co_corr = np.corrcoef(students, rowvar=0)
heatmap.plotheat(
    co_corr,
    xlabels=[pl_en[x][1] for x in win.getCoursesNames()],
    ylabels=[pl_en[x][1] for x in win.getCoursesNames()],
    rotation=90,
    num_levels_=6,
anno2 = []
for ii, st in enumerate(students):
    if st.class_ != cl:
        anno.append((ii - 1, students[ii - 1].class_))
        cl = st.class_
    if st.spec != sp:
        anno2.append((ii - 1, students[ii - 1].spec))
        sp = st.spec
anno.append(((len(students) - 1), students[-1].class_))
anno2.append(((len(students) - 1), students[-1].spec))
anno = anno + anno2

courses = win.getCourses()
'''correlation course-course'''
co_corr = np.empty([len(courses), len(courses)])
for ii, c1 in enumerate(courses):
    for jj, c2 in enumerate(courses):
        v1 = []
        v2 = []
        for st in students:
            v1.append(st.grades[ii])
            v2.append(st.grades[jj])
        random.shuffle(v1)
        random.shuffle(v2)
        co_corr[ii, jj] = mutual_info_score(v1, v2)[0]

# print(len(students))
heatmap.plotheat(co_corr, xlabels=win.getCoursesNames(), ylabels=win.getCoursesNames())
heatmap.plotheat(st_corr, changeTicks=False, annotation=anno)
# heatmap.plotheat(st_corr, changeTicks=False)