Skip to content

Why is the TransactionEncoder() function transcoding my headers too?|为什么TransactionEncoder()函数会将我的标题也转码了? #919

Answered by rasbt
mingrich asked this question in Q&A
Discussion options

You must be logged in to vote

I think the problem could be that the inputs were not lists.

The dataset should be in the following form

dataset = [['Milk', 'Onion', 'Nutmeg', 'Kidney Beans', 'Eggs', 'Yogurt'],
           ['Dill', 'Onion', 'Nutmeg', 'Kidney Beans', 'Eggs', 'Yogurt'],
           ['Milk', 'Apple', 'Kidney Beans', 'Eggs'],
           ['Milk', 'Unicorn', 'Corn', 'Kidney Beans', 'Yogurt'],
           ['Corn', 'Onion', 'Onion', 'Kidney Beans', 'Ice cream', 'Eggs']]

import pandas as pd
from mlxtend.preprocessing import TransactionEncoder

te = TransactionEncoder()
te_ary = te.fit(dataset).transform(dataset)
df = pd.DataFrame(te_ary, columns=te.columns_)

If you don't use sublists, I think that problems that yo…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by mingrich
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants