推广 热搜: 收购ACF  石英加热管,  800  T型槽试验平台  深圳回收ACF  求购ACF  T型槽装配平台  回收ACF  求购日立ACF  T型槽地梁 

categorical 、categorical和numerical

   日期:2023-04-18     浏览:41    评论:0    
核心提示:MATLAB的Categorical数组8  Categorical数组 类别(categorical)数组是一种存储有限类别数据的数组类型。类别数组可以提供对非数值数据的高效存储以及操作,另外类别数

MATLAB的Categorical数组

8  Categorical数组

类别(categorical)数组是一种存储有限类别数据的数组类型。类别数组可以提供对非数值数据的高效存储以及操作,另外类别数组还保持了原有类别的名字,这样使用起来更加直观方便。类别数组可以和表(table)数据类型一起使用。

默认情况下,类别数组中包含的类别是没有顺序的。例如,一组离散的宠物类别{'dog' 'cat' 'bird'}是没有顺序的。所以MATLAB采用字母表顺序来对其进行排序,{'bird' 'cat' 'dog'}。顺序类别数组包含的类别是有顺序的,例如尺寸大小的类别{'***all', 'medium', 'large'}是具有顺序的。

【例3-55】 类别数组的创建。

本例为读者演示如何创建一个类别数组。用户可以使用categorical函数把数值数组、逻辑数组、字符串元胞数组或者已有的类别数组创建为类别数组。

首先创建一个新英格兰地区州名的一个元胞数组。

state ={'MA','ME','CT','VT','ME','NH','VT','MA','NH','CT','RI'};

之后将此元胞数组转换为类别数组。

state = categorical(state)

class(state)

state =

  Columns 1through 9

     MA      ME     CT      VT      ME     NH      VT      MA     NH

  Columns 10through 11

     CT      RI

ans =

categorical

通过categories函数可以列出类别数组中包含了哪些类别。

categories(state)

ans =

    'CT'

    'MA'

    'ME'

    'NH'

    'RI'

    'VT'

从结果可以看到,所有的类别是按照字母顺序来排序的。

【例3-56】 顺序类别数组的创建。

创建一个记录物体尺寸大小的元胞数组:

AllSizes ={'medium','large','***all','***all','medium',...

           'large','medium','***all'};

这个元胞数组有三种尺寸,'large'、'medium'和'***all'。如果使用元胞数组进行记录的话,那么是没有一种方便的形式来表示***all medium large这种大小关系的。使用valueset变量用来指明顺序的大小,在调用categorical函数时对顺序参数进行设置就可以实现顺序类别数组的创建。

valueset = {'***all','medium','large'};

sizeOrd =categorical(AllSizes,valueset,'Ordinal',true)

sizeOrd =

  Columns 1through 6

    medium      large      ***all     ***all      medium      large

  Columns 7through 8

    medium      ***all

class(sizeOrd)            %查看创建数组的类型

ans =

categorical

类别数组中的顺序,sizeOrd,是保持不变的。同样适用categories函数列出所有类别:

categories(sizeOrd)

ans =

    '***all'

    'medium'

    'large'

这时,所有类别的列举就不是再按照字母顺序了,而是按照用户定义的***allmediumlarge顺序来列举的。

创建100各1-44之间的整数向量:

x = gallery('integerdata',44,[100,1],1);

然后使用histc函数创建3个箱子,将x中的数值在1-15之间的放进***个箱子,15-30之间的放在第二个箱子,30-45之间的数值放进第三个箱子。分界点15和30会归入第而2和第三各箱子。

[~,bin] = histc(x,[1,15,30,45]);

Bin是一个100×1的向量,用来表示x中的每一个向量是属于哪个箱子的。创建一个顺序类别数组,sizeOrd2,其中三个箱子变成了三个类别,***all、medium和large。

valueset = 1:3;

catnames = {'***all','medium','large'};

sizeOrd2 =categorical(bin,valueset,catnames,'Ordinal',true);

sizeOrd2是一个100×1的顺序类别数组,它有三个类别***allmediumlarge。

使用summary函数可以对类别进行求和

summary(sizeOrd2)

    ***all       33

    medium      36

    large       31

通过结果可以看出,有33个元素是属于***all这个类别的,36个是属于medium这个类别的,31个是属于large这个类别的。

【例3-57】 类别数组元素的比较。

首先由一个字符串元胞数组来创建类别数组。

C = {'blue' 'red' 'green' 'blue';...

'blue' 'green' 'green' 'blue'};             %创建测试元胞数组

colors = categorical(C)                     % 转换为类别数组

colors =

    blue      red        green      blue

    blue      green      green     blue

这里我们创建了2×4的类别数组。然后可以通过categories函数查看数组中有哪些类别。

categories(colors)

ans =

    'blue'

    'green'

    'red'

然后我们可以使用“==”来比较数组***行元素是否和第二行元素相等。

colors(1,:) == colors(2,:)

ans =

     1     0    1     1

从结果可以看出,只有第二列的两个元素不相等。

我们还可以把整个类别数组colors和单一字符串’blue’来对比:

colors == 'blue'

ans =

     1     0    0     1

     1     0    0     1

结果显示在colors数组中一共有4个blue。

通过指定颜色的顺序,我们可以将colors转换为顺序类别数组。例如指定顺序为redgreenblue。

colors = categorical(colors,{'red','green''blue'},'Ordinal',true)

colors =

    blue      red        green      blue

    blue      green      green     blue

类别数组中的各元素和转换之前是相同的,检验一下数组中有哪些类别:

categories(colors)

ans =

    'red'

    'green'

    'blue'

在设置了顺序之后,就可以对各元素的顺序进行比较。例如比较***列的元素是否比第二列的元素大:

colors(:,1) colors(:,2)

ans =

     1

     1

第二列中的元素是red和green,按照设定的顺序都比***列中的blue小,所以均返回了1(true)。

用户还可以查找所有比blue小的元素:

colors 'blue'

ans =

     0     1    1     0

     0     1    1     0

返回结果中为1的元素就是比blue小的元素。

【例3-58】 类别数组元素的组合。

首先创建测试数组,记录的是一个班25名学生午餐饮料是什么。

A = gallery('integerdata',3,[25,1],1);

A = categorical(A,1:3,{'milk' 'water''juice'});

然后对类别数组A进行统计:

summary(A)

    milk       8

    water      8

    juice      9

从结果可以看出有8名学生喜欢喝牛奶,8名学生喜欢水,还有9名学生喜欢果汁。

创建另一个类别数组,用以表示另一个班28人的午餐饮料情况。

B = gallery('integerdata',3,[28,1],3);

B = categorical(B,1:3,{'milk' 'water''juice'});

B是一个28×1的和A具有相同类别的数组。对数组B进行统计:

summary(B)

    milk       12

    water      10

    juice       6

从结果可以看出有12名学生喜欢喝牛奶,10名学生喜欢水,还有6名学生喜欢果汁。

有了两个类别数组之后,我们可以将其组合成为一个新的数组。

Group1 = [A;B];           % 组合的方法和普通数值矩阵相同

对总的类别数组Group1进行统计:

summary(Group1)

    milk       20

    water      18

    juice      15

Group1是一个53×1的类别数组,包含3个类别:milk,water和juice。

现在我们创建一个新的包含50个学生的类别数组,可选的饮料增加了苏打水。

Group2 =gallery('integerdata',4,[50,1],2);

Group2 = categorical(Group2,1:4,{'juice''milk' 'soda' 'water'});

对Group2进行统计:

summary(Group2)

    juice      18

    milk       10

    soda       13

    water       9

Group2是一个50×1的数组,有4个类别:juice,milk,soda和water.

将Group1和Group2组合:

students = [Group1;Group2];

对新建的总数组进行统计:

summary(students)

    milk       30

    water      27

    juice      33

    soda       13

可见结果中的数组有4个类别。下面使用reordercats来更改数组中的类别排列顺序:

students =reordercats(students,{'juice','milk','water','soda'});

categories(students)      % 查看有哪些类别

ans =

    'juice'

    'milk'

    'water'

    'soda'

分类的英语短语

分类,是指按照种类、等级或性质分别归类。下面就由我为大家带来关于分类的 英语 短语 集锦,希望大家能有所收获。

关于分类的相关短语

分类比较器 sorter comparator;

分类表 classification chart;

分类参数 sorting parameter;

分类操作 sort operation;

分类程序 sorter; sort program;

分类程序模块 sort module;

分类存储器 sorting memory;

分类单位 taxonomical unit; taxon; taxa;

分类单元 taxon (pl. taxa);

分类电话簿 classified telephone directory; yellow pages;

分类电路 sorting circuit;

分类定货 group order;

分类法 classification;

分类 方法 sorting technique;

分类符 classifier; specificator;

分类符号 class symbol;

分类 广告 classified advertisement; classifieds;

分类工 作文 件 sort work file;

分类功能 模块 sort module;

分类关键 {自} sort key;

分类规 classification g***ge;

分类归并 sort merge;

分类过程 assorting process;

分类号码 class number;

分类合并 sorting and merging;

分类机 sequencer; sorter;

分类记录 book of final entry;

分类架 box; slot;

分类键 sort key;

分类交配 assortative mating;

分类阶段 {计} sorting phase;

分类阶元 taxonomic category;

分类进食 dissociate diet;

分类空间 classifying space; categorical space;

分类控制键 sort control key;

分类控制设备 segregating control equipment;

分类类目 series;

分类力学 sort mechanics;

分类量 sort capacity;

分类命题 categorical proposition;

分类模块 sort module;

分类目录 split catalogue; classified catalogue;

分类排列法 classified shelt arrangement;

分类平衡法 sort balance;

分类平衡器 {讯} ledger balance;

分类器 grader; sorter;

分类群 taxon;

分类 日记 簿 journal d*** book;

分类筛 classifying screen;

分类声纳 classification sonar;

分类生产法 multiline production;

分类生成程序 sort generator;

分类试验 class test;

分类树形结构 sort tree structure;

分类数据 categorical data;

分类说明 classification declaration;

分类算法 sorting algorithm;

分类随机抽样 random sampling by classification;

分类索引 classified index [subject index];

分类台 assorting table;

分类条件 class condition;

分类文件 sort file;

分类文件描述项 sort file description entry;

分类系列 {生} taxonomic series;

分类系统 categorizing [taxonomic] system;

分类细账 breakdown;

分类向量 class vector;

分类效率***化 optimizing sort performance;

分类信息 category message;

分类信息组 split field;

分类性状 taxonomic character;

分类应用 sort application;

分类语句 sort statement; specification statement;

分类语言学 taxonomic linguistics;

分类阅读机 sorter reader;

分类轧钢机 section steel rolling mill;

分类账 ledger; financial record; journal;

分类账簿 ledger;

分类折旧法 group depreciation method; (典型示范)

分类指导 demonstration by example or guidance to different types of areas;

分类主义 taxonomi***;

分类专业小组 cut house(石油工厂的);

分类装置 sorter;

分类状况 assortment;

分类资料 grouped data;

分类子句 {计} class cl***se;

分类总数 batch total;

分类组合 sort merge

关于分类的相关短句

(使分别归类) classify; itemize; sort:

classify accidents by c***se;

根据起因将事故分类

classify by sex [age; nationality; locality];

根据性别[年龄; 民族; 地区]分类

Men in the post office classify mail according to places it is to go.

邮局里的人员将信件按寄送地点分类。

They are classified in sorts.

它们是按品种分类的。

(分门别类) classification; assortment; systematization; partition; sorting; taxonomy; breakdown:

a broad classification;

粗略的分类

systematize classification;

使分类系统化

classification of plants

植物的分类

关于分类的相关例句

1. I furnished my first apartment with items from the want ads.

我从分类广告上购置物品,布置了我的***间公寓。

2. The information was not easily classifiable.

此信息不易分类。

3. The books in the library are classified according to subject.

图书馆的书按学科分类。

4. The ledgers and account books had all been destroyed.

分类账本和账簿都被销毁了.

5. He posted up the export sales.

他把外销账过到分类账上.

6. Scientists divide animals, plants and rocks into classes.

科学家把动物 、 植物和矿物分类.

7. Class the books in this category.

按目录把书分类.

8. He grouped students according to ability.

他按能力把学生们分类.

9. Range the books by size.

把这些书按大小分类排列.

10. The sale***an sorted his new consignment of stockings.

推销员把新到的一批长袜清理分类.

11. A greater refinement of the categorization is possible.

进行更加精细的分类是可能的.

12. He glanced his eyes down the classified advertisements.

他浏览了一下分类广告.

13. Librarians spend a lot of time classifying books.

图书馆工作人员花许多时间将书分类.

14. They are classified in sorts.

它们是按品种分类的.

15. Your best hope of obtaining a copy is to place an advert in the classifieds.

要想搞到这本书,你***在分类广告栏刊登个广告。

categorical是什么意思

categorical

[英][ˌkætəˈgɒrɪkl][美][ˌkætəˈgɔ:rɪkl]

adj.绝对的,无条件的; 分类的,按类别的; 断言的; 确信无疑的;

例句:

1.

And sure, in 1973 miller v. california pulled *** out of the categoricalforcefield of free speech.

理所当然地,在1973年***法院对miller v california这个案子的判决中,色情文学从明确的言论自由中被剔除。

2.

The problem of kant's categorical imperative is how to behave well in a worldin which others do not.

康德定然律令(categorical imperative)的问题在于,如何在一个其他人行止不端的世界里保持懿行。

category的形容词和副词

category的形容词:categorical;副词:categorically

category 读法 英 [ˈkætəɡəri]  美 [ˈkætəɡɔːri]

n. 种类,范畴

[ 复数 categories ]

短语:

first category ***纲

category theory 范畴论

category management 品类管理;类别管理

词义辨析:

kind,sort,type,class,classification,category这些名词均有“种、类、类型”之意。

kind指性质相同,而且特征很相似,足以归为一类的人或东西。

sort普通用词,文体较kind随便,指对人或对事物进行的大概分类,有时含贬义。

type指客观界限比较清楚,有相同本质特点的同类事物,或指大致相似的同类事物。

class正式用词,指门类、种类或优劣等级;用于指动植物的分类时,表示“纲”。

classification指根据已经确定的类型对某一事物作鉴别和归类。

category书面用词,特指有确切定义的群体。

关于categorical和categorical和numerical的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。

原文链接:http://www.souke.org/news/show-40315.html,转载和复制请保留此链接。
以上就是关于categorical 、categorical和numerical全部的内容,关注我们,带您了解更多相关内容。
 
标签: 数组 类别 顺序
打赏
 
更多>同类资讯
0相关评论

推荐资讯
网站首页  |  VIP套餐介绍  |  关于我们  |  联系方式  |  使用协议  |  版权隐私  |  SITEMAPS  |  网站地图  |  排名推广  |  广告服务  |  积分换礼  |  网站留言  |  RSS订阅  |  违规举报