# Data analytic exercise

### Matrix profile

การทำ Matrix profile นั้นเป็นการนำข้อมูลไปหาความคล้ายกันของข้อมูลเพื่อนำมาระบุว่าข้อมูลนั้นมีความคล้ายกัน ณ จุดใด หรือใช้ในทางกลับกันว่ามีจุดใดบ้างที่ไม่คล้ายกับจุดอื่นๆเลย **ข้อดี** เราสามารถหาความซ้ำกันของข้อมูลที่มีขนาดใหญ่ได้ **ข้อเสีย** ถ้าข้อมูลมาในลักษณะที่ไม่มี pattern หรือมีชุดข้อมูลขนาดเล็กมากๆ จะทำให้ Matrix profile นั้นไม่สามารถแสดงประสิทธิภาพได้อย่างเต็มที่&#x20;

หลักการของ Matrix profile คือการนำข้อมูลมา convolution เพื่อหา euclidian distance แล้วนำค่าที่น้อยที่สุดที่ได้จากการทำ convolution ครั้งนั้นไปใส่ไว้ใน profile distance&#x20;

![ภาพการทำ matrix profile](/files/HNAKswFwbEyb82FPFdzY)

เมื่อเรานำค่า Matrix profile distance ไปทำการ visualize เราจะได้กราฟหน้าตาลักษณะดังนี้

![ภาพ Matrix profile distance ในลักษณะกราฟเส้น](/files/pD1OeckUegMwUFcVdywF)

กราฟนี้บอกอะไรกับเราบ้าง การอ่านกราฟนี้ ข้อมูลในแกนตั้งคือค่าความเหมือนกันของ data point ยิ่งค่าเข้าใกล้ศูนย์มากเท่าไหร่จุดๆนั้นก็จะมีความเหมือนกันมากเท่านั้น ส่วนข้อมูลในแกนนอนนั้นคือจุด data point ที่มีความเหมือนกัน ในรูปตัวอย่างด้านบนจะเห็นได้ว่ามีความเหมือนกันตรงที่มีเส้นประ เมื่อเรานำ data point ที่ได้ไปดูกับค่าข้อมูลจะเห็นได้ว่า ณ จุดๆนั้นมีความคล้ายคลึงกัน

![จุดที่นำ data point มาเทียบใน data จริง](/files/z9YrAl17oojEPcefUp78)

## &#x20;Exercise&#x20;

แบบฝึกหัดเบื้องต้นนี้จะใช้ google colab และไลบรารี่ stumpy ในการทำ data analytic&#x20;

การทำ analytic นี้จะเป็นตัวอย่างการนำเข้าข้อมูลแบบ time series ไปทำ matrix profile เพื่อหาจุดที่เกิดการซ้ำกันของข้อมูล

เอกสารด้านล่างจะพาไปยัง Google colab&#x20;

{% embed url="<https://colab.research.google.com/drive/181of76vq65OsSjDpYifSr1xJ8WIw5hlc?usp=sharing>" %}
เอกสาร exercise
{% endembed %}

เมื่อเข้าไปแล้วสามารถกด File > copy in drive เพื่อนำไปแก้ไขหรือต่อยอดได้

##

แหล่งอ้างอิง

{% embed url="<https://towardsdatascience.com/introduction-to-matrix-profiles-5568f3375d90>" %}


---

# Agent Instructions: 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://docs.aic-eec.com/artificial-intelligence-ai/data-analytics/data-analytic-exercise.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.
