Dear sklearn users:
I am hanging with the following simple problem of doing support vector
machine with numpy arrays. I would be grateful if someone answer me.
import numpy as np
from sklearn import svm
##I have 3 classes/labels ('male', 'female','na') denoted as follows:
labels = [0,1,2]
##Each class was defined by 3 variables ('height','weight','age') as the
training data:
male_height = np.array([111,121,137,143,157])
male_weight = np.array([60,70,88,99,75])
male_age = np.array([41,32,73,54,35])
males = np.hstack([male_height,male_weight,male_age])
female_height = np.array([91,121,135,98,90])
female_weight = np.array([32,67,98,86,56])
female_age = np.array([51,35,33,67,61])
females = np.hstack([female_height,female_weight,female_age])
na_height = np.array([96,127,145,99,91])
na_weight = np.array([42,97,78,76,86])
na_age = np.array([56,35,49,64,66])
nas = np.hstack([na_height,na_weight,na_age])
##Now I have to fit the support vector machine method for the training data
to predict the class given that 3 variable:
height_weight_age = [100,100,100]
clf = svm.SVC()
trainingData = np.vstack([males,females,nas])
clf.fit(trainingData, labels)
result = clf.predict(height_weight_age)
print result
#Unfortunately, the following error occurs:
# ValueError: X.shape[1] = 3 should be equal to 15, the number of features
at #training time
#How should I modify the 'trainingData' and 'labels' to get the correct
answer?
Thanks in the advance.
Artur Bercik
------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://p.sf.net/sfu/Zoho
_______________________________________________
Scikit-learn-general mailing list
Scikit-learn-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general