Luna's Blog

ใ€Œๆฐไผผๅคฉๅœฐไธ€่œ‰่ฃใ€

CPSC 340 Feature Selection

Feature Selection General feature selection problem: Find the features (columns) of โ€˜Xโ€™ that are important for predicting โ€˜yโ€™. Association Approach: For each feature โ€˜jโ€™, compute correlation be...

Trees

Bottom Up Recursive VS Top Down Recursive Ancestor Problems 235. Lowest Common Ancestor of a Binary Search Tree 236. Lowest Common Ancestor of a Binary Tree 1026. Maximu...

Math Problems

50. Pow(x, n) Implement pow(x, n), which calculates x raised to the power n (i.e., $x^n$). The simplest way is to multiply n times, time complexity is $O(n)$ Another way is to think $x^{10}$ as $...

SweepLine Related Problems

Interval & Sweep Line Related Problems For two intervals, A and B: if A.end > B.start and A.start < B.end then they have duplicate intervals. After sorting by the start time, w...

CPSC 340 Robust Regression

Robust Regression Robust regression focus less on large errors. Instead of minimizing L2-norm, minimizes L1-norm of residuals. $f(w) = ||Xw-y||$ โ€“ itโ€™s harder to minimize the absolute error, we d...

CPSC 340 Feature Selection

We need to find the features that are important for predicting y. Association approach - for each feature j, compute correlation between feature $x^j$ and $y$ (however it ignores variable inter...

Linked List

Cycles We can use Floyd algorithm to solve problems like this. 141. Linked List Cycle Given head, the head of a linked list, determine if the linked list has a cycle in it. Return true if there...

CPSC 340 Linear Regression

We want to discover relationship between numerical variables. Linear Regression in 1-D dimension Assume we have only 1 feature (d = 1), linear regression make prediction $\hat{y_i}$ using a linear...

CPSC 340 Gradient Descent

Gradient Descent starts with a guess $w_0$ use the gradient $\nabla f(w^0)$ to generate a better $w^1$ โ€ฆ the limit of $w^t$ goes to $\infty$ has $\nabla f(w^t) = 0$ It converges to a glo...

CPSC340 Outlier Detection

Methods Model-based Graphical Cluster-Based Distance-Based Supervised Model-Based Outlier Detection We can fit a probabilistic model, outliers are those with low probability. Assume d...