Transcript
Page 1: Machine Learning, Stock Market and Chaos

Machine Learning of Chaotic Systems

Solving Complex and Insoluble Problems via Artificial Intelligence

By Lipa Roitman PhDNovember 1st, 2015

Page 2: Machine Learning, Stock Market and Chaos

Contents

• Chaos VS Randomness• Chaotic Processes• Modeling Chaos- Statistics Approach• Modeling Chaos- Artificial Intelligence and Machine

Learning Approach• Steps in Machine Learning• Financial Markets as Chaotic Processes

Page 3: Machine Learning, Stock Market and Chaos

Chaos and Randomness

• Random noise No known cause, no regularity, no rationality, no repeatability, no pattern Impossible to predict

Page 4: Machine Learning, Stock Market and Chaos

Chaos VS Randomness

• Randomness ExamplesPrevious coin flips do not predict the next one.Brownian motion - random walkGaussian and non-Gaussian Random (white) noise with frequency-independent power spectrumOther modes of random processes.

Page 5: Machine Learning, Stock Market and Chaos

• Stationary process: statistical properties: mean value, variance, moments, and probability distribution do not change over time.

Stationary ergodic process: the process has constant statistical properties with time, AND its global statistical properties can be reliably derived from a long enough sample of the process.

Chaos VS Randomness

Page 6: Machine Learning, Stock Market and Chaos

• Real life chaotic processes are neither stationary nor ergodic!

Their statistics have to be constantly monitored since they drift with time.

A nonparametric analysis is needed when the probability distribution of the system is not normal.

Chaos VS Randomness

Page 7: Machine Learning, Stock Market and Chaos

• Astronomy: Three-Body Problem• Sunspots• Geology: Earthquakes• Oceanology: El Niño (Pacific ocean temperature) , Tides• Meteorology: Weather

Chaos in Natural Processes

Page 8: Machine Learning, Stock Market and Chaos

• Fluid flow: luminary vs turbulent • Candle flame• Quantum chaos• Biology: Population growth• Physiology: Arrhythmia, Epilepsy, Diabetis• DNA code• Epidemiology: diseases

Chaos in Natural Processes

Page 9: Machine Learning, Stock Market and Chaos

• Social: fashion trends• Wars• Music and speech• Stock markets, etc.

Chaos in Natural Processes

Page 10: Machine Learning, Stock Market and Chaos

Chaotic Processes

Chaotic Processes Three competing paradigms:

Stability InstabilitySudden and Dramatic Change

Page 11: Machine Learning, Stock Market and Chaos

Chaotic Systems Properties 

What is the pattern?

• Stability: Persistent trends.

• Memory: What happens next depends on prior history.

• Predictable: One can predict while the pattern continues.

Page 12: Machine Learning, Stock Market and Chaos

Chaotic Systems Properties 

• Instability - “tired trend” - accumulation of small random imbalances, or of slow systematic imbalances that precede large change.

• “Sand pile avalanche model”

• Predictability is lower

Page 13: Machine Learning, Stock Market and Chaos

• Change: paradigm changes suddenly, seemingly without warning. – often with reversal of trend

• Fat-Tail: The change could be much stronger from what is expected in the normal Gaussian distribution.

• Black Swan Events

Chaotic Systems Properties 

Page 14: Machine Learning, Stock Market and Chaos

Chaotic Systems Properties 

• Cycles of varying lengths. • Periods of quiet followed by big jumps• Chaotic patterns are predictable, but only in terms of probabilities.

Page 15: Machine Learning, Stock Market and Chaos

• Measuring Chaos - Statistically

Modeling Chaos 

Page 16: Machine Learning, Stock Market and Chaos

• Mathematical modeling of chaotic systems is difficult:

Tiny changes in parameters can sometimes lead to extreme changes in the outcome.There is no certainty, only probability.

Modeling Chaos 

Page 17: Machine Learning, Stock Market and Chaos

• The ubiquity of gradual trends and the rarity of the extreme events resemble the spectral density of a stochastic process, having the form

• In this “1/f noise model” the magnitude of the signal (event) is inversely proportional to its frequency.

Modeling Chaos 

S(f)=1/f^α

Page 18: Machine Learning, Stock Market and Chaos

Although 1/f noise is widely present in natural and social time series, the source of such noise is not well and understood.

1/f noise is an intermediate between the white noise with no correlation in time and random walk (Brownian motion) noise with no correlation between increments.

In most real chaotic processes the random (white) frequency-independent noise overlaps the 1/f noise.

Modeling Chaos 

Page 19: Machine Learning, Stock Market and Chaos

In a random autoregressive process the autocorrelation functions decay exponentially

In chaotic process, they leave a small persistent residue: “long memory”.

Modeling Chaos 

Page 20: Machine Learning, Stock Market and Chaos

If one looks at a chaotic process at different degrees of magnification, one finds they are similar. This self –similarity brings us to a subject of fractalsSelf similarity = Power laws scale invariance fractals (Mandelbrot)Hurst exponent

Scale Invariance

Page 21: Machine Learning, Stock Market and Chaos

• Chaos Fractals Connection

Modeling Chaos 

Page 22: Machine Learning, Stock Market and Chaos

• Rescaling Range• Given a relation

• Scaling the argument x by a constant factor c causes only a proportionate scaling of the function itself

Modeling Chaos 

Page 23: Machine Learning, Stock Market and Chaos

• In other words:

Scaling by a constant c simply multiplies the original power-law relation by the constant c^{-k}. Thus “Self-Similarity”

Modeling Chaos 

Page 24: Machine Learning, Stock Market and Chaos

• “Power Law Signature”: Logarithms of both f(x) and x, have linear relationship: straight-line on the log-log plot.

• Rescaled range - The slope of this line gives the Hurst exponent, H.

Modeling Chaos

Page 25: Machine Learning, Stock Market and Chaos

• Hurst exponent can distinguish fractal from random time series, or find the long memory cycles

Hurst Exponent H

Page 26: Machine Learning, Stock Market and Chaos

• H =1/2 Random walk - Brownian motion -Normal Distribution

• H < 1/2 mean reverting• negative feedback:• high noise• high fractal dimension

Hurst exponent H

Page 27: Machine Learning, Stock Market and Chaos

• 1>H>1/2 Chaotic trending process:

Positive feedback Less noise Smaller fractional dimension Fractional Brownian motion, or 1/f noise

Hurst exponent H

Page 28: Machine Learning, Stock Market and Chaos

Maximal Lyapunov Exponent

Maximal Lyapunov exponent (MLE) is a measure of sensitivity to initial conditions, i.e. unpredictability. Positive MLE: chaos The inverse of Lyapunov exponent: predictability: 1/MLE Large MLE: shorter half-life of signal, faster loss of predictive “power”.

Page 29: Machine Learning, Stock Market and Chaos

• Maximal Lyapunov exponent (MLE) is a measure of sensitivity to initial conditions, a property of chaos

• Hurst exponent H is a measure of persistency

Maximal Lyapunov Exponent

Page 30: Machine Learning, Stock Market and Chaos

Fractal time series are good approximations of chaotic

processes. They are complex systems that have similar

properties.

Modeling Chaos with Fractals

Page 31: Machine Learning, Stock Market and Chaos

Modeling Chaos with Fractals

Fat-tailed probability distribution Memory Effect: Slowly decaying autocorrelation function Power spectrum of 1/f type Modeled with fractal dimension and the Hurst parameter Global or local self-similarity.

Page 32: Machine Learning, Stock Market and Chaos

Fractal dimension D and Hurst exponent H each characterize the local irregularity (D) and global persistence (H).

Thus D and H are the fractal analogues of variance and mean, which are not constant in the chaotic time series.

Fractal Dimension and Hurst Exponent

Page 33: Machine Learning, Stock Market and Chaos

Fractal Dimension and Hurst Exponent

• For self-affine processes, the local properties are reflected in the global ones

• For a self-affine surface in n-dimensional space• D+H=n+1

D: fractal dimensionH: Hurst exponent

Page 34: Machine Learning, Stock Market and Chaos

Chaos and Fractals Connection

Fractals have self-similar patterns at different scales.

Fractal dimension

Multi fractal system - continuous spectrum of exponents - singularity spectrum.

Page 35: Machine Learning, Stock Market and Chaos

Random shocks to the process, such as news events. The shocks can have both temporary and lasting effect

Combination of interdependent autoregressive processes, each with its own statistical properties.

Two Reasons For 1/F Noise  

Page 36: Machine Learning, Stock Market and Chaos

Modeling Chaos: Artificial Intelligence and Machine Learning

Approach

Modeling Chaos - AI Approach 

Page 37: Machine Learning, Stock Market and Chaos

Artificial Intelligence

• Machine Learning Purpose: Generalization• Find the laws within the data• Predicting change

• Number crunching allows finding hidden laws, not obvious to human eye

Page 38: Machine Learning, Stock Market and Chaos

Artificial Intelligence Types

Rules Based AI

Man creates the rules: Expert Systems

The rule-based approach is time consuming and not very accurate

Page 39: Machine Learning, Stock Market and Chaos

Supervised learning from examples

The examples must be representative of the entire data set.

Artificial Intelligence Types

Page 40: Machine Learning, Stock Market and Chaos

Un-supervised learning

Classification: clustering

Artificial Intelligence Types

Page 41: Machine Learning, Stock Market and Chaos

Deep learning

Deep learning models high-level abstractions in data by using multiple processing layers with complex structures.

Artificial Intelligence Types

Page 42: Machine Learning, Stock Market and Chaos

Deep learning can automatically select the features

For a simple machine learning, a human has to tell the algorithm which combination of features to consider

Deep learning finds the relationships on its own

No human involvement

Artificial Intelligence Types

Page 43: Machine Learning, Stock Market and Chaos

“Ultra Deep Learning”

Machine has learned so much, it can not only derive the rules, but detect when the rules change: detect the change in paradigms.

Combines the supervised, un-supervised types and rule based machine learning into a more intelligent system.

Artificial Intelligence Types

Page 44: Machine Learning, Stock Market and Chaos

Steps in Machine Learning

Provide FrameworkMathematical and Programming Tools

Data preparation

Parameters estimation

Give examples to learn from: the input (and in some methods the output)

Page 45: Machine Learning, Stock Market and Chaos

Steps in Machine Learning

• Creating a Model (or Models).• Fitness Function: What to optimize?

• Example: Make more good predictions than bad ones.

Page 46: Machine Learning, Stock Market and Chaos

Data Preparation

Data preparationConvert the generally non-stationary data into more-or-less stationaryRemove the cycles, trends to reduce the uniqueness of each data point

Page 47: Machine Learning, Stock Market and Chaos

Parameters Estimation

• Parametric OR Nonparametric?• Parametric model: fixed number of parameters• Nonparametric: no assumptions about the probability distributions of

the variables. • In non-parametric model the number of parameters increases with the

amount of training data.

Page 48: Machine Learning, Stock Market and Chaos

Creating a Model

“All Models are Wrong, Some Models are Useful” – George E. P. Box

Page 49: Machine Learning, Stock Market and Chaos

Multivariate time series

Multivariate time series modeling is required when the outcome of one process depends on other processes.

Examples are systems of interdependent global and local processes, asset prices, exchange rates, interest rates, and other variables.

Page 50: Machine Learning, Stock Market and Chaos

Multivariate time series

To create a model one could use the available knowledge about interrelationship of the processes, and combine it with unknowns in one or more of the linear or non-linear models. The “fitness” or “error” function is then created, which compares the model with the data.

Page 51: Machine Learning, Stock Market and Chaos

Machine Learning

The fitness function is improved through machine learning by varying the parameters in the model. The goal is to maximize the fitness of the model to the data presented for learning (minimize the error). Different models are screenedPart of the data is saved from the learning cycle to be used for testing.The successful model should be able to perform adequately on the test data.

Page 52: Machine Learning, Stock Market and Chaos

Dimensionality Reduction

• Dimensionality reduction

• Speeds up algorithm execution• Improves performance• The less variables the better is generality

Page 53: Machine Learning, Stock Market and Chaos

• Principal Component Analysis is one of the methods of dimensionality reduction.

• Orthogonally transforms the original data set into a new set of “principal components”

Dimensionality Reduction Methods

Page 54: Machine Learning, Stock Market and Chaos

• Methods:• Low Variance Filter. • High Correlation Filter. • Pruning the network.• Adding and replacing inputs.• Other methods.

Dimensionality Reduction Methods

Page 55: Machine Learning, Stock Market and Chaos

Clustering

• The many examples in the data can be compressed into clusters according to the similarity through fitting to one or more criteria.

• Each data member that belongs to a cluster is associated with a number from 0 to 1 that shows the degree of belonging.

• Each data member can also belong to multiple clusters with each specific degree of belonging.

• Clustering can be a goal in itself, or a part of a general model, that includes the behavior of clusters as a whole.

Page 56: Machine Learning, Stock Market and Chaos

Time Constraint

• A <insert favorite programming language> programmer knows the value of everything, but the cost of nothing. -- Alan J. Perlis

Page 57: Machine Learning, Stock Market and Chaos

Time Constraint

• Some problems are insoluble or too complex to be completely solved in reasonable time.

• Compromises are necessary, e.g. speed vs precision vs generality• Time complexity (big O notation) of an algorithm quantifies the

amount of time taken by an algorithm to run as a function of the length of the string representing the input.

Page 58: Machine Learning, Stock Market and Chaos

Time Complexity (Big O Notation)

Page 59: Machine Learning, Stock Market and Chaos

Choice of Algorithm

• Which Algorithm?

Depends on the task

Depends on time available

Depends on the precision required

Page 60: Machine Learning, Stock Market and Chaos

Local and Global Minimum

accp1.org/pharmacometrics/theory.htm

Uphill SearchingDownhill Gradient Searching

Page 61: Machine Learning, Stock Market and Chaos

Local Search Algorithms

• Local search methods: • steepest descent or • best-first criterion, • stochastic search.

• simulated annealing, • genetic selection• others

Page 62: Machine Learning, Stock Market and Chaos

A random move altering the state Assess the fitness of the new state Compare the fitness to the previous state Decide whether to accept the new solution or reject it. Repeat until you have converged on an acceptable answer

Simulated Annealing

Page 63: Machine Learning, Stock Market and Chaos

Global Search Algorithms

• Stochastic optimization• Uphill searching• Basin hopping

Page 64: Machine Learning, Stock Market and Chaos

accp1.org/pharmacometrics/theory.htm

Local and Global Minimum

Page 65: Machine Learning, Stock Market and Chaos

Basin Hopping

The algorithm is iterative with each cycle composed of the following features

Random perturbation of the coordinates

Local minimization

Accept or reject the new coordinates based on the minimized function value

Page 66: Machine Learning, Stock Market and Chaos

Genetic Algorithms

• Many solutions are in the pool, some good, some not so.• Each solution is analogous to a chromosome in genetics

Page 67: Machine Learning, Stock Market and Chaos

Genetic Algorithms

• Ways to improve gene pool: • Combination:

• Combine two or more solutions in hope of producing a better solution.

• Mutation: • -Modify a solution in random places in hope of producing a

better solution.• Crossover:

• Import a solution from a similar problem• Selection:

• Survival of the fittest

Page 68: Machine Learning, Stock Market and Chaos

68

Bain-Template

Gene Pool

ReproduceMutate

SelectReject

Crossover

Genetic Algorithm

Page 69: Machine Learning, Stock Market and Chaos

I Know First Predictive Algorithm

• Most financial time series exhibit classical chaotic behavior. The chaos theory, the classification and predictive capabilities of the machine learning has been applied to forecasting of such time series.

• This artificial intelligence approach is in the root of I Know First predictive algorithm.

Page 70: Machine Learning, Stock Market and Chaos

I Know First Predictive Algorithm

The following slides are the method and the results of applying the algorithm to learn the database of historical time series data.

Page 71: Machine Learning, Stock Market and Chaos

The I Know First Algorithm

The results are constantly improving as the algorithm learns from its successes and failures

Tracks and predicts the flow of

money from one market or

investment channel to another

The system is a

predictive model based

on Artificial Intelligence,

Machine Learning, and

incorporates elements of

Artificial Neural Networks

and Genetic Algorithms

Tracks the flow of money Artificial

Intelligence (AI)

Machine

Learning

(ML) Artificial Neural

Networks

Genetic Algorithms

I Know Firstpredicts 2000

Market’s Eeveryday

Page 72: Machine Learning, Stock Market and Chaos

Synopsis of the Algorithm

The results are constantly improving as the algorithm learns from its successes and failures

Page 73: Machine Learning, Stock Market and Chaos
Page 74: Machine Learning, Stock Market and Chaos

Two indicators:

Signal – Predicted movement of the assetPredictability Indicator – Historical correlation between the prediction and the actual market movement

Daily Market Heat map

Page 75: Machine Learning, Stock Market and Chaos

XOMA returned 61.45% in1 month from this forecast

Page 76: Machine Learning, Stock Market and Chaos

Forecast vs. Actual

Page 77: Machine Learning, Stock Market and Chaos

I Know First Sample Portfolio

Page 78: Machine Learning, Stock Market and Chaos

I Know First beats the

S&P500 by 96.4%

View Full Portfolio

I Know First Live Portfolio 2015 Performance

The Performance

Page 79: Machine Learning, Stock Market and Chaos

I Know First beats the

S&P500 by 20.8%

The Performance

Page 80: Machine Learning, Stock Market and Chaos

The Performance

Page 81: Machine Learning, Stock Market and Chaos

The Performance

Page 82: Machine Learning, Stock Market and Chaos

Main Features of the Algorithm

Identifies The Best Market Opportunities Daily6 Time FramesTracks Over 3,000 MarketsSelf-LearningAdaptableAlways Learning New PatternsScalableA Decision Support System (DSS) Predictability IndicatorStrong Historical Performance – 60.66% gain in 2013

The algorithm becomes more and more accurate with every prediction as it constantly tests

multiple models in different market circumstances

Page 83: Machine Learning, Stock Market and Chaos

More Applications Of I Know First Algorithm

• Time Series Forecasting of Multidimensional Chaotic Systems.

• What if? It is a Scenario-based Forecasting


Top Related