Bag of words और N-grams

Python में मशीन लर्निंग के लिए फीचर इंजीनियरिंग

Robert O'Callaghan

Director of Data Science, Ordergroove

Bag of words की समस्याएँ

 

Positive अर्थ

Single word: happy

Negative अर्थ

Bi-gram: not happy

Positive अर्थ

Trigram: never not happy

Python में मशीन लर्निंग के लिए फीचर इंजीनियरिंग

N-grams का उपयोग

tv_bi_gram_vec = TfidfVectorizer(ngram_range = (2,2))

# Fit और bigram vectorizer लागू करें
tv_bi_gram = tv_bi_gram_vec\
               .fit_transform(speech_df['text'])

# Bigram फीचर प्रिंट करें
print(tv_bi_gram_vec.get_feature_names())
[u'american people', u'best ability ',
 u'beloved country', u'best interests' ... ]

Python में मशीन लर्निंग के लिए फीचर इंजीनियरिंग

सामान्य शब्द खोजना

# Counts फीचर्स के साथ DataFrame बनाएँ
tv_df = pd.DataFrame(tv_bi_gram.toarray(),
                     columns=tv_bi_gram_vec.get_feature_names())\
                        .add_prefix('Counts_')

tv_sums = tv_df.sum()
print(tv_sums.head())
Counts_administration government    12
Counts_almighty god                 15
Counts_american people              36
Counts_beloved country               8
Counts_best ability                  8
dtype: int64
Python में मशीन लर्निंग के लिए फीचर इंजीनियरिंग

सामान्य शब्द खोजना

print(tv_sums.sort_values(ascending=False)).head()
Counts_united states         152
Counts_fellow citizens        97
Counts_american people        36
Counts_federal government     35
Counts_self government        30
dtype: int64
Python में मशीन लर्निंग के लिए फीचर इंजीनियरिंग

अभ्यास करते हैं!

Python में मशीन लर्निंग के लिए फीचर इंजीनियरिंग

Preparing Video For Download...