Zbekiston respublikasi raqamli texnologiyalar vazirligi muhammad al-xorazmiy nomidagi toshkent axborot texnologiyalari universiteti



Yüklə 17,52 Kb.
tarix26.10.2023
ölçüsü17,52 Kb.
#131505
Diyor Sultonov


O’ZBEKISTON RESPUBLIKASI RAQAMLI TEXNOLOGIYALAR VAZIRLIGI

MUHAMMAD AL-XORAZMIY NOMIDAGI TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI

AMALIY ISH
MASHINALI O’QITISHGA KIRISH
KIBERXAVFSIZLIK FAKULTETI

715-21 guruh talabasi


Bajardi: Sultonov Diyor
Tekshirdi: Ochilov Mannon

15-variant



15

Kumush narxini bashorat qilish

20

numpy

2,6

1,5,7

Kumush narxini bashorat qilish uchun kumushni O’zbekistondagi dizel narxiga bog’lab olamiz chunki uni qazib olishda juda ko’plab texnikalardan foydalaniladi . Buning uchun 20 ta elementdan iborat dataset shakllantirib olamiz.


import numpy as np
import matplotlib.pyplot as plt

dataset = np.array([


[12 , 200 ], #1 l dizel narxi, 10 gr kumush narxi
[11.6, 194],
[11.9, 197],
[11.8, 195],
[12.1, 204],
[12.3 , 210],
[12.6, 217],
[12.4, 213],
[12.5 , 216],
[12.9 , 225],
[13 , 227],
[13.2 230 ],
[12.9 , 225],
[12.4, 213],
[12.5 , 216 ],
[13 , 227],
[13.3 233 ],
[13.4 , 236 ],
[13.6 , 239],
[13,5 , 238]
])

#Datasetdagi 2 ta xususiyatni o’zaro bog’laymiz(1 l dizel narxi va kumush narxini)


x= dataset[:,0]
y = dataset[:,-1]

print(x)
Grafik tasvirlash uchun plt dan foydalanamiz.


plt.figure(figsize=(2,6))
plt.scatter(x,y,marker="s", color="r")
plt.xlabel("dizel narxi")
plt.ylabel("kumush narxi")
plt.title("Datasetdagi kumush narxining dizel narxiga bog'liqligi")
plt.grid()
plt.show()

Polinomial darajasi 2 bo’lgan hol uchun:


p = np.polyfit(x,y,2 )
reg_model = np.poly1d(p)
yNew = reg_model(x)

plt.figure(figsize=(2,6))
plt.subplot(1,2,1)
plt.scatter(x,y,marker="s", color="r", label = "original data")
plt.xlabel("dizel narxi")
plt.ylabel("kumush narxi")
plt.title("Dataset")
plt.grid()
plt.subplot(1,2,2)
plt.plot(x,yNew, color = "b", label = "reg model")
plt.xlabel("dizel narxi")
plt.ylabel("kumush narxi")
plt.title("Regression model")
plt.grid()
plt.legend()
plt.show()
Dataset grafigi va regression model grafigini alohida yonma-yon chiqaramiz.

Polinomial darajasi 6 bo’lgan hol uchun:


p = np.polyfit(x,y,6)
reg_model = np.poly1d(p)
yNew = reg_model(x)

SKLEARN
Sklearn kutubxonasi bizga bir necha xil polinomial darajalarni bitta funksiyada chiqarishga yordam beradi


from sklearn.preprocessing import PolynomialFeatures

import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression
import numpy

x = dataset[:,0]
y = dataset[:,2]

X=x.reshape(-1,1)
#degree=1 , polinomial darajasi 1 bo’lgan hol uchun
poly_reg = PolynomialFeatures(degree=1)

X_poly = poly_reg.fit_transform(X)

pol_reg = LinearRegression()

pol_reg.fit(X_poly, y)

plt.figure(figsize=(8,3))
plt.scatter(X, y, color='red')
plt.xlabel("dizel narxi")
plt.ylabel("kumushnarxi")
plt.title("Regression model")
plt.plot(X, pol_reg.predict(poly_reg.fit_transform(X)), color='blue')
plt.grid()
plt.show()


from sklearn.preprocessing import PolynomialFeatures

import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression
import numpy

x = dataset[:,0]
y = dataset[:,2]

X=x.reshape(-1,1)
#degree=5 , polinomial darajasi 5 bo’lgan hol uchun
poly_reg = PolynomialFeatures(degree=5)

X_poly = poly_reg.fit_transform(X)

pol_reg = LinearRegression()

pol_reg.fit(X_poly, y)

plt.figure(figsize=(8,3))
plt.scatter(X, y, color='red')
plt.xlabel("dizel narxi")
plt.ylabel("kumush narxi")
plt.title("Regression model")
plt.plot(X, pol_reg.predict(poly_reg.fit_transform(X)), color='blue')
plt.grid()
plt.show()


from sklearn.preprocessing import PolynomialFeatures
import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression
import numpy

x = dataset[:,0]
y = dataset[:,2]

X=x.reshape(-1,1)
#degree=7 , polinomial darajasi 7 bo’lgan hol uchun
poly_reg = PolynomialFeatures(degree=5)

X_poly = poly_reg.fit_transform(X)

pol_reg = LinearRegression()

pol_reg.fit(X_poly, y)

plt.figure(figsize=(8,3))
plt.scatter(X, y, color='red')
plt.xlabel("dizel narxi")
plt.ylabel("kumush narxi")
plt.title("Regression model")
plt.plot(X, pol_reg.predict(poly_reg.fit_transform(X)), color='blue')
plt.grid()
plt.show()
Yüklə 17,52 Kb.

Dostları ilə paylaş:




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

    Ana səhifə