Student Motivation On Performance-1
Student Motivation On Performance-1
June 4, 2024
1
4 3 2 3 3 3
2 Descriptive statistics
[5]: print(df.describe())
2
Work relation Security Cultural belief Hostile environment \
count 20.000000 20.000000 20.000000 20.000000
mean 3.300000 3.150000 2.850000 2.650000
std 0.656947 0.366348 0.812728 0.587143
min 2.000000 3.000000 2.000000 1.000000
25% 3.000000 3.000000 2.000000 2.000000
50% 3.000000 3.000000 3.000000 3.000000
75% 4.000000 3.000000 3.250000 3.000000
max 4.000000 4.000000 4.000000 3.000000
[ ]:
3
[7]: # Visualize the correlation matrix
plt.figure(figsize=(10, 8))
sns.heatmap(correlation_matrix, annot=True, cmap='coolwarm', linewidths=0.5)
plt.title('Correlation Matrix')
plt.show()
[ ]:
[ ]:
4
4 Perform Factor Analysis
[8]: # Perform Factor Analysis
fa = FactorAnalysis(n_components=4)
factors = fa.fit_transform(df)
print(df[['Factor1', 'Factor2']].head())
Factor1 Factor2
0 0.536643 -0.618086
1 -0.600141 0.917624
2 -0.610987 0.679136
3 -0.492215 2.242386
4 0.887281 2.003611
[ ]:
[ ]:
5 Cluster Analysis
[9]: # Perform K-means clustering
kmeans = KMeans(n_clusters=10)
clusters = kmeans.fit_predict(df)
print(df[['Cluster']].head())
Cluster
0 9
1 7
2 2
3 8
4 5
[ ]:
[ ]:
5
6 Regression Analysis
[9]: # Define the independent variables (X) and dependent variable (y)
X = df[['Intrinsic', 'Institution suport', 'Promotion appraisal', 'Performance␣
↪motivating environment', 'Performance demotivating environment', 'Cultural␣
y = df['Student motivation']
6
Promotion appraisal -0.0171 0.127 -0.135 0.895
-0.291 0.257
==============================================================================
Omnibus: 2.119 Durbin-Watson: 1.906
Prob(Omnibus): 0.347 Jarque-Bera (JB): 0.838
Skew: -0.457 Prob(JB): 0.658
Kurtosis: 3.414 Cond. No. 1.89e+17
==============================================================================
Notes:
[1] Standard Errors assume that the covariance matrix of the errors is correctly
specified.
[2] The smallest eigenvalue is 4.19e-32. This might indicate that there are
strong multicollinearity problems or that the design matrix is singular.
[ ]:
[ ]:
7 ANOVA
[10]: # Perform ANOVA
f_val, p_val = stats.f_oneway(df['Student motivation'][df['Performance␣
↪motivating environment'] == 1],
df['Student motivation'][df['Performance␣
↪motivating environment'] == 2],
df['Student motivation'][df['Performance␣
↪motivating environment'] == 3],
df['Student motivation'][df['Performance␣
↪motivating environment'] == 4])
8 Barchart
[16]: # Bar chart for the 'Intrinsic' variable
plt.figure(figsize=(10, 6))
df['Intrinsic'].value_counts().sort_index().plot(kind='bar', color='skyblue')
plt.title('Distribution of Intrinsic Factor Scores')
plt.xlabel('Intrinsic Factor Scores')
plt.ylabel('Frequency')
plt.xticks(rotation=0)
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.show()
7
[17]: # Bar chart for the Teacher Salary satisfaction
plt.figure(figsize=(10, 6))
df['Satisfaction'].value_counts().sort_index().plot(kind='bar', color='skyblue')
plt.title('Distribution of Teacher Salary satisfaction Scores')
plt.xlabel('Teacher Salary satisfaction')
plt.ylabel('Frequency')
plt.xticks(rotation=0)
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.show()
8
[18]: # Bar chart for the Student Performance motivating environment
plt.figure(figsize=(10, 6))
df['Performance motivating environment'].value_counts().sort_index().
↪plot(kind='bar', color='skyblue')
9
9 Pie Chart
[20]: # Create a pie chart for the 'Gender' variable
gender_counts = df['Gender'].value_counts()
plt.figure(figsize=(8, 8))
plt.pie(gender_counts, labels=['Male', 'Female'], autopct='%1.1f%%',␣
↪startangle=140, colors=['lightblue', 'lightcoral'])
plt.title('Gender Distribution')
plt.axis('equal') # Equal aspect ratio ensures that pie is drawn as a circle.
plt.show()
10
[22]: # Create a pie chart for the 'Age' variable
age_mapping = {1: '20-30', 2: '31-40', 3: '41-50', 4: '51-60'}
df['Age Group'] = df['Age'].map(age_mapping)
11
[ ]:
12