<jupyter_start><jupyter_text>课程难度评价模型 要点1. 标准化成绩2. 计算信度3. 做出趋势  本篇代码中使用特定某一门科目，实际是可变的，输入不同的科目可以分析出不同的趋势  可变的部分进行注释，实际使用固定的科目<jupyter_code>import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import datetime
import os
from scipy import stats

dataToDeal = pd.read_csv('bks_cjxx_out_true.csv',skiprows=0)
dA = dataToDeal
# print(dA)
dataAfterDeal = dA[['xh','ksrq','kch','kccj']]
courseNeedToAnalysis = 1110020010 #课程号可以修改成别的课程
dataAfterDeal = dataAfterDeal[dataAfterDeal['kch'].isin([str(courseNeedToAnalysis)])]
dataAfterDeal = dA[['xh','ksrq','kccj']]
dataAfterDeal = dataAfterDeal.sort_values(by='ksrq',ascending=True)
dBtemp = dataAfterDeal
print(dBtemp.drop_duplicates('ksrq'))
dataAfterDeal = dataAfterDeal.values

# 分类搜集各个年份的数据
# print(dataAfterDeal)
grades=[[],[],[],[],[],[],[],[],[],[],[]]
for row in dataAfterDeal:
    if row[1] >= 200000 and row[1] <= 300000 and row[2] <= 100:
        grades[int(row[1]/1000)-2009].append(row[2])
    elif row[1] >= 20000000 and row[1] <= 30000000 and row[2] <= 100:
        grades[int(row[1]/10000)-2009].append(row[2])
    elif row[1] >= 100000 and row[1] <= 200000 and row[2] <= 100:
        grades[int(row[1]/10000)+2000-2009].append(row[2])
print(grades)

#计算出平均成绩,以及与对应的高斯分布的协方差，平均成绩的变化反映难度的变化，协方差的变化反映信度的变化
averageGrades = [0,0,0,0,0,0,0,0,0,0,0]
pNormalGrades = [0,0,0,0,0,0,0,0,0,0,0]
i = 0
for temp in grades:
    if(len(temp)!=0):
        averageGrades[i] = sum(temp)/float(len(temp))
        if(len(temp)>=3):
            pNormalGrades[i] = stats.normaltest(temp)
            print(pNormalGrades[i])
            print()
    i += 1
print(averageGrades)
print(pNormalGrades)

#总结，做出图像，其中理念的数据均不符合标准正态分布，故不分析其信度
time=range(2009,2020)
plt.plot(time,averageGrades,'bo-')
plt.xticks(fontsize=12)
plt.yticks(fontsize=12)
plt.xlabel('Time',fontsize=14)
plt.ylabel('Average grade of the course',fontsize=14)
fig = plt.gcf()
fig.set_size_inches(7.2, 4.2)
print()
fig.savefig(os.getcwd()+'\pictureCourseGrade.png', dpi=300)
plt.show()<jupyter_output>
{'fraction_non_alphanumeric': 0.17527308838133068, 'fraction_numerical': 0.07795431976166832, 'mean_word_length': 5.877133105802048, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '302692', 'license': 'MIT', 'n_tokens_mistral': 1052, 'n_tokens_neox': 991, 'n_words': 127, 'path': 'campus_data_mining/reference/18/gradeAnalysis.ipynb', 'repo_name': 'Yeolnim/big-data-competition', 'size': '2014'}