13-variant Guruh: iml002-3 Bajardi: Raxmatullayev Xusniddin Tekshirdi: Ochilov Mannon


Download 12.6 Kb.
Sana05.11.2023
Hajmi12.6 Kb.
#1749055
Bog'liq
raxmatullayev (6)


O`ZBEKISTON RESPUBLIKASI RAQAMLI TEXNOLOGIYALAR VAZIRLIGI
M
UHAMMAD AL-XORAZMIY NOMIDAGI

TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI


Mashinali o'qitishga kirish fanidan
Amaliy ishi 2

13-variant


Guruh: IML002-3


Bajardi:Raxmatullayev Xusniddin


Tekshirdi: Ochilov Mannon
Toshkent-2023

  1. Telefon modellarini siflashtirish. O’zgatuvchi tanlamadagi misollar soni 40 Sinflar soni 3 Xususiyatlari soni 3

import numpy as np


np.random.seed(0) # Set a seed for reproducibility
num_examples = 40
num_classes = 3
num_features = 3
X = np.random.rand(num_examples, num_features) # Your feature data
y = np.random.randint(0, num_classes, size=num_examples) # Your target labels
import matplotlib.pyplot as plt
feature1 = 0
feature2 = 1
plt.scatter(X[y == 0, feature1], X[y == 0, feature2], label='Class 0', marker='o')
plt.scatter(X[y == 1, feature1], X[y == 1, feature2], label='Class 1', marker='x')
plt.scatter(X[y == 2, feature1], X[y == 2, feature2], label='Class 2', marker='s')
plt.xlabel(f'Feature {feature1}')
plt.ylabel(f'Feature {feature2}')
plt.legend()
plt.show()

from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.15, random_state=42)
from sklearn.linear_model import LogisticRegression
model = LogisticRegression()
model.fit(X_train, y_train)
train_accuracy = model.score(X_train, y_train)
test_accuracy = model.score(X_test, y_test)
from sklearn.metrics import confusion_matrix
import seaborn as sns
y_pred = model.predict(X_test)
cm = confusion_matrix(y_test, y_pred)
plt.figure(figsize=(8, 6))
sns.heatmap(cm, annot=True, fmt='d', cmap='Blues')
plt.xlabel('Predicted')
plt.ylabel('True')
plt.show()

Download 12.6 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling