title: How can I split the data in 40% training, 30% validation and 30% test
body: <p>This is what I coded. I am able to create the permutation and create the three variables that I need training, validation and test. I can't just figure out how to split the data in the percentages mentioned above. In few words, when I create those variables they should be created accordingly and then have to print the result. Thanks in advance</p>
  <pre><code>def split_data(data_dict, data_split):
      &quot;&quot;&quot;divide the data into training, validate and test sets. 
      :param data_dict: a dictionary of the data with keys 'X' and 'Y'
      :param data_split: a list of the fraction of the data to be in each set of form 
      [training_fraction, validation_fraction, test_fraction]. The fractions should all add up to 1.
      :returns training_dict, validation_dict, test_dict: dictionaries of the same form as the data_dict, 
      containing the different sets&quot;&quot;&quot;
      
      assert np.sum(data_split)-1 &lt; 0.01
      
      # work out how many datapoints will be in the train and validation sets 
      n_train = int(len((data_dict['X']))*data_split[0])
      n_validate = int(len((data_dict['X']))*data_split[1])
      
      # generate a random permutation of indices of the data and split into training, validation and test
      perm = np.random.permutation(range(len(data_dict['X'])))
      indices_train, indices_validate, indices_test = np.split(perm, [n_train, n_train+ n_validate])
      
      # create training, validation and test dictionaries 
      training_dict = {'X': data['X'][indices_train], 'Y': data['Y'][indices_train]}
      validation_dict = {'X': data['X'][indices_validate], 'Y': data['Y'][indices_validate]}
      test_dict = {'X': data['X'][indices_test], 'Y': data['Y'][indices_test]}
      
      return training_dict, validation_dict, test_dict
  </code></pre>