File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed
lib/ML/SparseMatrixRecommender Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -56,16 +56,17 @@ our sub convert-to-wide-form(
5656our sub categorize-to-intervals (
5757 @ vec ,
5858 : $ breaks is copy = Whatever ,
59- : $ probs is copy = Whatever ,
60- Bool : $ interval-names = False ) returns List {
59+ : probabilities(: $ probs ) is copy = Whatever ,
60+ Bool : $ interval-names = False ,
61+ Bool : D : p(: $ pairs ) = False ) {
6162 # Validate input vector
6263 die " The first argument is expected to be an array of numeric values."
6364 unless @ vec . all ~~ Numeric : D ;
6465
6566 # Handle probabilities
6667 my @ mprobs = do if $ probs . isa (Whatever ) {
6768 (^ 11 ) >>/>> 10 ;
68- } elsif $ probs ~~ (Array : D | List : D | Seq : D ) && $ probs . all ~~ Numeric : D {
69+ } elsif $ probs ~~ (Array : D | List : D | Seq : D ) && $ probs . all ~~ Numeric : D && ([ && ] | $ probs . map ( 0 ≤ * ≤1)) {
6970 $ probs . unique . sort
7071 } else {
7172 die ' The $probs argument is expected to be a list of probabilities or Whatever.'
@@ -97,5 +98,5 @@ our sub categorize-to-intervals(
9798 }
9899 }
99100
100- return @ res ;
101+ return $ pairs ?? ( @ vec Z => @ res ) !! @ res ;
101102}
You can’t perform that action at this time.
0 commit comments