How to get the string value from a frozenset that have two or more string values in Python?

219 Views Asked by At
import pandas as pd
from apyori import apriori
from collections import defaultdict
ds=pd.read_csv('event.csv',header=None)
num_records=len(ds)
print(num_records)
records=[]
for i in range(0,num_records):
    records.append([str(ds.values[i,j])for j in range(0,6)])
association_rule=apriori(records,min_support=0.01,min_confidence=0.50,min_lift=8,min_length=2)
association_Results=list(association_rule)
print(association_Results)
results=[]
for item in association_Results:
        pair = item[0]
       items=[x for x in pair]
       value0=str(item[0])
       value1=str(item[1])
       value2=str(item[1])[:7]
       value3=str(item[2][0][2])[:7]
       rows=[value0,value1,value2,value3]
       results.append(rows)
       #print(value0)
       #print(results)
       label=['Tracks','Support','confidence','Lift']
       Event_suggestion =pd.DataFrame.from_records(results,columns=label)
       print(Event_suggestion)
k=Event_suggestion.iloc[0]['Tracks']
print(next(value for value in k))

the result: 1001 Tracks ... Lift 0 frozenset({'ART', 'Digital Marketing'}) ... 1.0

[1 rows x 4 columns]
                                    Tracks  ...     Lift
0  frozenset({'ART', 'Digital Marketing'})  ...      1.0
1    frozenset({'IOT', 'Public Speaking'})  ...  0.83333

[2 rows x 4 columns]
                                             Tracks  ...     Lift
0           frozenset({'ART', 'Digital Marketing'})  ...      1.0
1             frozenset({'IOT', 'Public Speaking'})  ...  0.83333
2  frozenset({'IOT', 'Public Speaking', 'Finance'})  ...   0.6875

[3 rows x 4 columns]
f
[Finished in 0.9s]

** this code is to suggested Events using Apriori Algorithm.It's taking The tracks from Events and see what is the frequent item or items and suggest that **

0

There are 0 best solutions below