SlideShare a Scribd company logo
1 of 53
Download to read offline
AlphaPy
A Data Science Pipeline in Python
1
The Framework
2
The Framework
• The Model Pipeline is the common code that will generate
a model for any classification or regression problem.
• The Domain Pipeline is the code required to generate the
training and test data; it transforms raw data from a feed
or database into canonical form.
• Both pipelines have configuration files using the YAML
format.
• The output of the whole process is a Model Object, which
is persistent; it can be saved and loaded for analysis.
3
Model Pipeline
4
Model Pipeline
5
Components
• scikit-learn: machine learning in Python
• pandas: Python data analysis library
• NumPy: numerical computing package for Python
• spark-sklearn: scikit-learn integration package for Spark
• skflow: scikit-learn wrapper for Google TensorFlow
• SciPy: scientific computing library for Python
• imbalanced-learn: resampling techniques for imbalanced data sets
• xgboost: scaleable and distributed gradient boosting
6
Predictive Models
• Binary Classification: Classify elements of a given
set into two groups.
• Multiclass Classification: Classify elements of a
given set into greater than two or more groups.
• Regression: Predict real values of a given set.
7
Classification
• AdaBoost
• Extra Trees
• Google TensorFlow
• Gradient Boosting
• K-Nearest Neighbors
• Logistic Regression
• Support Vector Machine (including Linear)
• Naive Bayes (including Multinomial)
• Radial Basis Functions
• Random Forests
• XGBoost Binary and Multiclass
8
Regression
• Extra Trees
• Gradient Boosting
• K-Nearest Neighbor
• Linear Regression
• Random Forests
• XGBoost
9
Data Sampling
• Different techniques to handle unbalanced classes
• Undersampling
• Oversampling
• Combined Sampling (SMOTE)
• Ensemble Sampling
10
Feature Engineering
• Imputation
• Row Statistics and Distributions
• Clustering and PCA
• Standard Scaling (e.g., mean-centering)
• Interactions (n-way)
• Treatments (see below)
11
Treatments
• Some features require special treatment, for example, a date column
that is split into separate columns for month, day, and year.
• Treatments are specified in the configuration file with the feature
name, the treatment function, and its parameters.
• In the following example, we apply a runs test to 6 features in the
YAML file:
12
Feature Transformation
13
Feature Processing
14
Encoders
• Factorization
• One-Hot
• Ordinal
• Binary
• Helmert Contrast
• Sum Contrast
• Polynomial Contrast
• Backward Difference Contrast
• Simple Hashing
15
Feature Selection
• Univariate selection based on the percentile of
highest feature scores
• Scoring functions for both classification and
regression, e.g., ANOVA F-value or chi-squared
statistic
• Recursive Feature Elimination (RFE) with Cross-
Validation (CV) with configurable scoring function
and step size
16
Grid Search
• Full or Randomized Distributed Grid Search with
subsampling (Spark if available)
17
Ensembles

Blending and Stacking
18
Best Model Selection
19
Model Evaluation
• Metrics
• Calibration Plot
• Confusion Matrix
• Learning Curve
• ROC Curve
20
Metrics
21
Calibration Plot
22
Confusion Matrix
23
Learning Curve
24
ROC Curve
25
Domains
• A domain encapsulates functionality that operates on specific
kinds of schema or subject matter.
• The purpose of the Domain Pipeline is to prepare data for the
Model Pipeline. For example, both market and sports data are
time series data but must be structured differently for prediction.
• Market data consist of standard primitives such as open, high,
low, and close; the latter three are postdictive and cause data
leakage. Leaders and laggards must be identified and possibly
column-shifted, which is handled by the Model Pipeline.
• Sports data are typically structured into a match or game format
after gathering team and player data.
26
Market Domain
1. Suppose we have five years of history for a group
of stocks, each stock represented by rows of time
series data on a daily basis.
2. We want to create a model that predicts whether or
not a stock will generate a given return over the
next n days, where n = the forecast period.
3. The goal is to generate canonical training and test
data for the model pipeline, so we need to apply a
series of transformations to the raw stock data.
27
Market Pipeline
28
Feature Definition Language
• Along with treatments, we defined a Feature
Definition Language (FDL) that would make it easy
for data scientists to define formulas and functions.
• Features are applied to groups, so feature sets are
uniformly applied across multiple frames.
• The features are represented by variables, and
these variables map to functions with parameters.
29
FDL Example
• Suppose we want to use the 50-day moving average (MA)
in our model, as we believe that it has predictive power for
a stock’s direction.
• The moving average function ma has two parameters: a
feature (column) name and a time period.
• To apply the 50-day MA, we can simply join the function
name with its parameters, separated by “_”, or
ma_close_50.
• If we want to use an alias, then we can define cma to be
the equivalent of ma_close and get cma_50.
30
Stock Pipeline Example
• Develop a model to predict days with ranges that
are greater than average.
• We will use both random forests and gradient
boosting.
• Get daily data from Yahoo over the past few years
to train our model.
• Define technical analysis features with FDL.
31
Stocks Configuration
32
Stocks Configuration
33
Model Configuration
• Data Section
34
Model Configuration
• Model Section
35
Model Configuration
• Features Section
36
Model Configuration
• Other Sections
37
Start Stocks Pipeline
38
Get Stock Prices
39
Apply Variables
40
Create Train/Test Files
41
Transform Features
42
Fit Model
43
Cross-Validate
44
Generate Metrics
45
Calibration [Train]
46
Calibration [Test]
47
Learning Curves
48
Feature Importances
49
Random Forest ROC
50
XGBoost ROC
51
Results
• We have identified some features that predict large-
range days. This is important for determining
whether or not to deploy an automated system on
any given day.
• Results are consistent across training and test data.
• The learning curves show that results may improve
with more data.
52
Use Cases
• AlphaPy was created based on experimentation
with many Kaggle competitions, so it can generate
models for any classification or regression problem.
• AlphaPy has been designed to be a toolkit for all
data scientists.
• The AlphaPy framework has specific pipelines for
creating market and sports models.
53

More Related Content

What's hot

Petabyte Scale Anomaly Detection Using R & Spark by Sridhar Alla and Kiran Mu...
Petabyte Scale Anomaly Detection Using R & Spark by Sridhar Alla and Kiran Mu...Petabyte Scale Anomaly Detection Using R & Spark by Sridhar Alla and Kiran Mu...
Petabyte Scale Anomaly Detection Using R & Spark by Sridhar Alla and Kiran Mu...Spark Summit
 
Summary of PERC activity.doc.doc
Summary of PERC activity.doc.docSummary of PERC activity.doc.doc
Summary of PERC activity.doc.docbutest
 
CIS110 Computer Programming Design Chapter (10)
CIS110 Computer Programming Design Chapter  (10)CIS110 Computer Programming Design Chapter  (10)
CIS110 Computer Programming Design Chapter (10)Dr. Ahmed Al Zaidy
 

What's hot (6)

Learning to Optimize
Learning to OptimizeLearning to Optimize
Learning to Optimize
 
Petabyte Scale Anomaly Detection Using R & Spark by Sridhar Alla and Kiran Mu...
Petabyte Scale Anomaly Detection Using R & Spark by Sridhar Alla and Kiran Mu...Petabyte Scale Anomaly Detection Using R & Spark by Sridhar Alla and Kiran Mu...
Petabyte Scale Anomaly Detection Using R & Spark by Sridhar Alla and Kiran Mu...
 
Intro
IntroIntro
Intro
 
Summary of PERC activity.doc.doc
Summary of PERC activity.doc.docSummary of PERC activity.doc.doc
Summary of PERC activity.doc.doc
 
CIS110 Computer Programming Design Chapter (10)
CIS110 Computer Programming Design Chapter  (10)CIS110 Computer Programming Design Chapter  (10)
CIS110 Computer Programming Design Chapter (10)
 
Query optimization
Query optimizationQuery optimization
Query optimization
 

Viewers also liked

Emperor Asset Management: PE seminar 19 November 2013
Emperor Asset Management: PE seminar 19 November 2013Emperor Asset Management: PE seminar 19 November 2013
Emperor Asset Management: PE seminar 19 November 2013Emperor Asset Management
 
Ernest shackleton
Ernest shackletonErnest shackleton
Ernest shackletonroom22bds
 
Ernest shackleton courage project
Ernest shackleton courage projectErnest shackleton courage project
Ernest shackleton courage projectwmsbierer
 
Ernest Shackleton
Ernest ShackletonErnest Shackleton
Ernest Shackleton11nielsdar
 
Antarctica
AntarcticaAntarctica
AntarcticaMerry C
 
QNT 351 Final Exam Answers 2015 version
QNT 351 Final Exam Answers 2015 versionQNT 351 Final Exam Answers 2015 version
QNT 351 Final Exam Answers 2015 versionvincenzwhaley
 
El tesoro más preciado de la herencia
El tesoro más preciado de la herenciaEl tesoro más preciado de la herencia
El tesoro más preciado de la herenciaIADERE
 
Shot List
Shot List Shot List
Shot List downerj
 
Ppt hendrik du randt
Ppt hendrik du randtPpt hendrik du randt
Ppt hendrik du randtjosepharry1
 
Convención Marco sobre el Cambio Climático
Convención Marco sobre el Cambio ClimáticoConvención Marco sobre el Cambio Climático
Convención Marco sobre el Cambio ClimáticoIADERE
 
Confusion INFOGRAPHIC
Confusion INFOGRAPHICConfusion INFOGRAPHIC
Confusion INFOGRAPHICRobin Davies
 
Resume for Zymer Kurti
Resume for Zymer KurtiResume for Zymer Kurti
Resume for Zymer Kurtizymer kurti
 
Heterosis breeding in horticultural crops
Heterosis breeding in horticultural cropsHeterosis breeding in horticultural crops
Heterosis breeding in horticultural crops9842611474
 
Amundsen, el explorador polar
Amundsen, el explorador polarAmundsen, el explorador polar
Amundsen, el explorador polarbibliobrozos
 
Leadership Lessons from Antarctic Expedition
Leadership Lessons from Antarctic ExpeditionLeadership Lessons from Antarctic Expedition
Leadership Lessons from Antarctic ExpeditionTathagat Varma
 
Types of Artificial Satellites
Types of Artificial SatellitesTypes of Artificial Satellites
Types of Artificial SatellitesPrashant Mahajan
 

Viewers also liked (20)

Emperor Asset Management: PE seminar 19 November 2013
Emperor Asset Management: PE seminar 19 November 2013Emperor Asset Management: PE seminar 19 November 2013
Emperor Asset Management: PE seminar 19 November 2013
 
Ernest shackleton
Ernest shackletonErnest shackleton
Ernest shackleton
 
Ernest shackleton courage project
Ernest shackleton courage projectErnest shackleton courage project
Ernest shackleton courage project
 
Ernest Shackleton
Ernest ShackletonErnest Shackleton
Ernest Shackleton
 
Antarctica
AntarcticaAntarctica
Antarctica
 
QNT 351 Final Exam Answers 2015 version
QNT 351 Final Exam Answers 2015 versionQNT 351 Final Exam Answers 2015 version
QNT 351 Final Exam Answers 2015 version
 
El tesoro más preciado de la herencia
El tesoro más preciado de la herenciaEl tesoro más preciado de la herencia
El tesoro más preciado de la herencia
 
chu de03-Nhom03
chu de03-Nhom03chu de03-Nhom03
chu de03-Nhom03
 
Shot List
Shot List Shot List
Shot List
 
Ppt hendrik du randt
Ppt hendrik du randtPpt hendrik du randt
Ppt hendrik du randt
 
Convención Marco sobre el Cambio Climático
Convención Marco sobre el Cambio ClimáticoConvención Marco sobre el Cambio Climático
Convención Marco sobre el Cambio Climático
 
Confusion INFOGRAPHIC
Confusion INFOGRAPHICConfusion INFOGRAPHIC
Confusion INFOGRAPHIC
 
Resume for Zymer Kurti
Resume for Zymer KurtiResume for Zymer Kurti
Resume for Zymer Kurti
 
Heterosis breeding in horticultural crops
Heterosis breeding in horticultural cropsHeterosis breeding in horticultural crops
Heterosis breeding in horticultural crops
 
Amundsen, el explorador polar
Amundsen, el explorador polarAmundsen, el explorador polar
Amundsen, el explorador polar
 
Leadership Lessons from Antarctic Expedition
Leadership Lessons from Antarctic ExpeditionLeadership Lessons from Antarctic Expedition
Leadership Lessons from Antarctic Expedition
 
Decision Making
Decision MakingDecision Making
Decision Making
 
Open Data / MyData
Open Data / MyDataOpen Data / MyData
Open Data / MyData
 
satellite launcher
satellite launchersatellite launcher
satellite launcher
 
Types of Artificial Satellites
Types of Artificial SatellitesTypes of Artificial Satellites
Types of Artificial Satellites
 

Similar to AlphaPy

Practical data science
Practical data sciencePractical data science
Practical data scienceDing Li
 
Guiding through a typical Machine Learning Pipeline
Guiding through a typical Machine Learning PipelineGuiding through a typical Machine Learning Pipeline
Guiding through a typical Machine Learning PipelineMichael Gerke
 
Apache Spark Machine Learning
Apache Spark Machine LearningApache Spark Machine Learning
Apache Spark Machine LearningPraveen Devarao
 
Revolutionise your Machine Learning Workflow using Scikit-Learn Pipelines
Revolutionise your Machine Learning Workflow using Scikit-Learn PipelinesRevolutionise your Machine Learning Workflow using Scikit-Learn Pipelines
Revolutionise your Machine Learning Workflow using Scikit-Learn PipelinesPhilip Goddard
 
Nose Dive into Apache Spark ML
Nose Dive into Apache Spark MLNose Dive into Apache Spark ML
Nose Dive into Apache Spark MLAhmet Bulut
 
PRETZEL: Opening the Black Box of Machine Learning Prediction Serving Systems
PRETZEL: Opening the Black Box of Machine Learning Prediction Serving SystemsPRETZEL: Opening the Black Box of Machine Learning Prediction Serving Systems
PRETZEL: Opening the Black Box of Machine Learning Prediction Serving SystemsNECST Lab @ Politecnico di Milano
 
Combining Machine Learning Frameworks with Apache Spark
Combining Machine Learning Frameworks with Apache SparkCombining Machine Learning Frameworks with Apache Spark
Combining Machine Learning Frameworks with Apache SparkDatabricks
 
Combining Machine Learning frameworks with Apache Spark
Combining Machine Learning frameworks with Apache SparkCombining Machine Learning frameworks with Apache Spark
Combining Machine Learning frameworks with Apache SparkDataWorks Summit/Hadoop Summit
 
Commercial features spss modules 12 june 2020
Commercial features spss modules 12 june 2020Commercial features spss modules 12 june 2020
Commercial features spss modules 12 june 2020Bianca Welgraaf
 
Kaggle Higgs Boson Machine Learning Challenge
Kaggle Higgs Boson Machine Learning ChallengeKaggle Higgs Boson Machine Learning Challenge
Kaggle Higgs Boson Machine Learning ChallengeBernard Ong
 
Presentación Oracle Database Migración consideraciones 10g/11g/12c
Presentación Oracle Database Migración consideraciones 10g/11g/12cPresentación Oracle Database Migración consideraciones 10g/11g/12c
Presentación Oracle Database Migración consideraciones 10g/11g/12cRonald Francisco Vargas Quesada
 
8th TUC Meeting - Tim Hegeman (TU Delft). Social Network Benchmark, Analytics...
8th TUC Meeting - Tim Hegeman (TU Delft). Social Network Benchmark, Analytics...8th TUC Meeting - Tim Hegeman (TU Delft). Social Network Benchmark, Analytics...
8th TUC Meeting - Tim Hegeman (TU Delft). Social Network Benchmark, Analytics...LDBC council
 
The Power of Auto ML and How Does it Work
The Power of Auto ML and How Does it WorkThe Power of Auto ML and How Does it Work
The Power of Auto ML and How Does it WorkIvo Andreev
 
Best Practices for Hyperparameter Tuning with MLflow
Best Practices for Hyperparameter Tuning with MLflowBest Practices for Hyperparameter Tuning with MLflow
Best Practices for Hyperparameter Tuning with MLflowDatabricks
 
General Tips for participating Kaggle Competitions
General Tips for participating Kaggle CompetitionsGeneral Tips for participating Kaggle Competitions
General Tips for participating Kaggle CompetitionsMark Peng
 
Spark SQL In Depth www.syedacademy.com
Spark SQL In Depth www.syedacademy.comSpark SQL In Depth www.syedacademy.com
Spark SQL In Depth www.syedacademy.comSyed Hadoop
 
Designing Distributed Machine Learning on Apache Spark
Designing Distributed Machine Learning on Apache SparkDesigning Distributed Machine Learning on Apache Spark
Designing Distributed Machine Learning on Apache SparkDatabricks
 
Building largescalepredictionsystemv1
Building largescalepredictionsystemv1Building largescalepredictionsystemv1
Building largescalepredictionsystemv1arthi v
 
Augmenting Machine Learning with Databricks Labs AutoML Toolkit
Augmenting Machine Learning with Databricks Labs AutoML ToolkitAugmenting Machine Learning with Databricks Labs AutoML Toolkit
Augmenting Machine Learning with Databricks Labs AutoML ToolkitDatabricks
 

Similar to AlphaPy (20)

Practical data science
Practical data sciencePractical data science
Practical data science
 
Guiding through a typical Machine Learning Pipeline
Guiding through a typical Machine Learning PipelineGuiding through a typical Machine Learning Pipeline
Guiding through a typical Machine Learning Pipeline
 
Apache Spark Machine Learning
Apache Spark Machine LearningApache Spark Machine Learning
Apache Spark Machine Learning
 
Revolutionise your Machine Learning Workflow using Scikit-Learn Pipelines
Revolutionise your Machine Learning Workflow using Scikit-Learn PipelinesRevolutionise your Machine Learning Workflow using Scikit-Learn Pipelines
Revolutionise your Machine Learning Workflow using Scikit-Learn Pipelines
 
Nose Dive into Apache Spark ML
Nose Dive into Apache Spark MLNose Dive into Apache Spark ML
Nose Dive into Apache Spark ML
 
Apache Spark MLlib
Apache Spark MLlib Apache Spark MLlib
Apache Spark MLlib
 
PRETZEL: Opening the Black Box of Machine Learning Prediction Serving Systems
PRETZEL: Opening the Black Box of Machine Learning Prediction Serving SystemsPRETZEL: Opening the Black Box of Machine Learning Prediction Serving Systems
PRETZEL: Opening the Black Box of Machine Learning Prediction Serving Systems
 
Combining Machine Learning Frameworks with Apache Spark
Combining Machine Learning Frameworks with Apache SparkCombining Machine Learning Frameworks with Apache Spark
Combining Machine Learning Frameworks with Apache Spark
 
Combining Machine Learning frameworks with Apache Spark
Combining Machine Learning frameworks with Apache SparkCombining Machine Learning frameworks with Apache Spark
Combining Machine Learning frameworks with Apache Spark
 
Commercial features spss modules 12 june 2020
Commercial features spss modules 12 june 2020Commercial features spss modules 12 june 2020
Commercial features spss modules 12 june 2020
 
Kaggle Higgs Boson Machine Learning Challenge
Kaggle Higgs Boson Machine Learning ChallengeKaggle Higgs Boson Machine Learning Challenge
Kaggle Higgs Boson Machine Learning Challenge
 
Presentación Oracle Database Migración consideraciones 10g/11g/12c
Presentación Oracle Database Migración consideraciones 10g/11g/12cPresentación Oracle Database Migración consideraciones 10g/11g/12c
Presentación Oracle Database Migración consideraciones 10g/11g/12c
 
8th TUC Meeting - Tim Hegeman (TU Delft). Social Network Benchmark, Analytics...
8th TUC Meeting - Tim Hegeman (TU Delft). Social Network Benchmark, Analytics...8th TUC Meeting - Tim Hegeman (TU Delft). Social Network Benchmark, Analytics...
8th TUC Meeting - Tim Hegeman (TU Delft). Social Network Benchmark, Analytics...
 
The Power of Auto ML and How Does it Work
The Power of Auto ML and How Does it WorkThe Power of Auto ML and How Does it Work
The Power of Auto ML and How Does it Work
 
Best Practices for Hyperparameter Tuning with MLflow
Best Practices for Hyperparameter Tuning with MLflowBest Practices for Hyperparameter Tuning with MLflow
Best Practices for Hyperparameter Tuning with MLflow
 
General Tips for participating Kaggle Competitions
General Tips for participating Kaggle CompetitionsGeneral Tips for participating Kaggle Competitions
General Tips for participating Kaggle Competitions
 
Spark SQL In Depth www.syedacademy.com
Spark SQL In Depth www.syedacademy.comSpark SQL In Depth www.syedacademy.com
Spark SQL In Depth www.syedacademy.com
 
Designing Distributed Machine Learning on Apache Spark
Designing Distributed Machine Learning on Apache SparkDesigning Distributed Machine Learning on Apache Spark
Designing Distributed Machine Learning on Apache Spark
 
Building largescalepredictionsystemv1
Building largescalepredictionsystemv1Building largescalepredictionsystemv1
Building largescalepredictionsystemv1
 
Augmenting Machine Learning with Databricks Labs AutoML Toolkit
Augmenting Machine Learning with Databricks Labs AutoML ToolkitAugmenting Machine Learning with Databricks Labs AutoML Toolkit
Augmenting Machine Learning with Databricks Labs AutoML Toolkit
 

AlphaPy

  • 1. AlphaPy A Data Science Pipeline in Python 1
  • 3. The Framework • The Model Pipeline is the common code that will generate a model for any classification or regression problem. • The Domain Pipeline is the code required to generate the training and test data; it transforms raw data from a feed or database into canonical form. • Both pipelines have configuration files using the YAML format. • The output of the whole process is a Model Object, which is persistent; it can be saved and loaded for analysis. 3
  • 6. Components • scikit-learn: machine learning in Python • pandas: Python data analysis library • NumPy: numerical computing package for Python • spark-sklearn: scikit-learn integration package for Spark • skflow: scikit-learn wrapper for Google TensorFlow • SciPy: scientific computing library for Python • imbalanced-learn: resampling techniques for imbalanced data sets • xgboost: scaleable and distributed gradient boosting 6
  • 7. Predictive Models • Binary Classification: Classify elements of a given set into two groups. • Multiclass Classification: Classify elements of a given set into greater than two or more groups. • Regression: Predict real values of a given set. 7
  • 8. Classification • AdaBoost • Extra Trees • Google TensorFlow • Gradient Boosting • K-Nearest Neighbors • Logistic Regression • Support Vector Machine (including Linear) • Naive Bayes (including Multinomial) • Radial Basis Functions • Random Forests • XGBoost Binary and Multiclass 8
  • 9. Regression • Extra Trees • Gradient Boosting • K-Nearest Neighbor • Linear Regression • Random Forests • XGBoost 9
  • 10. Data Sampling • Different techniques to handle unbalanced classes • Undersampling • Oversampling • Combined Sampling (SMOTE) • Ensemble Sampling 10
  • 11. Feature Engineering • Imputation • Row Statistics and Distributions • Clustering and PCA • Standard Scaling (e.g., mean-centering) • Interactions (n-way) • Treatments (see below) 11
  • 12. Treatments • Some features require special treatment, for example, a date column that is split into separate columns for month, day, and year. • Treatments are specified in the configuration file with the feature name, the treatment function, and its parameters. • In the following example, we apply a runs test to 6 features in the YAML file: 12
  • 15. Encoders • Factorization • One-Hot • Ordinal • Binary • Helmert Contrast • Sum Contrast • Polynomial Contrast • Backward Difference Contrast • Simple Hashing 15
  • 16. Feature Selection • Univariate selection based on the percentile of highest feature scores • Scoring functions for both classification and regression, e.g., ANOVA F-value or chi-squared statistic • Recursive Feature Elimination (RFE) with Cross- Validation (CV) with configurable scoring function and step size 16
  • 17. Grid Search • Full or Randomized Distributed Grid Search with subsampling (Spark if available) 17
  • 20. Model Evaluation • Metrics • Calibration Plot • Confusion Matrix • Learning Curve • ROC Curve 20
  • 26. Domains • A domain encapsulates functionality that operates on specific kinds of schema or subject matter. • The purpose of the Domain Pipeline is to prepare data for the Model Pipeline. For example, both market and sports data are time series data but must be structured differently for prediction. • Market data consist of standard primitives such as open, high, low, and close; the latter three are postdictive and cause data leakage. Leaders and laggards must be identified and possibly column-shifted, which is handled by the Model Pipeline. • Sports data are typically structured into a match or game format after gathering team and player data. 26
  • 27. Market Domain 1. Suppose we have five years of history for a group of stocks, each stock represented by rows of time series data on a daily basis. 2. We want to create a model that predicts whether or not a stock will generate a given return over the next n days, where n = the forecast period. 3. The goal is to generate canonical training and test data for the model pipeline, so we need to apply a series of transformations to the raw stock data. 27
  • 29. Feature Definition Language • Along with treatments, we defined a Feature Definition Language (FDL) that would make it easy for data scientists to define formulas and functions. • Features are applied to groups, so feature sets are uniformly applied across multiple frames. • The features are represented by variables, and these variables map to functions with parameters. 29
  • 30. FDL Example • Suppose we want to use the 50-day moving average (MA) in our model, as we believe that it has predictive power for a stock’s direction. • The moving average function ma has two parameters: a feature (column) name and a time period. • To apply the 50-day MA, we can simply join the function name with its parameters, separated by “_”, or ma_close_50. • If we want to use an alias, then we can define cma to be the equivalent of ma_close and get cma_50. 30
  • 31. Stock Pipeline Example • Develop a model to predict days with ranges that are greater than average. • We will use both random forests and gradient boosting. • Get daily data from Yahoo over the past few years to train our model. • Define technical analysis features with FDL. 31
  • 52. Results • We have identified some features that predict large- range days. This is important for determining whether or not to deploy an automated system on any given day. • Results are consistent across training and test data. • The learning curves show that results may improve with more data. 52
  • 53. Use Cases • AlphaPy was created based on experimentation with many Kaggle competitions, so it can generate models for any classification or regression problem. • AlphaPy has been designed to be a toolkit for all data scientists. • The AlphaPy framework has specific pipelines for creating market and sports models. 53