ARTICLE DETAIL

资讯详情

深耕郑州网站建设与运营推广的一线实战洞察。

Python数据分析-高中生的学业成功因素(学生表现数据集)

Python数据分析-高中生的学业成功因素(学生表现数据集) 一、研究背景随着教育事业的发展和教育资源的不断丰富如何有效地评估学生的学习表现成为教育研究中的一个重要课题。学生表现数据分析是通过收集和分析学生在学习过程中的各种数据如成绩、出勤率、参与度等以期发现影响学生表现的因素从而为教育管理者和教师提供科学的决策依据。近年来随着数据科学和机器学习技术的快速发展数据驱动的教育研究逐渐成为提升教育质量的重要手段。在现代教育中学生的学习表现不仅仅取决于智力因素还受到家庭环境、学校资源、教师水平、学生的学习态度和习惯等多方面因素的影响。传统的教育评估方式通常局限于考试成绩无法全面反映学生的学习状况和潜力。因此利用大数据分析技术对学生的表现进行多维度的分析可以更全面地了解学生的学习状态进而为个性化教学和教育质量提升提供依据。本研究旨在通过分析学生表现数据探讨影响学生学习表现的关键因素评估不同因素对学生成绩的影响并提出相应的教育干预策略。希望通过本研究为教育管理者和教师提供数据支持促进教育质量的提升和学生全面发展。二、研究意义全面评估学生表现通过对学生多维度数据的分析全面评估学生的学习表现发现单一考试成绩无法揭示的潜在问题和优点为教师和家长提供更加科学和全面的学生评价。个性化教学支持基于数据分析的结果可以针对不同学生的学习需求和特点制定个性化的教学方案提高教学的针对性和有效性帮助每个学生发挥其最大潜力。提升教育质量通过研究影响学生表现的因素识别和解决教育中的薄弱环节优化教育资源配置提升整体教育质量和教学效果。教育政策制定依据本研究的结果可以为教育管理者提供数据支持辅助制定和调整教育政策推动教育改革和创新促进教育公平和质量提升。三、实证分析导入需要的包import numpy as np import pandas as pd import seaborn as sns import matplotlib.pyplot as plt import matplotlib.ticker as ticker import missingno as msno from matplotlib.ticker import MaxNLocator from colorama import Fore, init from sklearn.pipeline import Pipeline from sklearn.preprocessing import StandardScaler, OneHotEncoder from sklearn.compose import ColumnTransformer from sklearn.model_selection import train_test_split from sklearn.linear_model import LogisticRegression from sklearn.tree import DecisionTreeClassifier from sklearn.ensemble import RandomForestClassifier, GradientBoostingClassifier, BaggingClassifier, AdaBoostClassifier from xgboost import XGBClassifier from lightgbm import LGBMClassifier from sklearn.svm import SVC from sklearn.metrics import accuracy_score from sklearn.metrics import accuracy_score, classification_report, confusion_matrix读取数据集将表格形式改的好看一下df pd.read_csv(Student_performance_data _.csv) def get_pretty_frame(df): return df.style.set_table_styles( [{selector: thead th, props: [(background-color, #3b528b), (color, black), (border, 1px solid #dddddd)]}, {selector: tbody tr:nth-child(even), props: [(background-color, #f9f9f9)]}, {selector: tbody tr:nth-child(odd), props: [(background-color, white)]}, {selector: tbody td, props: [(border, 1px solid #dddddd)]}] ).set_properties(**{text-align: center})对数据集进行描述性统计df_summary df.describe() get_pretty_frame(df_summary)可视化缺失值查看是否有无重复行df.duplicated().sum()记下来对数据可视化探索性分析查看GradeClass的分别情况grade_counts df[GradeClass].value_counts() grades grade_counts.index.tolist() counts grade_counts.values.tolist() total_counts sum(counts) percentages [(count / total_counts) * 100 for count in counts] colors [orange, lightblue, green, purple, coral] explode [0.05] * len(grades) # Slightly explode all slices plt.figure(figsize(12, 6)) plt.pie(percentages, labelsgrades, colorscolors, autopct%1.1f%%, startangle140, shadowTrue, explodeexplode, wedgeprops{edgecolor: black}) plt.legend(grades, titleGradeClass, loccenter left, bbox_to_anchor(1, 0, 0.5, 1)) plt.title(GradeClass Distribution, fontsize15) plt.axis(equal) plt.show()再次查看Categorical Variable 的分别情况for i, col in enumerate(cat_col): vc df[col].value_counts(normalizeTrue) axs[i].bar(vc.index.astype(str), vc, color#3b528b) axs[i].set_title(col, fontsize10) axs[i].yaxis.set_major_formatter(plt.FuncFormatter(lambda x, _: f{x:.0%})) axs[i].set_xlabel(Category) axs[i].set_ylabel(Percentage) # Remove empty subplots for j in range(i1, len(axs)): fig.delaxes(axs[j]) plt.suptitle(Categorical Variables Distribution, fontsize13, y1.02) plt.tight_layout() plt.show()查看Numerical的分布情况fig, axs plt.subplots(len(num_col) // 2 len(num_col) % 2, 2, figsize(12, 6)) axs axs.flatten() for i, col in enumerate(num_col): axs[i].hist(df[col], bins30, color#9ee742, edgecolorblack, densityTrue) axs[i].set_title(col, fontsize10) axs[i].set_xlabel(Value) axs[i].set_ylabel(Density) for j in range(i1, len(axs)): fig.delaxes(axs[j]) plt.suptitle(Numerical Variables Distribution, fontsize10, y1.02) plt.tight_layout() plt.show()记下来进行双变量分析双变量分析是一种统计分析方法用于研究两个变量之间的关系。它旨在确定两个变量之间是否存在关联、关联的强度和方向等。首先查看Tutoring和GradeClass的关系crosstab_gender pd.crosstab(df[Tutoring], df[GradeClass]) crosstab_gender crosstab_gender.div(crosstab_gender.sum(axis1), axis0) * 100 ax_gender crosstab_gender.plot(kindbar, stackedTrue) plt.xlabel(Gender (0 No Tutoring, 1 Tutoring)) plt.ylabel(Percentage) plt.title(Distribution of GradeClass Based on Tutoring) plt.legend(titleTarget) plt.xticks(rotation0) for p in ax_gender.patches: width p.get_width() height p.get_height() x, y p.get_xy() ax_gender.annotate(f{height:.1f}%, (x width / 2, y height / 2), hacenter, vacenter, fontsize10, colorwhite) plt.show()Gender和GradeClass的关系接下来查看相关性分析corr df.corr() target_corr corr[GradeClass].drop(GradeClass) sns.set(font_scale1.2) sns.set_style(white) sns.set_palette(PuBuGn_d) sns.heatmap(target_corr.to_frame(), cmapBrBG, annotTrue, fmt.2f) plt.title(Correlation with GradeClass Column) plt.show()记下来对数据离群值查看for i, col in enumerate(num_col): axs[i].boxplot(df1[col]) axs[i].set_title(col, fontsize10) axs[i].set_ylabel(Value) for j in range(i1, len(axs)): fig.delaxes(axs[j]) plt.suptitle(Boxplot of Numerical Variables, fontsize13, y1.02) plt.tight_layout() plt.show()记下来对数据标准化和模型建立models { Decision Tree: DecisionTreeClassifier(), Random Forest: RandomForestClassifier(), Gradient Boosting: GradientBoostingClassifier(), SVC: SVC(), LGBM: LGBMClassifier(), Bagging: BaggingClassifier(), XGB: XGBClassifier(), AdaBoost: AdaBoostClassifier() }X_train, X_test, y_train, y_test train_test_split(X, y, test_size0.2, random_state42)for model_name, model in models.items(): print(fEvaluating {model_name}...) clf Pipeline(steps[(preprocessor, preprocessor), (classifier, model)]) clf.fit(X_train, y_train) y_pred clf.predict(X_test) accuracy accuracy_score(y_test, y_pred) print(f{model_name}: Accuracy {accuracy:.4f}) print(Classification Report:) print(classification_report(y_test, y_pred)) cm confusion_matrix(y_test, y_pred) sns.heatmap(cm, annotTrue, fmtd, cmapBlues, xticklabelsmodel.classes_, yticklabelsmodel.classes_) plt.xlabel(Predicted) plt.ylabel(True) plt.title(fConfusion Matrix for {model_name}) plt.show()决策树结果随机森林结果梯度提升结果SCVxgboost结果四、结论本研究通过对学生表现数据的分析发现以下几个主要结论学习时间和出勤率的影响学生每周的学习时间和出勤率对其学业成绩有显著影响。投入更多时间学习且出勤率高的学生其GPA通常较高。家庭背景的作用父母的教育水平和家庭支持对学生的学业成绩有重要影响。父母教育水平较高且家庭支持较多的学生通常表现更为优异。课外活动的影响参与课外活动如音乐和志愿服务的学生在学业上表现出一定的积极影响表明课外活动对学生的全面发展具有积极作用。个性化干预的必要性不同学生的表现受多种因素的综合影响针对这些因素的个性化干预策略能够有效提高学生的学业成绩和整体表现。总的来说本研究通过对学生表现数据的多维度分析揭示了影响学生学业成绩的关键因素并提出了相应的教育干预建议。未来的研究可以进一步结合更多的数据和更先进的分析方法优化学生表现评估模型为教育管理和教学实践提供更加有力的数据支持。
返回列表