yitingliii commited on
Commit
fad1a71
1 Parent(s): 516f621

Create tfidf.py

Browse files
Files changed (1) hide show
  1. tfidf.py +6 -0
tfidf.py ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ ```python
2
+ from sklearn.feature_extraction.text import TfidfVectorizer
3
+ tfidf = TfidfVectorizer(max_features=5000, ngram_range=(1, 2), stop_words='english')
4
+ X_train_tfidf = tfidf.fit_transform(X_train)
5
+ X_test_tfidf = tfidf.transform(X_test)
6
+ ```