Skip to content

Commit 097e4eb

Browse files
authored
Update README.rst
1 parent 7a61a86 commit 097e4eb

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

README.rst

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -280,13 +280,13 @@ Where N is number of documents and df(t) is the number of documents containing t
280280

281281
.. code:: python
282282
283-
from sklearn.feature_extraction.text import TfidfTransformer
284-
def loadData(X_train, X_test,MAX_NB_WORDS=75000):
285-
vectorizer_x = TfidfVectorizer(max_features=MAX_NB_WORDS)
286-
X_train = vectorizer_x.fit_transform(X_train).toarray()
287-
X_test = vectorizer_x.transform(X_test).toarray()
288-
print("tf-idf with",str(np.array(X_train).shape[1]),"features")
289-
return (X_train,X_test)
283+
from sklearn.feature_extraction.text import TfidfTransformer
284+
def loadData(X_train, X_test,MAX_NB_WORDS=75000):
285+
vectorizer_x = TfidfVectorizer(max_features=MAX_NB_WORDS)
286+
X_train = vectorizer_x.fit_transform(X_train).toarray()
287+
X_test = vectorizer_x.transform(X_test).toarray()
288+
print("tf-idf with",str(np.array(X_train).shape[1]),"features")
289+
return (X_train,X_test)
290290
291291
========================
292292
Dimensionality Reduction
@@ -323,6 +323,7 @@ we start to review some random projection techniques.
323323
.. image:: docs/pic/Random%20Projection.png
324324

325325
.. code:: python
326+
326327
import numpy as np
327328
from sklearn import random_projection
328329
X = np.random.rand(100, 10000)
@@ -410,6 +411,7 @@ The first version of Rocchio algorithm is introduced by rocchio in 1971 to use r
410411
When in nearest centroid classifier, we used for text as input data for classification with tf-idf vectors, this classifier is known as the Rocchio classifier.
411412

412413
.. code:: python
414+
413415
from sklearn.neighbors.nearest_centroid import NearestCentroid
414416
import numpy as np
415417
X = np.array([[-1, -1], [-2, -1], [-3, -2], [1, 1], [2, 1], [3, 2]])

0 commit comments

Comments
 (0)