> For the complete documentation index, see [llms.txt](https://uzbek.gitbook.io/ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://uzbek.gitbook.io/ai/kurslar/untitled.md).

# <02> CHIZIQLI MODEL

{% embed url="<https://youtu.be/VyC2j5zIsNI>" %}
Chiziqli model
{% endembed %}

{% hint style="info" %}
Chiziqli modelni qo'llanilishi haqida qo'shimcha ma'lumotlar.
{% endhint %}

## CHIZIQLI MODEL

Statistikada chiziqli model qo'llanilishiga qarab turlicha tasvrilanadi. Bulardan ko'p uchraydiganlari regressiyaga modellarga aloqdorlaridir, shu sababli chiziqli model va chiziqli regressiya sinonim sifatida qo'llaniladi. Ma'lumotlarning o'zgarishi chiziqli teksi tarzda ortib borishi yoki kamayib borishi bilan ham chiziqli modelni boshqalaridan ajratish qiyinchilik tug'dirmaydi.&#x20;

## O'RTACHA KVADRATIK XATOLIK (MEAN SQUARED ERROR-->MSE)

![](/files/-MPO2DSDQcedWPvgaRU_)

Demak, chiziqli modelning xatoligini hisoblashda biz MSE xatolik funksiyasidan foydalandik. Yuqoridagi ifodada barcha o'zgaruvchilar aniq berilgan.&#x20;

## <img src="/files/-MP8BpNTUwnLvpov9gYN" alt="" data-size="line"> AMALIYOT

## MODEL\&LOSS(Python)

```python
#Kutubxonalrni chaqirib olish
import matplotlib.pyplot as plt
import numpy as np

#Ma'lumotlarni kiritish
x_soat = np.array([1.0, 2.0, 3.0])
y_baho = np.array([2.0, 4.0, 6.0 ])

#To'g'ri hisoblash uchun funksiya
def forward(x):
    return x*w
#Xatolik (Loss) ning funksiyasi
def loss(x,y):
    y_pred = forward(x)
    return (y_pred-y)**2

#Grafikni yaratib olishimiz uchun kontaynerlar
w_list=[]
mse_list=[]

#w ni 0 dan 4 gacha oralig'ida hisblash 
for w in np.arange(0.0,4.1,0.1):
    print("w={:.3f}".format(w))
    L_umum=0
    
    for x_hb_qiym, y_hb_qiym in zip(x_soat, y_baho):
        y_hb_bash = forward(x_hb_qiym)
        L_hb_qiym = loss(x_hb_qiym, y_hb_qiym)
        L_umum += L_hb_qiym
        print("\t", "{:.2f}, {:.2f}, {:.2f}, {:.2f}".format(x_hb_qiym, y_hb_qiym, y_hb_bash, L_hb_qiym))
    
    # Har bir ma'lumot uchun MSE ni hisoblaymiz
    print("MSE=", L_umum / len(x_soat))  #len(x_soat)--> N
    w_list.append(w)
    mse_list.append(L_umum / len(x_soat))

#Grafik natija
plt.plot(w_list, mse_list)
plt.ylabel('Loss')
plt.xlabel('w')
ax= plt.axes()
ax.set_facecolor('#030101')
plt.show()

```

## <img src="/files/-MQRjyooFGFFtnq8FEhr" alt="" data-size="line"> VAZIFA

* BIROR QIZIQARALI CHIZIQLI MA'LUMOT TOPIB UNI MODELLASHTIRING HAMDA XATOLIGINI **MSE** YORDAMIDA ANIQLANG.
* **MSE** XATOLIK VA **w** QIYMATLARINI GRAFIK KO'RINISHIDA TASVIRLANG.&#x20;

MASALAN:

| <p>UY NARXI(\*1000$)</p><p>(X)</p> | <p>MAYDONI ( <span class="math">m^2</span> ) </p><p>(Y)</p> |
| :--------------------------------: | :---------------------------------------------------------: |
|                 24                 |                              50                             |
|                 28                 |                              61                             |
|                 32                 |                              66                             |
|                 35                 |                              71                             |
|                 40                 |                              82                             |
|                 46                 |                              90                             |

## <img src="/files/-MQRhqm0AV-Z33WBTWBa" alt="" data-size="line"> MATERIALLAR

{% file src="/files/-MPO6oIeIaGwdKbvsnZs" %}
Chiziqli model (slayd\&python)
{% endfile %}

## <img src="/files/-MQRinTxSExoYO2XYqiX" alt="" data-size="line"> MANBALAR

1. <https://en.wikipedia.org/wiki/Linear_model>
2. <https://en.wikipedia.org/wiki/Mean_squared_error>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://uzbek.gitbook.io/ai/kurslar/untitled.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
