我在Python中使用arules。我执行了下面的代码来生成所有关联。我想知道如何将arules的输出转换为Python中的某些数据结构。 ' rpy2.robjects.methods.RS4' 类型的输出。 - 下面是代码---
from rpy2.robjects import pandas2ri
pandas2ri.activate()
import collections
from collections import OrderedDict
import pandas as pd
import numpy as np
from rpy2.robjects.vectors import ListVector
from rpy2.robjects.packages import importr
arules = importr("arules")
od = OrderedDict()
od["supp"] = 0.0005
od["conf"] = 0.7
od["target"] = 'rules'
df = pd.DataFrame (
[
['1','1', '1'],
['1', '0','0'],
['1', '1', '1'],
['1', '0', '0'],
['1', '1', '1'],
['1', '0', '1'],
['1', '1', '1'],
['0', '0', '1'],
['0', '1', '1'],
['1', '0', '1'],
],
columns=list ('ABC'))
result = ListVector(od)
df['A'] = df['A'].astype('category')
df['B'] = df['B'].astype('category')
df['C'] = df['C'].astype('category')
my_rules = arules.apriori(df, parameter=result)
print("herererererere")
print(type(my_rules))
print("rules")
答案 0 :(得分:1)
这是如何执行此操作的一个极简示例:
cd libgtextutils-0.7
sed -i '47s/input_stream/static_cast<bool>(input_stream)/' src/gtextutils/text_line_reader.cpp
./configure
make
make install