Muhammad Al-Xorazmiy nomidagi TATU Nurafshon filiali 710-21 guruh talabasi Yesbolov Bekgazining Mashinali o’qitish fanidan bajargan Amaliy ishi. Bajardi : Yesbolov B. Tekshirdi : Qobilov S. Bu vazifaning barcha qismlarini bitta Python skriptida bajarish mumkin. Mana shu misol skript: ```python import matplotlib.pyplot as plt import numpy as np from sklearn.model_selection import train_test_split from sklearn.datasets import make_classification from keras.models import Sequential from keras.layers import Dense from keras.optimizers import Adam # 1. Dataset yaratish X, y = make_classification(n_samples=1000, n_features=2, n_informative=2, n_redundant=0, n_clusters_per_class=1, random_state=42) X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42) # Grafik tasvirlash plt.scatter(X_train[:, 0], X_train[:, 1], c=y_train, cmap=plt.cm.RdYlBu) plt.title('Dataset') plt.xlabel('X1') plt.ylabel('X2') plt.show() # 2. Neyron tarmoq arxitekturasi model = Sequential() model.add(Dense(10, input_dim=2, activation='relu')) model.add(Dense(1, activation='sigmoid')) # 3. Neyron tarmoqni o'qitish parametrlari model.compile(loss='binary_crossentropy', optimizer=Adam(learning_rate=0.01), metrics=['accuracy']) # O'qitish history = model.fit(X_train, y_train, epochs=50, batch_size=32, validation_data=(X_test, y_test)) # 4. Natijalarni visual va jadval qiymatlarini keltirish # Accuracies plt.plot(history.history['accuracy'], label='Training Accuracy') plt.plot(history.history['val_accuracy'], label='Validation Accuracy') plt.title('Training and Validation Accuracies') plt.xlabel('Epoch') plt.ylabel('Accuracy') plt.legend() plt.show() # Losses plt.plot(history.history['loss'], label='Training Loss') plt.plot(history.history['val_loss'], label='Validation Loss') plt.title('Training and Validation Losses') plt.xlabel('Epoch') plt.ylabel('Loss') plt.legend() plt.show() # Jadval qiymatlari test_loss, test_acc = model.evaluate(X_test, y_test) print(f'Test Loss: {test_loss:.4f}') print(f'Test Accuracy: {test_acc:.4f}') ``` Bu skriptda: 1. `make_classification` funktsiyasi yordamida sodda dataset yaratildi. 2. Matplotlib kutubxonasidan foydalangan holda dataset tasvirlandi. 3. Keras kutubxonasi yordamida neyron tarmoq arxitekturasi qurildi. 4. O'qitish parametrlari tanlandi va neyron tarmoq o'qitildi. 5. O'qitish natijalari matplotlib orqali tasvirlandi va jadval qiymatlari chiqarildi.