Home>

It is necessary to implement a Kfold scheme with five folds. Divide the data into 5 folds and iterate over them: 4 training folds each to calculate the average target values ​​by item_id and these values ​​must be filled in the validation fold at each iteration.

df= pd.DataFrame ({'item_id': [19, 27, 28, 29, 32],
                   'target': [0.0, 0.0, 6.0, 3.0, 1.0],
                  'item_target_enc': [0.0222, 0.056834, 0.141176, 0.037383, 1.319042]})
# You will need to compute correlation like that
corr= np.corrcoef (all_data ['target']. values, encoded_feature) [0] [1]
print (corr)

Expected Response: 0.4165

How can this be done with the map function?

Thank you!

Please clarify the essence of the question. The question is how to iterate over folds?

MaxU2021-10-13 10:29:24

Yes, this is exactly what I do not understand

Panda2021-10-13 11:53:38