Muhammad Al-Xorazmiy nomidagi Toshkent Axborot Texnologiyalari Universiteti Mashinali o’qitish fanidan Mustaqil ish Guruh: 212-20 Topshirdi: Jamolova Baxtiniso Tekshirdi: Nurmurodov Javohir


Download 256.26 Kb.
Sana14.05.2023
Hajmi256.26 Kb.
#1460555

O’ZBEKISTON RESPUBLIKASI AXBOROT
TEXNOLOGIYALARI VA KOMMUNIKATSIYALARINI
RIVOJLANTIRISH VAZIRLIGI

Muhammad Al-Xorazmiy nomidagi
Toshkent Axborot Texnologiyalari Universiteti
Mashinali o’qitish fanidan
Mustaqil ish
Guruh: 212-20
Topshirdi: Jamolova Baxtiniso
Tekshirdi: Nurmurodov Javohir
1. Chiziqli regressiya yordamida baholash jarayonini bashoratlash y = wx


from sklearn.linear_model import LinearRegression
import matplotlib.pyplot as plt
import numpy as np
x = np.array([5, 15, 25, 35, 45, 55]).reshape((-1, 1))
y = np.array([5, 20, 14, 32, 22, 38])
print(x)
print(y)
model = LinearRegression()
model.fit(x, y)
r_sq = model.score(x, y)
print('Determinatsiya koefitsienti:', r_sq)
print('Kesishma:', model.intercept_)
print('Chizilgan oqim:', model.coef_)
y_pred = model.predict(x)
print('Taxmin qilingan javob:', y_pred, sep='\n')
y_pred = model.intercept_ + model.coef_ * x
print('Taxmin qilingan javob:', y_pred, sep='\n')
x_new = np.arange(5).reshape((-1, 1))
print(x_new)
y_new = model.predict(x_new)
print(y_new)

plt.scatter(x, y, color='red')
plt.plot(x, y_pred, color='blue')
plt.title('Chiziqli regressiya')
plt.xlabel('x')
plt.ylabel('y')
plt.show()



2. Sigmoid aktivlash funksiyasi yordamida sinflash.
import numpy as np
import matplotlib.pyplot as plt
def sig(x):
return 1 / (1 + np.exp(-x))
x = np.linspace(-10, 10, 50)
p = sig(x)
plt.xlabel("x")
plt.ylabel("Sigmoid(x)")
plt.plot(x, p)
plt.show()

3.Matritsani matritsaga ko’paytirish dasturi.


def matrix_multiplication(A, B):
# Determine the matrices' dimensions.
rows_A = len(A)
cols_A = len(A[0])
rows_B = len(B)
cols_B = len(B[0])
# Natija matritsasini nolga o'rnating.
result = [[0 for row in range(cols_B)] for col in
range(rows_A)]
# Iterate through rows of A
for s in range(rows_A):
# Iterate through columns of B
for j in range(cols_B):
# Iterate through rows of B
for k in range(cols_A):
result[s][j] += A[s][k] * B[k][j]
return result;

# Sample matrices
A = [[1, 4, 3], [4, 9, 6]]
B = [[7, 8], [9, 10], [11, 12]]
# Perform matrix multiplication
result = matrix_multiplication(A, B)
# Print the result
print(result)
# Output: [[76, 84], [175, 194]]

4.SoftMax aktivlash funksiyasi yordamida sinflashtirish


import numpy as np
import matplotlib.pyplot as plt
A = np.array([[1, 2], [3, 4]])
B = np.array([[5, 6], [7, 8]])
C = np.matmul(A, B)
fig, (ax1, ax2, ax3) = plt.subplots(1, 3)
ax1.matshow(A, cmap=plt.cm.Blues)
for i in range(A.shape[0]):
for j in range(A.shape[1]):
c = A[j, i]
ax1.text(i, j, str(c), va='center', ha='center')
ax1.set_title('Matrix A')
ax2.matshow(B, cmap=plt.cm.Blues)
for i in range(B.shape[0]):
for j in range(B.shape[1]):
c = B[j, i]
ax2.text(i, j, str(c), va='center', ha='center')
ax2.set_title('Matrix B')
ax3.matshow(C, cmap=plt.cm.Blues)
for i in range(C.shape[0]):
for j in range(C.shape[1]):
c = C[j, i]
ax3.text(i, j, str(c), va='center', ha='center')
ax3.set_title('Matrix C')
plt.show()



Download 256.26 Kb.

Do'stlaringiz bilan baham:




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