Ejemplo n.º 1
0
 def testSVMSK2(self):
     digits = datasets.load_digits()
     X_digits = digits.data
     y_digits = digits.target
     n_samples = len(X_digits)
     X_train = X_digits[:.9 * n_samples]
     y_train = y_digits[:.9 * n_samples]
     X_test = X_digits[.9 * n_samples:]
     y_test = y_digits[.9 * n_samples:]
     svm = SVM(sqlCtx, is_multi_class=True, transferUsingDF=True)
     score = svm.fit(X_train, y_train).score(X_test, y_test)
     self.failUnless(score > 0.9)
Ejemplo n.º 2
0
 def testSVMSK2(self):
     digits = datasets.load_digits()
     X_digits = digits.data
     y_digits = digits.target
     n_samples = len(X_digits)
     X_train = X_digits[:.9 * n_samples]
     y_train = y_digits[:.9 * n_samples]
     X_test = X_digits[.9 * n_samples:]
     y_test = y_digits[.9 * n_samples:]
     svm = SVM(sqlCtx, is_multi_class=True, transferUsingDF=True)
     score = svm.fit(X_train, y_train).score(X_test, y_test)
     self.failUnless(score > 0.9)
 def test_svm(self):
     digits = datasets.load_digits()
     X_digits = digits.data
     y_digits = digits.target
     n_samples = len(X_digits)
     X_train = X_digits[:int(.9 * n_samples)]
     y_train = y_digits[:int(.9 * n_samples)]
     X_test = X_digits[int(.9 * n_samples):]
     y_test = y_digits[int(.9 * n_samples):]
     svm = SVM(sqlCtx, is_multi_class=True)
     score = svm.fit(X_train, y_train).score(X_test, y_test)
     self.failUnless(score > 0.9)
 def test_svm(self):
     digits = datasets.load_digits()
     X_digits = digits.data
     y_digits = digits.target
     n_samples = len(X_digits)
     X_train = X_digits[:int(.9 * n_samples)]
     y_train = y_digits[:int(.9 * n_samples)]
     X_test = X_digits[int(.9 * n_samples):]
     y_test = y_digits[int(.9 * n_samples):]
     svm = SVM(sqlCtx, is_multi_class=True)
     score = svm.fit(X_train, y_train).score(X_test, y_test)
     self.failUnless(score > 0.9)
Ejemplo n.º 5
0
 def test_svm_sk2(self):
     digits = datasets.load_digits()
     X_digits = digits.data
     y_digits = digits.target
     n_samples = len(X_digits)
     X_train = X_digits[:int(.9 * n_samples)]
     y_train = y_digits[:int(.9 * n_samples)]
     X_test = X_digits[int(.9 * n_samples):]
     y_test = y_digits[int(.9 * n_samples):]
     svm = SVM(sparkSession, is_multi_class=True, transferUsingDF=True)
     mllearn_predicted = svm.fit(X_train, y_train).predict(X_test)
     from sklearn import linear_model, svm
     clf = svm.LinearSVC()
     sklearn_predicted = clf.fit(X_train, y_train).predict(X_test)
     self.failUnless(accuracy_score(sklearn_predicted, mllearn_predicted) > 0.95 )
Ejemplo n.º 6
0
 def test_svm_sk2(self):
     digits = datasets.load_digits()
     X_digits = digits.data
     y_digits = digits.target
     n_samples = len(X_digits)
     X_train = X_digits[:int(.9 * n_samples)]
     y_train = y_digits[:int(.9 * n_samples)]
     X_test = X_digits[int(.9 * n_samples):]
     y_test = y_digits[int(.9 * n_samples):]
     svm = SVM(sparkSession, is_multi_class=True, transferUsingDF=True)
     mllearn_predicted = svm.fit(X_train, y_train).predict(X_test)
     from sklearn import linear_model, svm
     clf = svm.LinearSVC()
     sklearn_predicted = clf.fit(X_train, y_train).predict(X_test)
     self.failUnless(accuracy_score(sklearn_predicted, mllearn_predicted) > 0.95 )
Ejemplo n.º 7
0
 def test_svm(self):
     digits = datasets.load_digits()
     X_digits = digits.data
     y_digits = digits.target
     n_samples = len(X_digits)
     X_train = X_digits[:int(.9 * n_samples)]
     y_train = y_digits[:int(.9 * n_samples)]
     X_test = X_digits[int(.9 * n_samples):]
     y_test = y_digits[int(.9 * n_samples):]
     svm = SVM(sparkSession, is_multi_class=True, tol=0.0001)
     mllearn_predicted = svm.fit(X_train, y_train).predict(X_test)
     from sklearn import linear_model, svm
     clf = svm.LinearSVC()
     sklearn_predicted = clf.fit(X_train, y_train).predict(X_test)
     accuracy = accuracy_score(sklearn_predicted, mllearn_predicted)
     evaluation = 'test_svm accuracy_score(sklearn_predicted, mllearn_predicted) was {}'.format(accuracy)
     self.failUnless(accuracy > 0.95, evaluation)
Ejemplo n.º 8
0
 def test_svm(self):
     digits = datasets.load_digits()
     X_digits = digits.data
     y_digits = digits.target
     n_samples = len(X_digits)
     X_train = X_digits[:int(.9 * n_samples)]
     y_train = y_digits[:int(.9 * n_samples)]
     X_test = X_digits[int(.9 * n_samples):]
     y_test = y_digits[int(.9 * n_samples):]
     svm = SVM(sparkSession, is_multi_class=True, tol=0.0001)
     mllearn_predicted = svm.fit(X_train, y_train).predict(X_test)
     from sklearn import linear_model, svm
     clf = svm.LinearSVC()
     sklearn_predicted = clf.fit(X_train, y_train).predict(X_test)
     accuracy = accuracy_score(sklearn_predicted, mllearn_predicted)
     evaluation = 'test_svm accuracy_score(sklearn_predicted, mllearn_predicted) was {}'.format(accuracy)
     self.failUnless(accuracy > 0.95, evaluation)
 def test_svm(self):
     digits = datasets.load_digits()
     X_digits = digits.data
     y_digits = digits.target
     n_samples = len(X_digits)
     X_train = X_digits[:int(.9 * n_samples)]
     y_train = y_digits[:int(.9 * n_samples)]
     X_test = X_digits[int(.9 * n_samples):]
     y_test = y_digits[int(.9 * n_samples):]
     svm = SVM(sparkSession, is_multi_class=True, tol=0.0001)
     mllearn_predicted = svm.fit(X_train, y_train).predict(X_test)
     from sklearn import svm
     clf = svm.LinearSVC()
     sklearn_predicted = clf.fit(X_train, y_train).predict(X_test)
     self.failUnless(
         test_accuracy_score(sklearn_predicted, mllearn_predicted, y_test,
                             0.95))