20250717

20250717 Meeting

GAP 補上辭意的訊息來強化語意的合理性 1️⃣ 加入 Word Embedding(詞向量)相似性 工具 用途 Word2Vec / GloVe / FastText 表示詞意分布的向量空間 Cosine Similarity 衡量兩詞語意相似性 做法: 1️. GAP 排完後,對每個群的 token: 計算該群內所有詞的 embedding 平均 檢查這些詞彼此 cosine similarity 是否夠高 2️. 若有明顯「語意不合」的詞: 你可以手動微調或重新分群 或將 GAP + embedding 結果結合成 新的相似矩陣 2️⃣ 建立 混合型相似矩陣(共現 × 詞意) 將 GAP 的 col_prox(共現 correlation)與 Word2Vec 相似性做結合: $$ Final_Similarity = \lambda \cdot GAP_Col_Prox + (1 - \lambda) \cdot Cosine_Similarity $$ $\lambda$:權重 GAP 捕捉共現結構,詞向量補足語意距離 用這個混合矩陣再進行 GAP 排序或分群,更穩健。 3️⃣ 或者導入 詞典 / 知識圖譜 強化語意結構 ...

July 16, 2026 · 1 min
20250710

20250710 Meeting

Generalized Association Plots(GAP) 針對高維度的資料進行視覺化與排序的工具 起始矩陣 D: 輸入任意一個 p by p 的 proximity matrix (如皮爾森相關係數矩陣) 遞迴相關係數矩陣: $R^{(1)}=\phi(D)$ $R^{(n+1)}=\phi(R^{(n)})$ 收斂: $R(n)$ 會收斂至 +1 和 -1 的矩陣 $R^{(\infty)}$ 收斂的過程當中會觀察到rank的降維和橢圓結構的變化(由橢圓壓縮至一直線), 對於排序(seriation)和分群(clustering)很有用 應用在文本分析: 若對新聞文本進行主題建模分析,能透過建立文件 $\rightarrow$ Topic 或 Topic-Keyword 的近似矩陣,藉由 GAP 的排序與分群,有助於Topic 或 Document 之間結構的視覺化與理解 Procedure 步驟 內容 目的 1 用 BBC News 5 類別資料(語料庫) 作為範例語料 2 每類取 前 15 個代表 token 建立小型 token 子集(75 tokens) 3 用 GAP 排序視覺化 75×75 矩陣 找到語意群聚結構 4 人工確認分 5 群 將 token-to-topic 定義好 5 用 token 群建 LDA 的 η 先驗 導引 LDA 學出預期主題 Question 問題 你的回答 GAP 結果丟進 LDA 了嗎? 是,透過 η 矩陣間接導入,不是直接丟 category η 怎麼設定? GAP 群內 η 大(如 0.3),其他小(如 0.01) GAP correlation 值有用來當機率嗎? 沒有,只有分群結果用來指定 topic GAP 是否直接影響文件分類? 沒有,只影響 LDA 主題-詞先驗 是否做 baseline LDA 比較? 尚未,之後會補做對比 baseline Advice GAP → 幫助 η 結構設計 baseline LDA vs GAP-informed LDA 結果對比 LDA 原理本來無需分群,這裡是你的設計特色 可以不用特別追求完美的理論公式,重點是架構合理、結果可解釋性夠

July 10, 2026 · 1 min
20250729

探討不同位置球員在進攻表現與薪資結構上的差異性—以2023年NBA球員為例

這是給自己的一份學習紀錄,以免日子久了忘記這是甚麼理論XD 目錄 介紹 研究目的 研究資料 研究流程 小結1 小結2 結果與討論 參考資料

July 29, 2025 · 1 min
20250707

20250707 LDA的理解與AI的修正

前情提要 這裡的 LDA 指的是 Latent Dirichlet Allocation 隱含狄利克雷分佈 不是 Linear Discriminant Analysis 關於 LDA 一種主題模型, 由 Blei, D. M. 等人在2003年提出, 是一種無監督式的學習(unsupervised learning) 主要用途是將文本的主題按機率向量的方式提出, 且每個主題都有其相呼的文字可以對照 其結構主要是多層的貝氏網絡組成, 起初是EM演算法來估計參數, 而後改成用Gibbs Sampling來估計參數 詳細內容請參考維基百科(點擊後開啟網站)或論文(點擊後開啟 pdf 檔案) 本篇主旨 在閱讀相關文獻之後, 因為其核心觀念來自於多層的貝氏網絡, 如圖 取自文獻 所以我個人提出了對於 LDA 架構的看法, 並丟進 Chat GPT-4o 模型來修正我的觀念 以下是我和 GPT 的對話 我: 給定一個來自迪利克雷分布的參數alpha, 第d個文件theta有topic1,topic2,topic3…的機率向量, 各個topic又有共同的詞彙w1,w2,w3..的機率分布, 我們要知道的是在第d個文件theta之下的topic機率與第topic下的w1的機率乘機總和(條件機率的概念), 來得知這個d文件擁有這些w1,w2,w3…的機率, 最後再乘上給定eta參數的beta分布下的k主題, 來決定每個w來自哪個主題, 因此得到該文件屬於哪個主題 GPT: ✅ 你說得對的部分: ✔️ $α$ 是來自 Dirichlet 分布的超參數,控制每個文件的主題分布 $θ$。 ✔️ 每個主題 $k$ 有一個詞語分布 $φ_k$,控制該主題產生哪些詞($w1, w2, …$)的機率。 ✔️ 文件生成詞的機率可由:「主題機率 × 詞在該主題下的機率」來決定。 ✔️ 對每個詞 $w$,模型要根據 $θ$ 和 $φ_k$ 來計算它來自哪個主題的機率。 ✔️ $η$ 是 Dirichlet 的超參數,控制每個 $φ_k$(主題的詞分布)的稀疏性。 🔧 需要調整與補強的地方: ...

July 7, 2025 · 2 min
20250112

Expectation maximization algorithm

這是給自己的一份學習紀錄,以免日子久了忘記這是甚麼理論XD Expectation-maximization algorithm -「最大期望值演算法」 經過兩個步驟交替進行計算: 第一步是計算期望值(E):利用對隱藏變量的現有估計值,計算其最大概似估計值 第二步是最大化(M):最大化在E步上求得的最大概似值來計算參數的值 M步上找到的參數估計值被用於下一個E步計算中,這個過程不斷交替進行 引自維基百科 Example from finalterm Assume that $Y_1, Y_2, …, Y_n ~ exp(\theta)$ Consider the MLE of $\theta$ based on $Y_1, Y_2, …, Y_n$ Suppose that 5 observed samples are collected from the experiment which measures the life time of the light bulb. Assume $y_1=1.5$, $y_2=0.58$, $y_3=3.4$ are complete experiment process. Because of the time limit, the fourth and fifth experiment are terminated at times $y^*_4=1.2$ and $y^*_5=2.3$ before the light bulb die. Based on ($y_1, y_2, y_3, y^*_4, y^*_5$), please use EM algorithm to estimate $\theta$. Solve With observed lifetimes: $y_1=1.5$, $y_2=0.58$, $y_3=3.4$ and $y^*_4=1.2$, $y^*_5=2.3$, meaning the actual lifetimes $Z_4>1.2$, $Z_5>2.3$ are unknown. So we treat $Z_4$ and $Z_5$ as latent variables, and have the complete likelihood like: ...

July 3, 2025 · 2 min
20250330

XGBoost Learning

這是給自己的一份學習紀錄,以免日子久了忘記這是甚麼理論XD 🦹 XGBoost Boost What is XGBoost? Think of XGBoost as a team of smart tutors, each correcting the mistakes made by the previous one, gradually improving your answers step by step. 🗝 Key Concepts in XGBoost Tree Building Start with an initial guess (e.g., average score). Measure how far off the prediction is from the real answer (this is called the residual). The next tree learns how to fix these errors. Every new tree improves on the mistakes of the previous trees. 🥢 How to Divide the Data (Not Randomly) XGBoost doesn’t split data based on traditional methods like information gain. It uses a formula called Gain, which measures how much a split improves prediction. A split only happens if: (Left + Right Score) > (Parent Score + Penalty) ❓ How do we know if a split is good? Use a value called Similarity Score The higher the score, the more consistent (similar) the residuals are in that group 🐢 Two Ways to Find Splits: Accurate- Exact Greedy Algorithm Try all possible features and split points Very accurate but very slow 🐇 Two Ways to Find Splits: Fast- Approximate Algorithm Uses feature quantiles (e.g., median) to propose a few split points Group the data based on these splits and evaluate the best one Two options: Global Proposal: use global info to suggest splits Local Proposal: use local (node-specific) info 🏋 Weighted Quantile Sketch Some data points are more important (like how teachers focus more on students who struggle) Each data point has a weight based on how wrong it was (second-order gradient) Use these weights to suggest better and more meaningful split points 🕳 Handling Missing Values What if some feature values are missing? XGBoost learns a default path for missing data This makes the model more robust even when the data isn’t complete 🧚‍♀️ Controlling Model Complexity: Regularization Gamma (γ) ...

March 30, 2025 · 2 min
20250322

Naive & Gaussian Bayes Learning

這是給自己的一份學習紀錄,以免日子久了忘記這是甚麼理論XD 👶 Naive Bayes By definition of Bayes’ theorem $$ P(y \mid x_1, x_2, …, x_n) = \frac{P(y)P(x_1, x_2, …, x_n \mid y)}{P(x_1, x_2, …, x_n)} $$ where $P(y)$ represents the prior probability of class $y$ $P(x_1, x_2, …, x_n \mid y)$ represents the likelihood, i.e., the probability of observing features $x_1, x_2, …, x_n$ given class $y$ $P(x_1, x_2, …, x_n)$ represents the marginal probability of the feature set $x_1, x_2, …, x_n$ With the assumption of Naive Bayes - Conditional Independence $$ P(x_i \mid y, x_1, …, x_{i-1}, x_{i+1}, …, x_n) = P(x_i \mid y) $$ ...

March 21, 2025 · 3 min
20250318

Decision & Classification Tree Learning

這是給自己的一份學習紀錄,以免日子久了忘記這是甚麼理論XD 🤔 What is decision tree? Decision tree is a system that relies on evaluating conditions as True or False to make decisions, such as in classification or regression. When the tree needs to classify something into class A or class B, or even into multiple classes (which is called multi-class classification), we call it a classification tree; On the other hand, when the tree performs regression to predict a numerical value, we call it a regression tree. ...

March 18, 2025 · 3 min
20250318

Monte Carlo Integration

這是給自己的一份學習紀錄,以免日子久了忘記這是甚麼理論XD (1) 已知: $$X_1, X_2, …, X_n \overset{\text{iid}}{\sim}p(x)$$ 計算: $$ E( \hat{I}_M)=E\left[\frac{1}{n} \sum^n_{i=1} \frac{f(X_i)}{p(X_i)} \right]=\frac{1}{n}E\left[ \sum^n_{i=1} \frac{f(X_i)}{p(X_i)} \right] $$ 對於每個獨立的 $X_i$ ,我們只要計算: $$E\left[\frac{f(X_i)}{p(X_i)} \right]$$ 因此: $$ E\left[\frac{f(X)}{p(X)} \right] = \int^b_a\frac{f(x)}{p(x)}p(x)dx =\int^b_af(x)dx = I $$ 可知 $$E\left[\frac{f(X_i)}{p(X_i)} \right] =I, \forall i $$ 所以 $$ E(\hat{I}_M) =\frac{1}{n}\sum^n_{i=1}I=I $$ (2) 計算變異數 $$Var(\hat{I}_M)=E\left[(\hat{I}_M-I)^2\right]$$ 因為 $$ \begin{aligned} Var(\widehat{I}_M) &= Var\left(\frac{1}{n} \sum_{i=1}^{n} \frac{f(X_i)}{p(X_i)}\right) = \frac{1}{n}Var\left(\frac{f(X)}{p(X)}\right) \\ &= \frac{1}{n}\left(E\left[\left(\frac{f(X)}{p(X)}\right)^2\right]-I^2\right) \end{aligned} $$ 已知 $$E\left[\left(\frac{f(X)}{p(X)}\right)^2\right] < \infty$$ 所以當 $n \to \infty$ 時 $$Var(\hat{I}_M) \to 0$$ ...

March 18, 2025 · 2 min
20250311

Logistic Regression Learning

這是給自己的一份學習紀錄,以免日子久了忘記這是甚麼理論XD Logistic Function (aka logit, MaxEnt) classifier, which means that it is also known as logit regression, maximum-entropy classification(MaxEnt) or the log-linear classifier. In this model, the probabilities from the outcome of predictions is using a logistic function. And what is logistic function? Let talk about it. Here comes from Wikipedia: A logistic function or a logistic curve is a commond S-shaped curve (sigmoid curve) with the equation: $$ f(x) = \frac{L}{1+e^{-k(x-x_o)}}$$ where: ...

March 11, 2025 · 5 min