Icon

03. Advanced Machine Learning Chemistry - solution

Advanced Machine Learning - Chemistry Solution

Solution to the "Advanced Machine Learning Chemistry" exercise for the advanced Life Science User Training
- Training a Random Forest model to predict a nominal target column
- Evaluating the performance of a classification model
- Optimizing parameters of the Random Forest model
- Performing the classification multiple times in a cross validation loop


Annotations and comments
  • Machine Learning This workflow demonstrates Model Building for a bioactivity data set with Random Forest learner and binary fingerprints. The data set represents a subset of 844 compounds evaluated for activity against CDPK1. 181 compounds inhibited CDPK1 with IC50 below 1uM and have "active" as their class. More information is available https://www.ebi.ac.uk/chemblntd/#tcams_dataset. See Set 19.
  • Activity I: Random Forest - Partition the activity data after the RDKit Fingerprint node into training and test set (Stratified Sampling). - Train a random forest on the training set to predict activity. - Use the trained model to predict the activity on the test set. - Evaluate the quality of a model with the Scorer node.
  • Step 1. Read training data: TCAMS_CDPK1 _subset_ML.table
  • Step 2. Compute Morgan fingerprints with radius 2 using RDKit Fingerprint node. Hint: Check Advanced tab
  • Step 3. Split data into training and test sets using Partitioning node. Make sure to perform stratified sampling.
  • Step 4. Build model using Random Forest Learner node and check its performance on the test set with Random Forest Predictor node.
  • Step 5. Collect statistics for training and test sets using Scorer nodes.
  • Activity II: Parameter Optimization - Add a parameter optimization loop to your model training process - Use Hillclimbing to determine the optimum number of models (min=10, max=200, step=10, int = yes) - Use maximum accuracy as the objective value - What is the best number of models? (Hint: don't forget to use the flow variable in the Random Forest Learner node)
  • Step 1. Use the Parameter Optimization Loop Start node with Hillclimbing to determine the optimum number of models (min=10, max=200, step=10, int=yes) Name the Parameter: nr_models
  • Step 2. Connect the upper output port of the Partitioning Node with the Random Forest Learner node. Connect the Flow Variable to the Random Forest Learner node and assign your Flow Variable to the nrModels in the Flow Variable Tab. Use the Random Forest Predictor node to predict your test data.
  • Step 3. Use the Scorer node to evaluate your model. First Column is "activity" and second column is "Prediction(activity)". Connect the Flow Variable port of the Scorer node to the Parameter Optimization Loop End node and choose the objective function value "accuracy".
  • Step 4. Connect the upper output port of the Parameter Optimization Loop End with the upper input port of the component Run Best Model + Scorer View. Connect the upper output port of the Partitioning node with the middle input port of the component Run Best Model + Scorer View. Connect the lower output port of the Partitioning node with the lower input port of the component Run Best Model + Scorer View.
  • Activity III: Cross Validation - Create a 10-fold cross validation for your model - Take a look at the error rates produced by the different iterations. Does the model seem stable?
  • Step 1. Use the X-Partitioner node with 10 validation sets and using stratified sampling based on the activity column.
  • Step 2. Use the Random Forest Learner node to train your model. Use the Random Forest Predictor node to predict your test data.
  • Step 3. Use the X-Aggregator node to close your loop. Use the Box Plot node to evaluate your model. Connect the lower output port of the X-Aggregator node with the Box Plot node and select the "Error in %" Column.
  • Numeric sentiment scores
  • exclude Sentiment Rating and Web Activity
  • exclude CustomerKey and Sentiment Analysis
  • New Web Data
  • Old Web data
  • WebActivity
  • Remove duplicate rows
  • Products <-> CustomerKey
  • Demographics and History from SAS file
  • Sentiment Rating + Sentiment Description
  • CustomerKey, sentiment rating, sentiment rating in text, Products
  • add WebActivity
  • add demographics and history
  • Remove row when numeric missing
  • External Model
  • WebActivity.sqlite
  • Sentiment Evaluation from KNIME
  • Collect Accuracy
  • Define Parameters
  • TCAMS_CDPK1_subset_ML.table

Nodes

Extensions

Links