How do I train Xgboost classifier for ECG Signal data? I am testing https://www.physionet.org/challenge/2017/sources/ submission. 

I like one of the submission code, which use Xgboost to train the classifier. Training data is in .mat file which can be converted to csv format. 

In below code, I have pretrained model xgb.bin, using which I can test any input signal. But I Want to train the model using different data and create my own training model.

Here is the code which predicts class name for given input ecg file 

def predict(data):

    #data = io.loadmat(path)['val'][0]

    from numpy import genfromtxt
    data = genfromtxt('testdata/val.csv', delimiter=',')


    features_noise = np.zeros((5, ))

    snr, rr_num, var, fr, fr2 = find_noise_features(data)
    features_noise[0] = snr
    features_noise[1] = rr_num
    features_noise[2] = var
    features_noise[3] = fr
    features_noise[4] = fr2
    features = extract_basic_features(data, 30000)
    features = np.hstack((features, features_noise.reshape(1, -1)))

    mean_ = np.array([15.96300284066109753667, 0.00412371298595770857, 38811.34497233365254942328,
                      0.48050717744965593115, 0.14397582347542958736])
    scale_ = np.array([4.22917401559752281770, 0.00093664880988427878, 62350.76443798459513345733,
                       0.15396567666240373873, 0.07085474966801086349])
    features_noise -= mean_
    features_noise /= scale_

    prediction = 0
    if features_noise[0] &lt; -2.9:
        prediction = 3
    if features_noise[2] &gt; 6.0:
        prediction = 3
    if features_noise[3] &gt; 3.0:
        prediction = 3
    if features_noise[4] &lt; -2.0:
        prediction = 3

    bst = xgb.Booster({'nthread': 4})
    bst.load_model("xgb.bin")

    dfeatures = xgb.DMatrix(features)
    prediction_prob = bst.predict(dfeatures)
    prediction = np.argmax(prediction_prob)

    return prediction

def run(data): 
    prediction = predict(data)
    print(prediction)


I want to train this classifer using my own dataset. Above model is trained on https://www.physionet.org/challenge/2017/training2017.zip dataset. 

Looking at above code, do you have any clue how can I train the model using Xgboost. 

Here is my thought steps 


Calculate features for all training signal in zip file
Calculate feature_noise as it is in above code for all signals
Calculate dfeatures features for each signals (Should I calculate it for each signals or for all signal together)
Train dfeatures for all signals using Xgboost (How?)
Store the xgboost model


Is this correct steps to do?
I might be a little bit late to the party, but I did exactly what you need in the follow-up challenge of CinC2017, where our algorithm gained the 2nd best score on the hidden test set.
Our code is available at https://github.com/martinkropf/ecg-classification
Paper is available at https://iopscience.iop.org/article/10.1088/1361-6579/aae13e