Problem using discretize function

6 views (last 30 days)
Muhammad Nouman Aqil
Muhammad Nouman Aqil on 26 Feb 2021
I have a column "Net Pickups" in a table which contains integers from about -100 to 100. I want to discretize it to create a categorical variable "Demand" such that:
· Net Pickups < 0: ‘Low’
· 0 <= Net Pickups < 15: ‘Medium’
· Net Pickups >= 15: ‘High’
However, I'm getting the error that my 'values' vector should have the same length as my number of bins i.e. 3. What am I doing wrong? Here's a ballpark of the code I think should be used
values = [min(trainData.NetPickups) 0 15 max(trainData.NetPickups)]
discretize(trainData.NetPickups,3,values,"categorical",{'Low','Medium','High'})

Answers (0)

Categories

Find more on Cell Arrays in Help Center and File Exchange

Products


Release

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!