svm / tfidf.py
yitingliii's picture
Create tfidf.py
fad1a71 verified
raw
history blame
242 Bytes
```python
from sklearn.feature_extraction.text import TfidfVectorizer
tfidf = TfidfVectorizer(max_features=5000, ngram_range=(1, 2), stop_words='english')
X_train_tfidf = tfidf.fit_transform(X_train)
X_test_tfidf = tfidf.transform(X_test)
```