I am using arules in Python. I executed the below code to generate all associations. I want to know how can i convert the output of arules to some data-structure in Python. The output if of type 'rpy2.robjects.methods.RS4'. --below is the code---
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")
Here is a minimalist example of how to do this: