Kernel method in stock prices anomaly detection
Jakub Polec
20+ yrs in Tech & Finance & Quant | ex-Microsoft/Oracle/CERN | IT / Cloud Architecture Leader | AI/ML Data Scientist | SaaS & Fintech
We routinely utilize advanced #statistical methods and machine learning techniques, such as #kernel methods, to uncover #nonlinear #patterns in stock price data.
Anomalies in stock prices refer to instances where the price behaviour deviates significantly from the expected norm, which might suggest underlying events or conditions such as earnings surprises, economic news, etc.
To reveal hidden patterns, we select a kernel function K(x,y) that effectively maps the data into a higher-dimensional feature space. It is important that kernel methods allow us to avoid computationally expensive calculations.
A popular kernel choice is the Radial Basis Function (#RBF ) kernel: K(x,y)=exp(?γ∥x?y∥2),
which is particularly suitable for identifying complex nonlinear relationships. Here, γ (gamma) is a positive real number that determines the influence range of a single training example; the larger the γ, the more localized the influence.
It's important to note that kernel methods do not explicitly perform the transformation Φ(x), which is typically required to shift the data into that higher-dimensional space. Instead, the kernel trick computes inner products in this space implicitly, allowing the structure of the data to become more discernible as if it were in a higher dimension. This step is first into further identification of clusters representing periods of similar price behaviour, and thus any anomalies, etc.
So, we train nonlinear models such as Support Vector Machines (#SVMs) on this implicitly transformed data. The goal of SVM is to find the optimal hyperplane that separates classes in the feature space.
The optimization problem for the SVM is formulated as:
领英推荐
Minimize?∥w∥2?subject?to?yi(w?Φ(xi)+b)≥1,
where w is the weight vector and b is the bias term, which together define the hyperplane.
The function φ(x) represents the implicit higher-dimensional transformation induced by the kernel.
So with stock prices, we apply the kernel function to compute the inner products between the new data points and the support vectors obtained during training.
This step does not involve mapping new data to a higher-dimensional space but uses the kernel to infer the relevant high-dimensional inner products. The model then uses these computations to determine on which side of the decision boundary the new data point lies, thereby predicting the class or the likely trend in stock prices.
Join?quantjourney.substack.com ?for more.
I am here as a result of code created by my Anthropic Sonnet session(Kernel PCA transformation using RBF kernel)... Thanks for the knowledge!
Quantitative Strategist and Derivatives Specialist
1 年Thanks for sharing. Are the anomalies persistent, how long do they last?