フィルターのクリア

how to convert a numeric variable into categorical variable in matlab

24 ビュー (過去 30 日間)
pavan sunder
pavan sunder 2016 年 10 月 12 日
編集済み: Guillaume 2016 年 10 月 12 日
i have a normalized numeric vector which ranges between -1 and +1. i want to use this as a response variable in my classification learner which requires conversion into a categorical variable. i would like to have 3 categories - < 0, 0-0.5, > 0.5. Kindly help me with a matlab code.

回答 (1 件)

Guillaume
Guillaume 2016 年 10 月 12 日
編集済み: Guillaume 2016 年 10 月 12 日
The first line of the documentation of categorical says: "To group numeric data into categories, use discretize." So:
x = rand(1, 20) * 2 - 1; %random numbers between -1 and 1
y = discretize(x, [-1 0 0.5 1], 'categorical')

カテゴリ

Help Center および File ExchangeClassification についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by