R:关于不先验误差能够强制NA对nsparseMatrix [英] R: apriori error about not able to coerce NA's to nsparseMatrix

查看:197
本文介绍了R:关于不先验误差能够强制NA对nsparseMatrix的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我跟在arules包先验算法试验。

这是我做了什么:
我装从SQL Server视图为R.
由于该数据是不是在交易形式(先验使用),我不得不将其转换:


  

&数据LT; - sapply(订单,as.factor)


然后我进入先验功能:


  

先验(数据,参数=列表(支持= 0.005,置信度= 0.5))


我得到这个错误:


  

    

错误吨(如下(从ngCMatrix)):错误评估在选择功能'T'的方法参数的x:在asMethod(对象)错误:不能强迫'NA对nsparseMatrix


  

我的查询检查,我甚至不具有为NULL任何属性/ NA。

我不明白是什么错误意味着。是否有人知道是什么问题,以及如何解决这个问题?


解决方案

我最近遇到了同样类型的错误。我所了解到的是,您的数据必须被强制转换为交易开采项目集或规则。这件作品code应该是有帮助的。

  transaction_data<  - 为(数据,交易)
规则< - 先验(transaction_data,参数=列表(minlen = 2,人联党= 0.2的conf = 0.5))

I am experimenting with the apriori algorithm in the arules package.

This is what I've done: I loaded a view from SQL Server into R. Since that data is not in transactions form (to use in apriori), I had to convert it:

data <- sapply(orders, as.factor)

Then I entered the apriori function:

apriori(data, parameter = list (support=0.005, confidence=0.5))

I get this error:

Error in t(as(from, "ngCMatrix")) : error in evaluating the argument 'x' in selecting a method for function 't': Error in asMethod(object) : cannot coerce 'NA's to "nsparseMatrix"

I checked with a query and I don't even have any attribute that is NULL/NA.

I don't understand what the error means. Does someone know what the problem is and how to solve this?

解决方案

I have encountered the same kind of error recently. All I have learnt was that your data have to be coerced to transactions for mining the itemsets or rules. This piece of code should be helpful.

transaction_data<- as(data, "transactions")
rules <- apriori(transaction_data,parameter = list(minlen=2,supp=0.2,conf=0.5))

这篇关于R:关于不先验误差能够强制NA对nsparseMatrix的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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