如何针对数据挖掘过程对数据进行分类? [英] How do I categorize my data for a datamining procedure?

查看:168
本文介绍了如何针对数据挖掘过程对数据进行分类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 apriori 函数进行数据挖掘。此函数仅适用于分类数据,没有值,只有文本。我的数据集满足了这些要求,因为我有五个类别变量,没有数字值,只有文本(因此变量性别分为女性和男性)

I am doing a data mining procedure, using the apriori function. This function only works on categorical data, without values but only text. My dataset fulfills these requirements, as I have five categorial variables, without numerical values but only text (so the variable 'sex' is categorized into 'female' and 'male')

如果现在尝试使用 apriori()函数,则会出现以下错误:

If I now try the apriori() function, I get the following error:

apriori(data)

asMethod(object)中的错误

  column(s) 1, 2, 3, 4, 5 not logical or a factor. Use as.factor or categorize first.

尽管我的数据看起来是分类的,但R并没有得到它。例如,如何使用as.factor函数对数据进行正确分类,以便apriori函数起作用?

Although my data looks categorical, R does not get that it is. How do I use for instance the as.factor function to categorize my data properly, so that the apriori function works?

推荐答案

您可以将所有列转换为因子:

You can convert all your columns to a factor:

data <- sapply(data,as.factor)

这篇关于如何针对数据挖掘过程对数据进行分类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆