Это проект об универсальном наборе данных для оценки студентов Турции, который собирается для kaggle. где, поскольку этот набор данных состоит из 5820 строк и 33 функций. такие функции, как «instr», «class», «nb.repeat», «посещаемость», «сложность», «Q1», «Q2», «Q3», «Q4», «Q5», «Q6», « Q7", "Q8", "Q9", "Q10", "Q11", "Q12", "Q13",
"Q14", "Q15", "Q16", "Q17", "Q18" , "Q19", "Q20", "Q21", "Q22", "Q23",
"Q24", "Q25", "Q26", "Q27", "Q28". в этом наборе данных важны все функции.

# реализация проекта

импортировать numpy как np
импортировать pandas как pd
импортировать matplotlib.pyplot как plt
импортировать seaborn как sns
%matplotlib inline
импортировать предупреждения
warnings.filterwarnings ('ignore')
pd.options.display.max_columns = 99 # для просмотра всех значений в наборе данных

# загрузка набора данных

df = pd.read_csv(r"D:\projects\ML Projects datasets\turkiye-student-evaluation_generic.csv")

дф.голова()

дф.форма

(5820, 33)

# поиск нулевых значений

df.isna().sum()

instr         0
class         0
nb.repeat     0
attendance    0
difficulty    0
Q1            0
Q2            0
Q3            0
Q4            0
Q5            0
Q6            0
Q7            0
Q8            0
Q9            0
Q10           0
Q11           0
Q12           0
Q13           0
Q14           0
Q15           0
Q16           0
Q17           0
Q18           0
Q19           0
Q20           0
Q21           0
Q22           0
Q23           0
Q24           0
Q25           0
Q26           0
Q27           0
Q28           0
dtype: int64

df.describe() # статическая информация

df.info()

<class 'pandas.core.frame.DataFrame'>
RangeIndex: 5820 entries, 0 to 5819
Data columns (total 33 columns):
 #   Column      Non-Null Count  Dtype
---  ------      --------------  -----
 0   instr       5820 non-null   int64
 1   class       5820 non-null   int64
 2   nb.repeat   5820 non-null   int64
 3   attendance  5820 non-null   int64
 4   difficulty  5820 non-null   int64
 5   Q1          5820 non-null   int64
 6   Q2          5820 non-null   int64
 7   Q3          5820 non-null   int64
 8   Q4          5820 non-null   int64
 9   Q5          5820 non-null   int64
 10  Q6          5820 non-null   int64
 11  Q7          5820 non-null   int64
 12  Q8          5820 non-null   int64
 13  Q9          5820 non-null   int64
 14  Q10         5820 non-null   int64
 15  Q11         5820 non-null   int64
 16  Q12         5820 non-null   int64
 17  Q13         5820 non-null   int64
 18  Q14         5820 non-null   int64
 19  Q15         5820 non-null   int64
 20  Q16         5820 non-null   int64
 21  Q17         5820 non-null   int64
 22  Q18         5820 non-null   int64
 23  Q19         5820 non-null   int64
 24  Q20         5820 non-null   int64
 25  Q21         5820 non-null   int64
 26  Q22         5820 non-null   int64
 27  Q23         5820 non-null   int64
 28  Q24         5820 non-null   int64
 29  Q25         5820 non-null   int64
 30  Q26         5820 non-null   int64
 31  Q27         5820 non-null   int64
 32  Q28         5820 non-null   int64
dtypes: int64(33)
memory usage: 1.5 MB

# ЭДА

sns.countplot(df['instr'])

sns.countplot(df['класс'])

sns.countplot(df[‘nb.repeat’])

sns.countplot(df['посещаемость'])

sns.countplot(df['сложность'])

#найти вопросы
x_questions = df.iloc[:, 5:33]
q_mean = x_questions.mean(axis=0)
total_mean = q_mean.mean()

q_mean = q_mean.to_frame(‘mean’)
q_mean.reset_index(level=0, inplace=True)
q_mean.head()

# для нахождения среднего

общее_среднее

#построить среднее

plt.figure(figsize=(14,8))
sns.barplot(x='index', y='mean', data=q_mean)

#coorelation
plt.figure(figsize=(20,20))
corr = df.corr()
sns.heatmap(corr, annot=True, cmap=’gist_earth_r’)

# анализ главных компонентов
# для уменьшения числа разбивок
x = df.iloc[:,5:33]

из sklearn.decomposition import PCA
pca = PCA(n_components=2, random_state=42)
x_pca=pca.fit_transform(x)
x_pca

#сколько информации мы сохранили из набора данных
pca.explained_variance_ratio_.cumsum()[1]

#обучение модели
#k означает кластеризацию
из sklearn.cluster import KMeans
искажения = []# работа в качестве вывода
#метод eblow
cluster_range = range(1, 6)
для i в cluster_range:
model = KMeans(n_clusters=i,init='k-means++',n_jobs=-1, random_state=42)
model.fit(x_pca)
искажения. добавление (модель. инерция_)

plt.plot(cluster_range, искажения, маркер='o')
plt.xlabel('количество кластеров')
plt.ylabel('искажения')

# использовать лучший кластер
model = KMeans(n_clusters=3,init='k-means++',n_jobs=-1, random_state=42)
model.fit(x_pca)
y = model .predict(x_pca)

plt.scatter(x_pca[y==0, 0], x_pca[y==0,1],s=50,c='красный',label='кластер 1')
plt.scatter(x_pca [y==1, 0], x_pca[y==1,1],s=50,c='синий',label='кластер 2')
plt.scatter(x_pca[y==2 , 0], x_pca[y==2,1],s=50,c='green',label='cluster 3')
plt.scatter(model.cluster_centers_[:,0], model. cluster_centers_[:, 1],s=100, c='yellow', label='centroids')
plt.title('группа студентов')
plt.xlabel('PCA 1')
plt.ylabel('PCA 2')
plt.legend()

из коллекций импортировать Counter
Counter(y)

Counter({2: 2360, 0: 2220, 1: 1240})

# обучение всего набора данных
model = KMeans(n_clusters=3,init='k-means++',n_jobs=-1, random_state=42)
model.fit(x)
y1= model .предсказать(х)

Счетчик(y1)

Counter({0: 2359, 1: 2221, 2: 1240})

вывод :

К концу этого проекта мы предсказывали значения и визуализировали данные в виде графиков.

давай потрогаем

Я запустил канал на YouTube
Плейлист Python (английский):- https://www.youtube.com/watch?v=9AiYyhKcBzI&list=PL-fvvgBPtI-XLPIbFMsO3i7uG9N9FShXW

GitHub: — https://www.github.com/Vamsi-2203

LinkedIn:- www.linkedin.com/in/vamsireddy2203

для получения дополнительных обновлений следуйте за мной ………