11B-43 NGUYỄN DUY TIẾN
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    --- tags: COTAI LHP --- # Lecture Notes ML4AI 2021 ## Session 1 -- Linear Predictors ## Session 2 -- Feature Extraction ###### tags: `Tag(1)` > This note is yours, feel free to play around. :video_game: > Type on the left :arrow_left: and see the rendered result on the right. :arrow_right: ## :memo: Where do I start? ### Step 1: Change the title and add a tag - [x] Create my first HackMD note (this one!) - [x] Change its title - [x] Add a tag :rocket: ### Step 2: Write something in Markdown Let's try it out! Apply different styling to this paragraph: **HackMD gets everyone on the same page with Markdown.** ==Real-time collaborate on any documentation in markdown.== Capture fleeting ideas and formalize tribal knowledge. - [x] **Bold** - [ ] *Italic* - [ ] Super^script^ - [ ] Sub~script~ - [ ] ~~Crossed~~ - [x] ==Highlight== :::info :bulb: **Hint:** You can also apply styling from the toolbar at the top :arrow_upper_left: of the editing area. ![](https://i.imgur.com/Cnle9f9.png) ::: > Drag-n-drop image from your file system to the editor to paste it! ### Step 3: Invite your team to collaborate! Click on the <i class="fa fa-share-alt"></i> **Sharing** menu :arrow_upper_right: and invite your team to collaborate on this note! ![permalink setting demo](https://i.imgur.com/PjUhQBB.gif) - [ ] Register and sign-in to HackMD (to use advanced features :tada: ) - [ ] Set Permalink for this note - [ ] Copy and share the link with your team :::info :pushpin: Want to learn more? ➜ [HackMD Tutorials](https://hackmd.io/c/tutorials) ::: --- ## BONUS: More cool ways to HackMD! - Table | Features | Tutorials | | ----------------- |:----------------------- | | GitHub Sync | [:link:][GitHub-Sync] | | Browser Extension | [:link:][HackMD-it] | | Book Mode | [:link:][Book-mode] | | Slide Mode | [:link:][Slide-mode] | | Share & Publish | [:link:][Share-Publish] | [GitHub-Sync]: https://hackmd.io/c/tutorials/%2Fs%2Flink-with-github [HackMD-it]: https://hackmd.io/c/tutorials/%2Fs%2Fhackmd-it [Book-mode]: https://hackmd.io/c/tutorials/%2Fs%2Fhow-to-create-book [Slide-mode]: https://hackmd.io/c/tutorials/%2Fs%2Fhow-to-create-slide-deck [Share-Publish]: https://hackmd.io/c/tutorials/%2Fs%2Fhow-to-publish-note - LaTeX for formulas $$ x = {-b \pm \sqrt{b^2-4ac} \over 2a} $$ - Code block with color and line numbers: ```javascript=16 var s = "JavaScript syntax highlighting"; alert(s); ``` - UML diagrams ```sequence Alice->Bob: Hello Bob, how are you? Note right of Bob: Bob thinks Bob-->Alice: I am good thanks! Note left of Alice: Alice responds Alice->Bob: Where have you been? ``` - Auto-generated Table of Content [ToC] > Leave in-line comments! [color=#3b75c6] - Embed YouTube Videos {%youtube PJuNmlE74BQ %} > Put your cursor right behind an empty bracket {} :arrow_left: and see all your choices. - And MORE ➜ [HackMD Tutorials](https://hackmd.io/c/tutorials) SESSION 2: Feature Extraction (chiết xuất đặc trưng) Các cách chiết xuất đặc trưng: Cách 1: Convolutional Kernel (tích chập): *Cách hoạt động: Ta trượt kernel lên bức ảnh và tính tích với các thông số trên bức ảnh để ta thấy được những điểm nổi bật Cách 2: PCA *PCA, là một phương pháp giảm kích thước thường được sử dụng để giảm kích thước của các tập dữ liệu lớn, bằng cách chuyển đổi một tập hợp lớn các biến thành một tập nhỏ hơn mà vẫn chứa hầu hết thông tin trong tập lớn. Cách 3: Sparse coding (mã hóa thưa thớt): *ta chỉ cần lấy những thành phần nhỏ trong bức ảnh gốc, thưa thớt. Cách 4: Word Embeddings: *là việc ta đi xử lý 1 từ để từ đó phân loại nó, tìm mối liên hệ giữa các từ **SESSION 3:** ***Regression curves**: vì dữ liệu ko phải lúc nào cũng là 1 đường thẳng nên ta cần phải có đường cong để dự đoán chính xác ![](https://i.imgur.com/uwFlrHn.png) ![](https://i.imgur.com/dN5iHuK.png) **Linearly separable**: a data set can be explained by linear classifier (dữ liệu có thể phân vùng dc) **Nonlinearly separable** (dữ liệu lộn xộn ko phân vùng dc) **Manifold Hypothesis**: là có những noise(dữ liệu ở lớp khác trà trộn vào dữ liệu của 1 lớp) ![](https://i.imgur.com/0Z2M8pr.png) **Multimodal embeddings**: là ta encode các chữ và encode hình ảnh từ đó tìm ra mối quan hệ giữa chúng ![](https://i.imgur.com/Jcn8qte.png) ![](https://i.imgur.com/3lfg9f8.png) **Entangled embedding manifolds**:dữ liệu các lớp bị trà trộn vào nhau ![](https://i.imgur.com/MGuV3iF.png) **Transformations to disentangle**: là từ 1 bức ảnh (input layer) qua các activated neurons cho ra output layer để phân loại. ![](https://i.imgur.com/cU6WV3p.png) **Transformations: stretch out Z space**: phương pháp chuyển không gian từ ambient space thành coordinate space để phân cắt, chia vùng dễ hơn vdu: hình 1 muốn chia 2 vùng phải bằng đường cong còn sau khi chuyển thì phân vùng bằng đường thẳng * Ta sử dụng các cách Xoay, kéo dài, uốn cong, cuộn tròn (làm được bằng những thuật toán s(A∗z+b) layers) để gỡ rối các entangled embedding manifolds. * hình 1 ![](https://i.imgur.com/w0Nsxdw.png) *hình 2 ![](https://i.imgur.com/JFpNo9X.png) **Linear Transformations:** *flat obj -> flat obj nhưng đã rotated, flipped *Các ảnh hưởng tính bằng tính có hướng của 2 vecto (Matrix multiplication) ![](https://i.imgur.com/LuvutsG.png) Quy trình để chuyển đổi: ***Linear transformations = rotate/flip + scale + rotate/flip*** **Non-Linear Transformations:** *flat obj -> curved, bent obj by using nonlinear activation γ(Az) *Các ảnh hưởng tính qua những lớp *activation functions γ. ![](https://i.imgur.com/JOdsaaz.png) ***Chuyển từ non-linear model thành linear model qua hàm ϕ** ![](https://i.imgur.com/i0xEGso.png) *các hàm ϕ: Feature engineering: MLP Kernel machines Locally linear Bài 3 học về MLP :+1: decision boundary: vùng ta ko xac dinh dc 1 diem thuoc lop nao => w1Z + b1 = w2Z + b2 => w12Z + b12 = 0 Non-seperable: những diem loi Z dua thanh khong gian Z' de trong Z' dung linear model từ các lớp ta trải ra mat phang de dung linear model de phan biet Transformation 2 loai non va linear Transformation dùng để chuyển đổi kgian để cắt bằng linear de phan biet 2 vung du lieu linear dua vao phang -> ra phang input phang -> ouput méo -> nonlinear linearZ -> Z' qua ma tran A -> Z'=Z*A (nhan ma tran tich co huong) # Z.A la tich vo huong Non-linear giong linear nhung bop meo dau ra qua hàm gamma b/chat cac phep bien doi tuyen tinh: xoay roi lat, gian, xoay. linear transform khi ap dung t/chat tren thi ko bi bien doi Nonlinear transform Nonlinear Transformations ϕ(z)=γ(Wz+b) vd [0,2,1.5] Feature Engineering: hàm ta tu thiet ke (còn deep learning là máy tính tự tìm) MLP(multi-player): Z -> Z' -> Zn' (cho Z nhieu lan qua ham ) γ: bóp méo (Wz+b): xoay, co giãn kernel trick: tinh qua ham kernel decision tree Mục đích: chuyển vùng kgian để phân tách các class đễ hơn qua hàm linear model **Notes from Hung Ngo**: see [sample LaTeX equations here](https://hackmd.io/LbmoGpsTSJGYd6JsVybXDw?view) **SESSION4** Topic: Recommender Systems Thuật ngữ bán hàng: Cross-sell and Upsell *Cross-sell: bán dc nhiều product cùng lúc *Upsell: bán 1 product nhiều lần Core Engine: hệ thống recommend cho consumers Đa số các ứng dụng đều sử dụng Core Engine Core Engine còn dc ứng dụng trong các đoạn chat do robot (Virtual Assistant) How an AI becomes a good Core Engine? 1:Generalization(chung): là theo dõi, tiếp thu các hành vi của all consumers để học và recommend. 2:Personalization(cá nhân hóa): học, ghi nhớ và recommend cho từng consumer. Longtail issues: !(https://i.imgur.com/mhsrXeQ.png) Phần Head là những product được Core Engine recommend cho số lượng lớn người dùng Phần Long Tail là phần chỉ recommend cho 1 nhóm thiểu số người dùng sẽ bán dc ít hơn nhưng khách hàng hài lòng hơn. Problem Formulation: bài toán để sử dụng Core Engine là dựa vào input là các items và users và các rating của users với items output là ta đi dự đoán và recommend các items mới cho users để buy nếu users buy nó thì nó là good recommendation và tăng buying experience còn nếu ko thì dự báo chưa tốt. Criteria để đưa recommend: 1: User-based filtering: dựa vào thói quen sử dụng chung của khách hàng để recommend sản phẩm mới cho khách hàng khác vdu: Anh A mua ăn thịt gà, trứng, thịt heo, Anh B mua thịt heo, trứng thì ta có thể recommend thịt gà cho anh B 2: Item-based filtering: dựa vào số lượng người mua items để recommend cho người khác chưa mua Lưu ý: nhưng tất tả phải có giao điểm chung. Tools để giải bài toán Problem Formulation: Cách tính giao điểm chung, độ giống nhau của các users: Dot Product (tích vô hướng), Cosine Similarity (hàm cos tính góc giữa 2 vecto), Euclidian Distances Phương pháp Item-based CF: **SESSION 5:** Metrics: thước đo performance Losses: Hàm mất mát (hàm tối ưu metrics) Các loại bài toán khoanh vùng: 1 Semantic Segmentation : No object, just pixel 2 Classification and localization: single object 3 Object detection : like 2 but multiple object 4 Instance Segmentation : like 1 but multiple object Cách xây dựng 1 mô hình: $\text{Input } X \xrightarrow[B]{Features}\text{ Embedding Coordinates }Z \xrightarrow[L_\theta]{LinearPredictor}\text{ Prediction }\hat{Y} = W\cdot Z+b$ * Ta có đầu vào là X qua hàm basic thì ta có tọa độ nhúng Z từ Z đưa qua các hàm như linear để dự báo Hàm dự báo gọi là f Give computer a set of N examples $\mathcal{D}=\{ (x^t,y^t) \}_{t=1}^N$ là input X Có $\hat{y}^t$ là kqua dự báo của hàm f($x^t$)=$\hat{y}^t$ Cách để ta biết hàm f tốt hay xấu: ta dựa vào performance measure (evaluation metric, loss) P P sẽ cho ra kqua là 1 số thực biểu hiện mức tốt xấu $\mathcal{P}(\mathcal{D},f)$ = real number Performance Measure of Regression: MSE: $\mathcal{P}(\mathcal{D},f) = \frac{1}{N}\sum_{t=1}^N (\hat{y}^t - y^t)^2$ Ta đi tìm hàm f là hàm có sai số thấp nhất bằng những giải thuật như gradient descent (đi ngược đạo hàm), qua i lần vòng lặp tìm kiếm thì ta sẽ có 1 bộ tham số tối ưu Việc làm trên gọi là "fitting a model fθ to the dataset D". là xem mô hình f có khớp với dữ liệu D ko thì ta sẽ gặp những TH quá khớp hoặc chưa khớp (generalization ability) * Performance measure ≡ evaluation metrics → Loss / cost / objective / error functions for better generalization capability. ![](https://i.imgur.com/gwYlv5L.png) ![](https://i.imgur.com/CdssFgL.png) **hình trên là cách thức hoạt động của việc training và test** * validation set là trong phần training set để chọn ra trong các models đã học model tốt nhất. * Generalization: most important ability of intelligence ![](https://i.imgur.com/GKIw9HC.png) Interpolation là vùng ta dự đoán dc Extrapolation là vùng ta dự đoán nhưng xác suất sai cao hơn inter (harder) Combinatorics: khop nhiều pp khác nhau để máy tính giải. ![](https://i.imgur.com/0Ar6G47.png) * **which linear classifiers are better?** Câu hỏi này dc đặt ra giữa các classifiers để phân vùng đỏ, xanh. Các classifiers đều phân vùng chính xác nhưng hình dạng của chúng khác nhau. Ta đi tìm ra classifiers tốt nhất để phân vùng dữ liệu. Các điểm dữ liệu có thể bị xê dịch so với vị trí hiện tại nên những classifiers cách đều các vùng và xa nhất là những classifiers tốt. Ta gọi chúng là large-margin * Regression: Common metrics and losses: ![](https://i.imgur.com/BNJUv67.png) Mỗi Metric đều có ưu và nhược điểm cho từng bài toán * Metrics of Classification: Metric name: accuracy Cách hoạt động: Count nếu True không count nếu False thì ta lấy tổng số dự báo đúng chia số dự báo ![](https://i.imgur.com/PT4HgVM.png) ![](https://i.imgur.com/nhVYslR.png) * Confusion matrix là 1 ma trận biểu thị các classification của các items and class Normalization: là ta đi biến các dữ liệu của Confusion matrix về xác suất <= 1 * Accuracy should only be used for class-balanced datasets. (có nghĩa là class-balanced datasets là những data trong đó có số lượng xấp xỉ nhau nếu quá chênh lệch thì là imbalanced thì ta không dùng accuracy mà dùng các metrics dưới đây) * Precision and Recall: metrics for imbalanced thresold là nâng mức phân biệt lên để tăng xsuat chính xác của classification Possitive: là những thứ ta dectect được Negative: là những thứ ta không detect được False Negative: là những thứ nên được detect nhưng không detect được. True Negative: là những thứ không cần detect ra True Possitive: là dectect được đúng class của thứ ta cần. False Possitive: là dectect được nhưng không đúng class của thứ ta cần. ![](https://i.imgur.com/z8ZndiP.png) Ví dụ: Ta chọn class là con chó thì: con mèo số 1 là False Possitive con chó số 2 là False Negative (nên dc detect) con chó số 3 là True Possitive con chó thứ 6 là True Possitive con mèo bên trong con chó thứ 6 là True Negative Lưu ý: Nếu chọn class là con mèo thì con mèo bên trong con chó thứ 6 là False Negative * prediction probability > threshold = positive * prediction probability ≤ threshold = negative (threshold thường là 0.5 nhưng ta thay đổi tùy vào mục đích) * How to calculate the Precision and Recall ? Precision: tỉ lệ trong số các items được detected thì có bao nhiêu items là đúng với cái class mà ta chọn cho predictor (biểu hiện cho how useful the search results are) Recall: là tỉ lệ trong số items mà nên được chọn, đó là những items đúng với class mà chọn cho predictor thì có bao nhiêu items là được dectect và true. (biểu hiện cho how sensitive the results are.) ![](https://i.imgur.com/ETA2mU3.png) * Sự ảnh hưởng của Precision và Recall đến với những bài toán thực tế. ![](https://i.imgur.com/AEtmgjW.png) * Ví Dụ về bài toán cancer: ![](https://i.imgur.com/7CL2NWp.png) Mục tiêu của predictor: dự báo những người bị cancer Ảnh hưởng của Precision và Recall: low precision thì trong số được detect thì số người bị cancer sẽ thấp (True Possitive) và không bị sẽ cao (False Possitive) low recall thì trong số những người bị cancer thì số người được detect sẽ thấp (True possitive) còn số người chưa được phát hiện sẽ cao (False Negative) Vì thế Precision và Recall ảnh hưởng mạnh đến bài toán này nên cả hai đều phải cao thì model mới gọi là tốt. Lưu ý:Với những bài toán khác thì Precision và Recall có mức độ ảnh hưởng khác nhau. * Precision and Recall for muticlass: ![](https://i.imgur.com/hd7wTml.png) Ta sử dụng micro and macro scores. * TPR: True Possitive Rate = (tỉ lệ của các dự đoán đúng) Recall (cách tính giống recall) * FPR: False Possitve Rate = tỉ lệ của các dự đoán sai) * Receiver Operating Characteristic (ROC): * ROC dựa vào TPR và FPR để vẽ đồ thị biểu diễn các đường phân cách ![](https://i.imgur.com/zovvGfM.png) * các đường phân cách càng tiến đến perfect classifier thì càng tốt còn xuống dưới đường màu đỏ là càng xấu. * Threshold moving: maximize G-Mean = sqrt(Sensitivity * Specificity) là một cách để tìm ra threshold tốt nhất Mô hình SVM: dùng hàm lỗi (loss) là hinge loss large margin: đường phân cách 2 vùng nhưng large margin là đường phân cách tốt nhất minimize w = maximize margin Hàm sign Loss predictor cách xa những điểm nhất Biến đổi margin thành công thức toán: dùng hingle loss Nếu 2 vùng có noise, model suport vector machine là những point trên 2 đường phân cách song song scores = Wx + b * những tham số cần tối ưu Gamma quản lý độ cong của decision boundary (chỉ có ở kernel 'rbf') c là khoảng phạt * c càng nhỏ margin càng lớn accuracy càng nhỏ ![](https://i.imgur.com/vzkveP7.png) nhận xét tấm hình: với c=0.1 thì accuracy là 0.86 thì nó chưa cao nhất nhưng khoảng cách phân chia giữa các vùng là rộng, xa nhất nên decision boundary này tốt cho thực tế với c=1 thì accuracy vẫn là 0.86 thì chưa cải thiện dc nhưng mô hình đã ý thức là phải học thuộc luôn cả những noise để tăng accuracy với c=10 thì accuracy là 1 thì mô hình đã phân biệt được những noise nhưng cái này do thuộc lòng thì điều này chưa hẳn là tốt trong thực tế vì nó chiếm không gian của vùng màu xanh và màu đỏ. * siêu tham số gamma là quản lý độ cong của decision boundary ![](https://i.imgur.com/gbTn0RD.png) gamma lớn thì decision boundary sẽ phụ thuộc vào những điểm gần nó gamma nhỏ thì decision boundary sẽ phụ thuộc vào tất cả các điểm nhận xét tấm hình: gamma = 100 ở bức hình cuối tuy mang lại accuracy cao nhất nhưng nó bị hiện tượng overfit nên cái 0.94 tốt hơn. ? * GridSearch là thư viện hỗ trợ việc tối ưu các siêu tham số như C và gamma là ta đi chọn mô hình tốt nhất thông qua thư viện này. * kernel SVM: * Mục đích là để phân chia các vùng dữ liệu dễ dàng hơn * kernel tricks là ta biến đổi không gian của dữ liệu để tạo ra một không gian mới mà tại đó ta có thể tính similarity. * Đây là bài toán tính similarity. * Có các cách tính similarity bằng các kernel: ![](https://i.imgur.com/she4Ahg.png) dev set chọn ra mô hình tốt Generalization độ khái quát hóa regression metric F score dùng cho unbalanced classification Confusion Matrix Thay đổi hàm loss để generalize Large-margin ko phải là linear model SESSION 6 --- tags: COTAI AI4HighSchool slideOptions: transition: slide width: 1920 height: 1080 margin: 0.1 minScale: 0.2 maxScale: 1.5 --- # ML4AI Midterm Questions (written exam, open book, 1 hour) Students **copy Markdown code** of these questions to their Lecture notes and write down solutions in there. 1. [**5** Point] Given a set of inputs $(X^1,\dots,X^N)$, we use PCA to represent them as $X^t = X_0 + z_1U_1+\dots+z_nU_n$ with $X_0$ the mean input and $U_i$ the orthonormal principal components. (Tổng của X)/N - [**2** Points] Write down equation for $X_0$, and equations for properties of $U_i,U_j$: unit length & mutual orthogonal. **Solution**: - [**1** Point] We need to reduce the dimensions of $X^t$ to visualize them on 2D. What is the embedding vector ${\bf z}^t$ of $X^t$ if we use only 2 first principal components to represent it? What is the last feature of ${\bf z}^t$ in this case? **Solution**: - [**1** Point] What are the main differences between representations by PCA and by sparse coding? **Solution**: PCA là một phương pháp giảm kích thước thường được sử dụng để giảm kích thước của các tập dữ liệu lớn. Sparse coding là lấy những thành phần nhỏ trong bức ảnh gốc, thưa thớt. - [**1** Point] If we cluster the dataset into 3 groups with centroids $({\bf m}_1, {\bf m}_2, {\bf m}_3),$ what is the label embedding coordinates of $X^t$ if it belongs to cluster 2? **Solution**: 2. [**1** Point] If we use each song as a feature to represent the users, what is the embedding coordinates ${\bf z}_A$ of user A in the dataset below? **Solution**: ![](https://i.imgur.com/PseEFdZ.png) 3. [**3** Point] From the general form of linear predictors: $\hat{y}=\mathsf{s}(Wz+b)$ with $\mathsf{s}(\cdot)$ a transfer function for desired output interpretation. - [**1** Point] What is $W$ for - 1 dimentional linear regression? **Solution**: là hệ số góc của phương trình đường thẳng y=Wx +b - sofmax regression with 3 classes? **Solution**: W là các thuộc tính của các items - [**1** Point] What is function $\mathsf{s}(\cdot)$ for - 1 dimentional linear regression? **Solution**: identity - SVM binary classification? **Solution**: hàm sign - [**1** Point] Why logistic regression (for binary classification) has only 1 probability output while there are 2 classes? **Solution**: vì kết quả của nó là 0 hoặc 1. 4. [**2** Points] Evaluation procedure - [**1** Point] Explain the main use of the train--dev (validation)--test sets. **Solution**: train set dùng để training, validation set là trong phần training set để chọn ra model tốt nhất, test set là dùng để test xem model có tốt không. - [**1** Point] What are the main similarity and differences between linear SVM and logistic regression? **Solution**: điểm giống nhau là đều sử dụng hàm Wx+b khác nhau là SVM dùng hàm sign, logistic regression là dùng hàm softmax. 5. [**2** Points] There are **1100 items** and **one million users**. We need to build a content-based RecSys by extracting **120 features** ${\bf z}_i$ describing each item $i$ then learn a classifier ${\bf \theta}_j$ for each user $j$ to predict **ratings from 1 to 5 stars** of each user for each item. ![](https://i.imgur.com/PseEFdZ.png) - [**1** Point] How many classes do we need? **Solution**: 5 - [**1** Point] What is the size of $W$ if we use softmax regression $\hat{y}=s(Wz+b)$ for to classify ratings? **Solution**: (5, 120) 6. [**2** Points] Nonlinear predictors have general form $\hat{y}=s(W'\phi(z)+b')$. For Multilayer Perceptrons (MLP) in particular: $\phi(z) = \gamma(Wz+b)$ recursively, each called a "hidden layer". - [**1** Point] Give explicit equation of an MLP with 2 hidden layers. **Solution**: - [**1** Point] What are the parameters of the fully-connected layer in your equation? **Solution**: 7. [**2** Points] Kernel machines use "kernel trick" $\phi(z_i)\cdot\phi(z_j) = \kappa(z_i,z_j)$. - [**1** Point] Explain why kernel trick is useful. **Solution**: * Mục đích là để phân chia các vùng dữ liệu dễ dàng hơn * kernel tricks giúp ta biến đổi không gian của dữ liệu để tạo ra một không gian mới mà tại đó ta có thể tính similarity. - [**1** Point] Explain how we can use kernel trick in feature-space prediction $\hat{y}=s(W^\phi\phi(z)+b)$ to turn a linear predictor into a nonlinear one. **Solution**: vì ta có thể chuyển đổi không gian sang 2 chiều. linear sẽ hình thành trên không gian mới, nonlinear là sẽ ở original space. --- ## Midterm Coding (1 hour) [Đề thi](https://colab.research.google.com/drive/1WuytAqhN_6EBZQK-0S7YYDiiu_MHy41V?usp=sharing). #session 11: học củng cố Planning: lên kế hoạch một cách efficient In the process of planing, we have to make a decision, have a clear goal, the situation of the environment, make new actions in changable enviroment. Transition models: chuyển trạng thái để phù hợp với mtruong -> phải bk trc tất cả các trạng thái. Fail to plan = plan to fail Vdu: lap ke hoach cho robot lau nha, xe tesla, chatbot * plan to achieve the deep goals btoan MDP: Có situation cho ra Action Có s,a cho ra r ![](https://i.imgur.com/tbmIa9G.png) TỔng trung bình reward cao là ta dễ thắng nhất Value functions: tổng xác suất trung bình của từng bước để đạt dc goals Value tối ưu tại state s có action a bằng reward trạng thái hành động a + trung bình các trạng thái tiếp theo. --- tags: COTAI AI4HighSchool slideOptions: transition: slide width: 1920 height: 1080 margin: 0.1 minScale: 0.2 maxScale: 1.5 --- # ML4AI Session 12 Final Exam (for Students) <br> ![](https://i.imgur.com/eDOwrsO.png) <br> CoTAI AI Training Program for Highschool Students © [CoTAI](https://gem.cot.ai) 2021 --- Open book. Choose to answer as many questions as possible, as concisely as possible. Ask instructors if you have difficulty in understanding the questions. **Questions** 1. [**8** Points] The unified TEFPA framework to build a ML model: task $\mathcal{T}$, experience $\mathcal{E}$, function space $\mathcal{F}$, performance $\mathcal{P}$, and algorithm $\mathcal{A}$ to search. What are the elements in TEFPA framework... Answer: T: Task là dự đoán các giá trị trong 1 phạm vi liên tục. Input X: 1 data Output: predicted result E: cung cấp 1 datasets cho máy tính để training P: trong datasets có labels là các giá trị thực tế để so sánh với giá trị dự đoán F: hàm tuyến tính ví dụ: hàm của simple regression là y= mx + b. A: dùng hàm cost function (MSE) để optimize weight rồi dùng gradient descent để update lại cost function. - 1.1 [**2** Point, 3.1] to build a face recognition model using a DCNN? T: Input: picture, output: predicted name of the face E: pictures F: linear P: true name A: Dot product - 1.2 [**2** Point, 3.1] to build a RecSys? (using one of the models you have learned: item-based, user-based, content-based, MF) - 1.3 [**2** Point, 3.1] to build a customer segmentation model using k-means? - 1.4 [**2** Point, 3.1] to build a sentiment analysis model (good, bad, neutral comments) using RNN+Softmax Classifier? 2. [**6** Points] Convolutional filters (or kernels) - 2.1 [**1** Point, 1.1, 3.2] How do we extend them from dot product? - 2.2 [**1** Point, 1.1, 3.2, 3.4] Why do we call their outputs "feature maps"? - feature map là output của 1 filter applied to the previous layer - 2.3 [**1** Point, 3.2] Explain padding: how to do & main purpose - Giữ nguyên kích thước input, mất thông tin ở gốc. - 2.4 [**1** Point, 3.2] Explain pooling: how to do & main purpose - giảm nhanh kích thước input - 2.5 [**1** Point, 3.2] Explain stride: how to do & main purpose - bước nhảy của filter - 2.6 [**1** Point, 3.2, 3.4] Explain their **effective** receptive field: why do they produce highly absstract features? - Vì các absstract features sẽ là cơ sở gốc để hình thành các bộ phận của tổng thể bức hình. 3. [**6** Points] Recurrent neural networks (RNNs) can be used for sequential modeling. - 3.1 [**1** Point, 3.2] What does sequential data mean? - dữ liệu liên tục vdu: giá nhà - 3.2 [**1** Point, 1.1, 3.2, 3.4] Explain each element in this basic equation of RNNs $h_t = \mathsf{\gamma}(Ah_{t-1}+Wz_t)$ - 3.3 [**2** Point, 1.3, 2.1, 3.2] WWhat does back-propagation-through-time mean, why do we need it instead of using plain back-prop, and how does it work for training RNNs? - 3.4 [**1** Point, 1.3, 3.2] Explain vanishing gradient problem for simple RNNs. - 3.5 [**1** Point, 3.1, 3.3] If we want to classify the sentiment of each user comment (good, bad, neutral) at the end of each sequence using RNN+Softmax classifier: explain briefly the model architecture. 4. [**6** Points] Planning in Markov Decision Process (MDP) $(S,A,T,R,\gamma)$. - 4.1 [**1** Point, 3.1, 3.2] Explain 5 elements in MDP model (equation of each element if available). - S: state (ví trị) - A: action (hành động) - T: task (nhiệm vụ) - R: reward (mức độ achieve) - γ: sai số - 4.2 [**1** Point, 3.2] Following a policy $\pi(s)$ to generate a trajectory of 10 time steps $(s_t,a_t,s_{t+1},r_{t+1})$. Compute the return. Equation of $a_t$? - 4.3 [**1** Point, 1.2, 3.2] Repeat for 10 days: from $s_0 = \text{HOME}$ take action $a_0 = \text{GET_BUS}$ with cost $r_1 = 6000 \text{VNĐ}$ then following policy $\pi(s)$ to generate $K=10$ trajectories, each with total cost $G_k$. Compute the average cost of taking bus then following $\pi$: $Q^\pi(\text{HOME, GET_BUS})$. - 4.4 [**1** Point, 1.1, 1.3, 2.1, 3.2] How do we compute an optimal plan (i.e., optimal policy $\pi^*$) of a known MDP $(S,A,T,R,\gamma)$? - 4.5 [**1** Point, 3.2] Why do we say that the action value function $Q^\pi(s,a)$ gives predictions into very far future? - 4.6 [**1** Point, 1.2, 3.2] What is the meaning of action value function when we set $\gamma = 1$? $\gamma = 0$? 5. [**7** Points] Unified ML models $\text{Input } X \xrightarrow[B_{\beta}]{\text{Features}}\text{ Embedding Coordinates }Z \xrightarrow[P_{\theta}]{\text{Predictor}}\text{ Predictions }\hat{Y} \xrightarrow[{\pi^*}]{\text{Policy}}\text{ Action }A$ - 5.1 [**2** Points] List all *taught* algorithms for feature extraction and their main ideas. - PCA main ideas: giảm kích thước hình ảnh - MLP main ideas: cho dữ liệu qua nhiều lớp - kernel trick main ideas: biến đổi chiều kgian - 5.2 [**2** Points] List all *taught* algorithms for making predictions and their main ideas. - Linear Regression *main idea: tìm bộ trọng số - logistic Regression *main idea: tìm bộ trọng số trong problems with two class values. -  NAIVE BAYES: *main ideas: xác suất -   - 5.3 [**2** Points] What are the main *general* differences between linear predictors? And in your opinion why do we need different algorithms? - Linear predictors khác nhau ở dùng cho kiểu dữ liệu khác nhau. - 5.4 [**1** Points] For MDPs, what are the predictions $\hat{Y}$ used to make decisions $A$? 6. [**2** Points] RecSys ![](https://i.imgur.com/PseEFdZ.png) We build item embeddings ${\bf z}_i \in \mathbb{R}^2$ as in table, and use **softmax regression** to predict ratings 1 to 5. Choose a specific user $X\in \{A,\dots,F\}$, what is the training set for learning $\theta_X$? What are the parameters $\theta_X$ to be learned (with their shapes)? 7. [**6** Points] MDP Planning for playing Chess. Let rewards = 1 for winning, -1 for losing, and 0 for a draw or unfinished game, and no discount. - 7.1 [**2** Points] What is the range of value of the optimal action-value function $Q^*(s,a)$, and how to derive probability of win/loss from it? - 7.2 [**2** Points] If we use all the games already played in history to compute $Q^*(s,a)$, explain the method? - 7.3 [**2** Points] Because there are so many state and action pairs $(s,a)$, we need to use *learning* to approximate and generalize for all $(s,a)$ pairs. If we use MLP to learn $Q^*(s,a)$, what is the dataset and possible network structure?

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully