|
T exnologiyalari va kommunikatsiyalarini rivojlantirish vazirligi
|
Sana | 19.05.2024 | Hajmi | 195,99 Kb. | | #244528 |
Bog'liq mashina2
O‘ZBEKISTON RESPUBLIKASI AXBOROT
T EXNOLOGIYALARI VA KOMMUNIKATSIYALARINI RIVOJLANTIRISH VAZIRLIGI
MUHAMMAD AL-XORAZMIY NOMIDAGI
TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI
2– TOPSHIRIQ ISH
Mazvu: Logistik regressiya yordamida siniflashtirish masalasini yechish.
Bajardi:212-21-guruh talabasi
Marupov Jahongir
Tekshirdi: Qobilov Sirojiddin
Topshirish muddati: 14.04.2024
Toshkent 2024
Mazvu: Logistik regressiya yordamida siniflashtirish masalasini yechish.
import numpy as np
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
Ustun_soni = 10
#boshlash = 0
#Tugatish = 10
Qator_soni = 50
jadval = {
'1-ustun': np.random.normal(2, 3, 20),
'2-ustun': np.random.normal(2, 3, 20),
'3-ustun': np.random.normal(1, 1, 20),
'4-ustun': np.random.normal(1, 2, 20),
'5-ustun': np.random.normal(1, 2, 20),
'6-ustun': np.random.normal(1, 2, 20),
'7-ustun': np.random.normal(1, 2, 20),
'8-ustun': np.random.normal(2, 1, 20),
'9-ustun': np.random.normal(1, 2, 20),
'10-ustun': np.random.normal(1, 2, 20),
}
jadval2 = {
'1-ustun': np.random.normal(2, 3, 20),
'2-ustun': np.random.normal(2, 3, 20),
}
# DataFrame yaratish va shu orqali ma'lumotlarni xosil qilish
df = pd.DataFrame(jadval)
df2 = pd.DataFrame(jadval2)
#df['sinf'] = np.random.randint(2, size=Qator_soni)
# print(df)
#print(jadval)
# Ma'lumotlar to'plamini tuzamiz
x = np.array([df])
# Har bir qator uchun uning qanday sinfga mansubligini 0 va 1 lar orqali ko'rsatamiz.
y = np.array([0, 0, 0, 1, 1, 0, 1, 0, 0, 1])
# Modelni yaratish
from sklearn.linear_model import LogisticRegression
model = LogisticRegression()
# Ma'lumotlarni modelga o'rgatamiz
model.fit(x, y)
# Yangi ma'lumotlarni siniflashtiramiz
yangi_data = np.array([df2])
# Natijalarni olish
bashorat_qiymati = model.predict(yangi_data)
# Natijalarni chiqaramiz
for i in range(len(yangi_data)):
print(f"X = {yangi_data[i]}, Yangi ma'lumot sinfi: {bashorat_qiymati[i]}")
|
| |