I have a data that looks like this
#Status value
TP 5.000
TP 3.000
TP 3.000
TN 10.000
TP 2.000
TP 9.000
TN 1.000
TP 9.000
TN 1.000
What we want to do is to cluster the Status based on the given interval in value.
Let that interval be 1-3, 4-6, 7-9, 10-12, etc .. (i.e. Bin size 3).
We hope to get the hash of array like this:
my %hoa = (
'1-3' => [TP,TP,TP,TN,TN],
'4-6' => [TP],
'7-9' => [TP,TP],
'10-12' => [TN]);
What’s the way to achieve that?
Update: Corrected the HoA for 7-9, thanks to ysth.
Abstracting away the code to determine interval:
(which gets two TPs for 7-9, not one as you show).