title: How do I get data into the ndarray format for SKLearn?
body: <p>Scikit-Learn is a great Python module that supplies a <a href="https://en.wikipedia.org/wiki/Support_vector_machine" rel="nofollow noreferrer">support vector machine</a> with many algorithms. I've been learning how to use the module for the past few days, and I've noticed it relies heavily on the separate <a href="https://pypi.python.org/pypi/numpy" rel="nofollow noreferrer">numpy</a> module.</p>
  
  <p>I understand what the module does, but I'm still learning about how it works. Here is a very brief example of what I'm using <code>sklearn</code> for:</p>
  
  <pre><code>from sklearn import datasets, svm
  import numpy
  
  digits = datasets.load_digits() #image pixel data of digits 0-9 as well as a chart of the corresponding digit to each image
  
  clf = svm.SVC(gamma=0.001,C=100) #SVC is the algorithm used for classifying this type of data
  
  x,y = digits.data[:-1], digits.target[:-1] #feed it all the data
  clf.fit(x,y) #"train" the SVM
  
  print(clf.predict(digits.data[0])) #&gt;&gt;&gt;[0]
  #with 99% accuracy, all of the data consists of 1797 samples.
  #if this number gets smaller, the accuracy decreases. with 10 samples (0-9),
  #accuracy can still be up to as high as 90%.
  </code></pre>
  
  <p>That's very basic classification. <b>There are 10 classes: 0,1,2,3,4,5,6,7,8,9.</b></p>
  
  <p>Using the following code with matplotlib.pyplot:</p>
  
  <pre><code>import matplotlib.pyplot as plt #in shell after running previous code
  plt.imshow(digits.images[0],cmap=plt.cm.gray_r,interpolation="nearest")
  plt.show()
  </code></pre>
  
  <p>gives the following image:
  <a href="https://i.stack.imgur.com/7yygI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7yygI.png" alt="enter image description here"></a></p>
  
  <p>The first pixel (left to right, top to bottom, like reading) would be represented by a 0. Same for the second, but the third would be represented by 7 or something (range is 0 to 15), fourth being about 13. Here's the actual data for the image:</p>
  
  <pre><code>[[  0.   0.   5.  13.   9.   1.   0.   0.]
   [  0.   0.  13.  15.  10.  15.   5.   0.]
   [  0.   3.  15.   2.   0.  11.   8.   0.]
   [  0.   4.  12.   0.   0.   8.   8.   0.]
   [  0.   5.   8.   0.   0.   9.   8.   0.]
   [  0.   4.  11.   0.   1.  12.   7.   0.]
   [  0.   2.  14.   5.  10.  12.   0.   0.]
   [  0.   0.   6.  13.  10.   0.   0.   0.]]
  </code></pre>
  
  <p><b>So my question is this:</b> if I wanted to classify text data, for example forum posts in the wrong subforum/category, how would I convert that data into the number system used in this dataset example?</p>