function [ps]=chunk_cr(instances,labels,split_parts)
    %-----produces the parts for the cross validation training-----
    %       input:     instances: a mxn matrix of train data, with n being the
    %                  dimension(features)
    %                  labels: a nx1 vector of training targets (+1 or -1)
    %                  split_parts: the number of parts for cross validation
    %       output:    ps: the scaling factor for the train sample when
    %                  scaled to [-1,1]
    %     Vasilios Plakandaras, 2012 <email: vplakand@ierd.duth.gr> 
    sizes_data=size(instances);
    size_data=sizes_data(1);
    chunk_size=floor(size_data/split_parts);
    st=1:chunk_size:(size_data+1)-chunk_size;
    en=chunk_size:chunk_size:size_data;
    %-------produce the training parts--------
for n=1:1:split_parts;
%      [scale,ps]=mapminmax(instances');% scaling data to [-1,1]
%      instances=scale';
    test_data_chunk=instances(st(1,n):en(1,n),:);% choose the test sample
    test_label_chunk=labels(st(1,n):en(1,n));%choose the test targets
    dat=instances;
    lab=labels;
    dat((st(1,n):en(1,n)),:)=[];
    lab((st(1,n):en(1,n)),:)=[];
    train_data_chunk=dat;
    train_label_chunk=lab;
    mat_file=[num2str(n)];
    save(mat_file,'train_data_chunk','test_data_chunk','test_label_chunk','train_label_chunk');% save each part
end