Machine Learning Platform for Accelerator Controls Yusi Qiao

  • Slides: 26
Download presentation
Machine Learning Platform for Accelerator Controls Yusi Qiao, Ph. D Student Supervisor: Chungming Paul

Machine Learning Platform for Accelerator Controls Yusi Qiao, Ph. D Student Supervisor: Chungming Paul Chu Accelerator Performance and Concepts Workshop Institute of High Energy Physics Chinese Academy of Sciences

Outline n Study Background n Platform Architecture n n Data export & uniform Data

Outline n Study Background n Platform Architecture n n Data export & uniform Data pre-processing General algorithms & Training result visibility Possible applications n Summary

Study Background Accelerator Application Architecture n n Artificial intelligence (AI) & machine learning (ML)

Study Background Accelerator Application Architecture n n Artificial intelligence (AI) & machine learning (ML) High doorstep for some physicists Standard format & popular algorithms Simple APIs to cut development time C. P. Chu et al. IPAC 2018

Platform Architecture

Platform Architecture

Data Export & Uniform Data Sources n n n EPICS live data TXT/Excel Files

Data Export & Uniform Data Sources n n n EPICS live data TXT/Excel Files EPICS Channel Archiver EPISC Archiver Appliance Other data sources Code Snippet Output Data Format n Pandas Data. Frame n TXT/Excel Files n Other format: HDFS pvnames=['BIBPM: R 1 OBPM 02: XPOS', 'BIBPM: R 1 OBPM 03: XPOS', 'BIBPM: R 1 OBPM 04: XPOS] #also can load pvnames from files engine=Load. Data. get. Key(server_addr, pvnames) data=Load. Data. get. Format. Chan. Arch(server_addr, engine, pvnames, start_time='11/30/2018 14: 15: 00’, end_time='11/30/2018 14: 16: 00’, merge_type='outer’, interpolation_type='linear’, fillna_type=None, how=0)

Data Export & Uniform Raw data characteristics n Large amount of PVs as model

Data Export & Uniform Raw data characteristics n Large amount of PVs as model features n Different PV has different acquisition period n Handling null or abnormal data Data Merging Timestamp Alignment Data Uniform Pandas Data. Frame

Data Export & Uniform For temporal data from archiver PV Timestamp alignment 3 merge

Data Export & Uniform For temporal data from archiver PV Timestamp alignment 3 merge types: 1. Outer -> smallest time period -> data addition 2. Inner -> biggest time period -> data deletion 3. Defined time period -> data addition & deletion

Data Export & Uniform Data uniform n n Standardization Normalization Discretization (quantization or binning)

Data Export & Uniform Data uniform n n Standardization Normalization Discretization (quantization or binning) Encoding categorical features

Data Pre-processing Data quality examine Handling empty, abnormal, inconsistent data n Padding Not changing

Data Pre-processing Data quality examine Handling empty, abnormal, inconsistent data n Padding Not changing over time Bad machine status n Interpolation Linear, nearest, polynomial, cubic, spline…… n Neural network Predict the unknown data through NN algorithm based on known data

Data Pre-processing n Data feature analysis n Diagnostic function n distribution analysis n common

Data Pre-processing n Data feature analysis n Diagnostic function n distribution analysis n common statistical indicators n comparative analysis n histograms n periodic analysis n scatter matrix diagrams n contribution analysis n correlation tables & n correlation analysis associated heat maps n box plots

Data Pre-processing Code Snippet diabetes = datasets. load_iris() data=Load. Data. dataset 2 df(diabetes) Display.

Data Pre-processing Code Snippet diabetes = datasets. load_iris() data=Load. Data. dataset 2 df(diabetes) Display. Data. show. Statistic(data) Display. Data. show. Bins(data) Display. Data. show. Plot(data) Display. Data. show. Corr. Map(data) Display. Data. show. SPLOM_G(data) iris dataset Classes Samples per class Samples total Dimensionality Features 3 50 150 4 real, positive

Data Pre-processing Scatterplot matrix Correlation heat map Bin plot Density plot matrix

Data Pre-processing Scatterplot matrix Correlation heat map Bin plot Density plot matrix

General Algorithms scikit-learn Machine Learning in Python n Simple and efficient tool for data

General Algorithms scikit-learn Machine Learning in Python n Simple and efficient tool for data mining & data analysis n Built on Num. Py, Sci. Py, and matplotlib n Open source, commercially usable - BSD license

Possible Applications n Accelerator facilities monitor Use accelerator running database and classification algorithms to

Possible Applications n Accelerator facilities monitor Use accelerator running database and classification algorithms to monitor the status of equipment. n Facilities optimization Use regression algorithms to improve the performance of key system of accelerator, such as high frequency cavity, superconducting system, water cooling system, etc. n Physical optimization Apply the machine learning platform to accelerator physical optimization progress, to realize the automatic optimization of DA, emittance, current intensity, etc. Dengjie Xiao (Ph. D, IHEP)

General Algorithms Regression Predicting a continuous-valued attribute associated with an object. n Linear Regression

General Algorithms Regression Predicting a continuous-valued attribute associated with an object. n Linear Regression n Bayesian Linear Regression n Polynomial Regression n maintains the generally fast performance of linear methods, while allowing them to fit a much wider range of data

General Algorithms Decision Tree non-parametric supervised learning method used for classification and regression. n

General Algorithms Decision Tree non-parametric supervised learning method used for classification and regression. n Advantages n Simple to understand to interpret n Requires little data preparation n Able to handle both numerical and categorical data Code Snippet iris = datasets. load_iris() data=Load. Data. dataset 2 df(iris) X_train, X_test, y_train, y_test =Train. Data. split_data(data, 'target') pred, score=Train. Data. MLDecision. Trees_testmodel( X_train, X_test, y_train, y_test, max_depth=2) Display. Data. plot_predict(y_test, pred, title='score: %f' % score)

General Algorithms K-Nearest Neighbors Supervised neighbors-based learning comes in two flavors: classification for data

General Algorithms K-Nearest Neighbors Supervised neighbors-based learning comes in two flavors: classification for data with discrete labels, and regression for data with continuous labels. n Nearest Neighbors Classification n instance-based learning n computed from a simple majority vote of the nearest neighbors of each point Code Snippet iris = datasets. load_iris() data=Load. Data. dataset 2 df(iris) Train. Data. MLKNN_classification(data, ’target’, k=15, weights=‘distance’)

General Algorithms Multi-layer Perceptron Advantages: Neural network models (supervised) Capability to learn non-linear models

General Algorithms Multi-layer Perceptron Advantages: Neural network models (supervised) Capability to learn non-linear models Capability to learn models in real-time (on-line learning) Disadvantages: Different random weight initializations can lead to different validation accuracy n requires tuning a number of hyperparameters such as the number of hidden neurons, layers, and iterations n sensitive to feature scaling n n n

General Algorithms Clustering Automatic grouping of unlabeled data into sets. n K-Means n scales

General Algorithms Clustering Automatic grouping of unlabeled data into sets. n K-Means n scales well to large number of samples n requires the number of clusters to be specified Code Snippet iris = datasets. load_iris() data=Load. Data. dataset 2 df(iris) feature_pv 1='sepal length (cm)' feature_pv 2="sepal width (cm)" Train. Data. MLKMeans(data, feature_pv 1, feature_pv 2, cluster=2)

General Algorithms Clustering Automatic grouping of unlabeled data into sets. n DBSCAN n views

General Algorithms Clustering Automatic grouping of unlabeled data into sets. n DBSCAN n views clusters as areas of high density separated by areas of low density n core samples: eps + min_samples Code Snippet iris = datasets. load_iris() data=Load. Data. dataset 2 df(iris) target_pv="target" Train. Data. MLDBSCAN(data, target_pv, eps=0. 5, min_samples=10)

General Algorithms Model selection and evaluation n Cross-validation evaluating estimator performance n K-fold divides

General Algorithms Model selection and evaluation n Cross-validation evaluating estimator performance n K-fold divides all the samples in groups of samples. The prediction function is learned using folds, and the fold left out is used for test. n avoid overfitting & not waste too much data

General Algorithms Model selection and evaluation n Model evaluation quantifying the quality of predictions

General Algorithms Model selection and evaluation n Model evaluation quantifying the quality of predictions n scoring parameter n for the most common use cases n higher return values are better than lower return values

General Algorithms Scoring Classification ‘accuracy’ ‘balanced_accuracy’ ‘average_precision’ ‘brier_score_loss’ ‘f 1_micro’ ‘f 1_macro’ ‘f 1_weighted’

General Algorithms Scoring Classification ‘accuracy’ ‘balanced_accuracy’ ‘average_precision’ ‘brier_score_loss’ ‘f 1_micro’ ‘f 1_macro’ ‘f 1_weighted’ ‘f 1_samples’ ‘neg_loss’ ‘precision’ etc. ‘recall’ etc. ‘roc_auc’ Clustering ‘adjusted_mutual_info_score’ ‘adjusted_rand_score’ ‘completeness_score’ ‘fowlkes_mallows_score’ ‘homogeneity_score’ ‘mutual_info_score’ ‘normalized_mutual_info_score’ ‘v_measure_score’ Regression ‘explained_variance’ ‘neg_mean_absolute_error’ ‘neg_mean_squared_log_error’ ‘neg_median_absolute_error’ ‘r 2’ Function metrics. accuracy_score metrics. balanced_accuracy_score metrics. average_precision_score metrics. brier_score_loss metrics. f 1_score metrics. log_loss metrics. precision_score metrics. recall_score metrics. roc_auc_score metrics. adjusted_mutual_info_score metrics. adjusted_rand_score metrics. completeness_score metrics. fowlkes_mallows_score metrics. homogeneity_score metrics. mutual_info_score metrics. normalized_mutual_info_score metrics. v_measure_score metrics. explained_variance_score metrics. mean_absolute_error metrics. mean_squared_log_error metrics. median_absolute_error metrics. r 2_score

Summary n Better data export, normalization & preparation steps n Simplify development of ML

Summary n Better data export, normalization & preparation steps n Simplify development of ML applications n Simple visualization plots and common algorithms for primary tryout n Efficient tool for data exploration and knowledge extraction n Physics experts need to define the subjects or problems More functions to be added! Better APIs after users’ feedback! More and more applications to be explored!

Team leader: C. P. Chu Team members: Dengjie Xiao, Yu Bai, Jinyu Wan, Sinong

Team leader: C. P. Chu Team members: Dengjie Xiao, Yu Bai, Jinyu Wan, Sinong Cheng, Fang Liu Contact E-mail: qiaoys@ihep. ac. cn

Backup Slides BPM Status Prediction For test purpose, we applied BEPC-II(Beijing Electron Positron Collider

Backup Slides BPM Status Prediction For test purpose, we applied BEPC-II(Beijing Electron Positron Collider II) BPM history data(collider state, 3 months) to SVM(Support Vector Machine) regression algorithm to predict the status.