import pandas as pd
import numpy as np
from collections import Counter
from mlxtend.preprocessing import TransactionEncoder
from mlxtend.frequent_patterns import apriori
from mlxtend.frequent_patterns import association_rules

actors = pd.read_csv('files/BollywoodMovieDetail.csv')
actors = actors['actors']

x = []
for i in range(len(actors)):
    a = str(actors[i]).split('|')
    a = [z.strip() for z in a]
    x.append(a)

te = TransactionEncoder()
te = te.fit(x)
te_ary = te.transform(x)

dffd = pd.DataFrame(te_ary,columns=te.columns_)

frequent_itemsets = apriori(dffd, min_support =0.00078,use_colnames=True)
frequent_itemsets.to_csv('files/newresultapriori.csv')

