“bioinjiniring tizimlari” fanidan



Yüklə 41,74 Kb.
səhifə3/3
tarix07.01.2024
ölçüsü41,74 Kb.
#207166
1   2   3
amaliy ish 5

Amaliy qism
Ushbu amaliy qism doirasida biz biosignallarga mashinaviy o‘qitishning Rando Forest algoritmi orqali ishlov berish jarayonini ko‘rib chiqamiz.
# Kerakli kutubxonalarni import qilish
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import accuracy_score, classification_report

# Biosignal ma'lumotlar to‘plamini yuklang (buni ma'lumotlarni yuklash kodingiz bilan almashtiring)


# Faraz qiling, X biosignal xususiyatlarni o‘z ichiga oladi va y yorliqlarni o‘z ichiga oladi (normal uchun 0, anormal uchun 1)
# Buni haqiqiy ma'lumotlarni yuklash mexanizmingizga ko‘ra o‘zgartiring

# Namoyish maqsadida, keling, soxta ma'lumotlar to‘plamini yarataylik


np.random.seed(42)
X = np.random.rand(100, 10) # 100 samples, 10 features
y = np.random.randint(2, size=100) # Binary labels

# Ma'lumotlar to‘plamini mashq va sinov to‘plamlariga ajratish


X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Ma'lumotlarni standartlashtirish


scaler = StandardScaler()
X_train_scaled = scaler.fit_transform(X_train)
X_test_scaled = scaler.transform(X_test)

# Mashinaviy o‘qitish modeli (Random Forest Classifier algoritmi)


model = RandomForestClassifier(n_estimators=100, random_state=42)

# Modelni o‘qitish


model.fit(X_train_scaled, y_train)

# Sinov to‘plami orqali modelni testlash


y_pred = model.predict(X_test_scaled)

# Natijalarni e'lon qilish


accuracy = accuracy_score(y_test, y_pred)
print(f"Accuracy: {accuracy:.2f}")

# Ekranga chiqarish


print("Classification Report:\n", classification_report(y_test, y_pred))

Quyida modelimiz orqali olingan natijani ko‘rishingiz mumkin.


Accuracy: 0.45
Classification Report:
precision recall f1-score support


0 0.44 0.78 0.56 9
1 0.50 0.18 0.27 11


accuracy 0.45 20
macro avg 0.47 0.48 0.41 20
weighted avg 0.47 0.45 0.40 20

Xulosa
Xulosa qilib aytganda, bugungi kunda Sun’iy intellektning mashinaviy o‘qitish va chuqur o‘qitish kabi yo‘nalishlari orqali turli xildagi bioinjineriyada qo‘llanilishi mumkin bo‘lgan Sun’iy intellekt modellarini ishlab chiqishimiz mumkin bo‘ladi.
Yüklə 41,74 Kb.

Dostları ilə paylaş:
1   2   3




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin