M uhammad al-Xorazmiy nomidagi Toshkent axborot texnologiyalari universiteti
Download 135.08 Kb.
|
mashina2
M uhammad al-Xorazmiy nomidagi Toshkent axborot texnologiyalari universiteti Mashinali o'qitishga kirish fanidan Amaliy ishi 2 Guruh : 713-21 Topshirdi: Xushvaqtov Shamsiddin Tekshirdi: Ochilov Mannon Musinovich 17 .Davlatlarni sinflashtirish O’zgatuvchi tanlamadagi misollar soni 40 Sinflar soni 3 Xususiyatlari soni 4 import numpy as np dataset=np.array([ [4,5,1,2,0], #iqtisodiy_progressiy,inflatsiya_darajasi,demografik_usishi,it_progressiy,Class [4,6,5,2,0], [6,8,3,0,1], [14,5,1,2,0], [4,6,5,2,0], [24,5,1,2,0], [4,6,5,2,1], [6,8,3,0,1], [6,8,3,0,1], [5.6,2.1,2.0,1,2], [4,6,5,2,0], [6,8,3,0,1], [14,5,1,2,2], [4,6,5,2,0], [24,5,1,2,2], [4,6,5,2,1], [6,8,3,0,2], [6,8,3,0,1], [5.6,2.1,2.0,1,1], [4,6,5,2,0], [6,8,3,0,1], [14,5,1,2,0], [4,6,5,2,0], [24,5,1,2,0], [4,6,5,2,2], [6,8,3,0,1], [6,8,3,0,1], [5.6,2.1,2.0,1,2], [4,6,5,2,0], [6,8,3,0,1], [14,5,1,2,0], [4,6,5,2,2], [24,5,1,2,0], [4,6,5,2,1], [6,8,3,0,1], [6,8,3,0,2] ]) x=dataset[:,0] #iqtisodiy_progressiy y=dataset[:,2] #inflatsiya_darajasi c=dataset[:,-1] #sinf from matplotlib import pyplot as plt plt.figure(figsize=(8,6)) plt.scatter(x[c==0],y[c==0],s=40, alpha=1,label='1-sinf',color='g',marker='s') plt.scatter(x[c==1],y[c==1], s=40, alpha=0.7,label='2-sinf',color='b',marker='^') # plt.scatter(x[c==2],y[c==2], s=40, alpha=0.8,label='3-sinf') plt.xlabel('xususiyat-1') plt.ylabel('xususiyat-2') plt.legend() plt.grid() plt.show() # Modelni qurish uchun datasetni train va test qismlarga ajratish X_train= dataset[:,:-1] #barcha xususiyatlar Y_train=dataset[:,-1] #sinf array([[ 4. , 5. , 1. , 2. ], [ 4. , 6. , 5. , 2. ], [ 6. , 8. , 3. , 0. ], [14. , 5. , 1. , 2. ], [ 4. , 6. , 5. , 2. ], [24. , 5. , 1. , 2. ], [ 4. , 6. , 5. , 2. ], [ 6. , 8. , 3. , 0. ], [ 6. , 8. , 3. , 0. ], [ 5.6, 2.1, 2. , 1. ]]) [ ] Y_train account_circle array([0., 0., 1., 0., 0., 0., 1., 1., 1., 1.]) from sklearn.model_selection import train_test_split from sklearn.model_selection import train_test_split x_train, x_test, y_train, y_test = train_test_split(X_train, Y_train, test_size=0.15, random_state=42) x_train.shape x_test.shape from sklearn.linear_model import LogisticRegression logisticRegr = LogisticRegression() logisticRegr.fit(x_train, y_train) train_pred = logisticRegr.predict(x_train) #train to'plam uchun score = logisticRegr.score(x_train, y_train) print(score) test_pred = logisticRegr.predict(x_test) #test to'plam uchun score = logisticRegr.score(x_test, y_test) print(score) from sklearn.metrics import confusion_matrix #train to'plam uchun cm = confusion_matrix(y_train, train_pred) print(cm) #test to'plam uchun cm = confusion_matrix(y_test, test_pred) print(cm) #datasetda yo'q misol bilan testlash logisticRegr.predict([[4.7,6,3,0]])[0] Xulosa Logistik regressiya bu o'zgaruvchilardan o'zaro bog'liqlikni aniqlash usulidir, ulardan biri qat'iyan bog'liq, boshqalari esa mustaqil. Buning uchun logistik funksiyada) foydalaniladi. Logistik regressiyaning amaliy qiymati shundaki, u bir yoki bir nechta mustaqil o'zgaruvchini o'z ichiga olgan voqealarni bashorat qilishning kuchli statistik usuli hisoblanadi. Download 135.08 Kb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling