O‘ZBEKISTON RESPUBLIKASI AXBOROT TEXNOLOGIYALARI VA
KOMMUNIKATSIYALARINI RIVOJLANTIRISH VAZIRLIGI
MUHAMMAD AL-XORAZMIY NOMIDAGI
TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI
Fan: Mashinali o’qitishga kirish
AMALIY TOPSHIRIQ - 1
Guruh: KIF 213-18
Bajardi: Normurodov Muhammadjon
Toshkent–2021
TOPSHIRIQ - 1
Berilgan variantlardan birini talaba jurnaldagi tartib raqamiga mos ravishta tanlab quydagi topshiriqlarni bajaradi (a,b,c) !!!
a) Bir chiziqli regressiya uchun X1 va Y qiymatlarini oling, ko’phad (polinum) qiymatni P=P1 deb qarang va model parametrlarini aniqlang
b) Ko’p chiziqli regressiya uchun (X1, X2), Y qiymatlarni oling, P=P2 deb qarang va model parametrlarini aniqlang
d) Visual ko’rinishda kiruvchi ma’lumotlarni tasvirlang va siz hosil qilgan model grafigini chiziq ko’rinishida taqdim eting
6-Variant:
P1=3; P2=2
X1
|
6
|
6
|
7
|
6
|
8
|
8
|
9
|
10
|
10
|
12
|
X2
|
1
|
2
|
4
|
5
|
6
|
8
|
9
|
11
|
12
|
14
|
Y
|
0
|
1
|
1
|
2
|
3
|
4
|
6
|
6
|
8
|
9
|
from matplotlib import pyplot as plt
import numpy as np
X1 = [6, 6, 7, 6, 8, 8, 9, 10, 10, 12]
Y = [0, 1, 1, 2, 3, 4, 6, 6, 8, 9]
P1=3
x = np.array(X1)
y = np.array(Y)
p=np.polyfit(x,y,P1)
model=np.poly1d(p)
new_value=model(x)
plt.scatter(x, y,color='r',marker='.')
plt.plot(x, new_value,color='green')
plt.tight_layout()
plt.show()
..
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import statsmodels.formula.api as smf
X1 = [6, 6, 7, 6, 8, 8, 9, 10, 10, 12]
X2 = [1, 2, 4, 5, 6, 8, 9, 11, 12, 14]
Y = [0, 1, 1, 2, 3, 4, 6, 6, 8, 9]
df2=pd.DataFrame()
df2['x']=pd.Series(X1)
df2['y']=pd.Series(X2)
df2['z']=pd.Series(Y)
model = smf.ols(formula='z ~ x + y', data=df2)
results_formula = model.fit()
results_formula.params
x_surf, y_surf = np.meshgrid(np.linspace(df2.x.min(), df2.x.max(), 100),np.linspace(df2.y.min(), df2.y.max(), 100))
onlyX = pd.DataFrame({'x': x_surf.ravel(), 'y': y_surf.ravel()})
fittedY=results_formula.predict(exog=onlyX)
fittedY=np.array(fittedY)
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.scatter(df2['x'],df2['y'],df2['z'],c='red', marker='o', alpha=0.5)
ax.plot_surface(x_surf,y_surf,fittedY.reshape(x_surf.shape), color='b', alpha=0.3)
ax.set_xlabel('X1')
ax.set_ylabel('X2')
ax.set_zlabel('Y')
plt.show()
Dostları ilə paylaş: |