Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #88 from Iron-Stark/patch-19
Update Scikit SVM implementation.
- Loading branch information
Showing
3 changed files
with
75 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
''' | ||
@file benchmark_svm.py | ||
Test for the svm scripts. | ||
''' | ||
|
||
import unittest | ||
|
||
import os, sys, inspect | ||
|
||
# Import the util path, this method even works if the path contains | ||
# symlinks to modules. | ||
cmd_subfolder = os.path.realpath(os.path.abspath(os.path.join( | ||
os.path.split(inspect.getfile(inspect.currentframe()))[0], '../util'))) | ||
if cmd_subfolder not in sys.path: | ||
sys.path.insert(0, cmd_subfolder) | ||
|
||
from loader import * | ||
|
||
''' | ||
Test the scikit svm script. | ||
''' | ||
|
||
class SVM_SCIKIT_TEST(unittest.TestCase): | ||
|
||
''' | ||
Test initialization. | ||
''' | ||
def setUp(self): | ||
self.dataset = ['datasets/iris_train.csv','datasets/iris_test.csv','datasets/iris_labels.csv'] | ||
self.verbose = False | ||
self.timeout = 9000 | ||
|
||
module = Loader.ImportModuleFromPath("methods/scikit/svm.py") | ||
obj = getattr(module, "SVM") | ||
self.instance = obj(self.dataset, verbose=self.verbose, timeout=self.timeout) | ||
|
||
''' | ||
Test the constructor. | ||
''' | ||
def test_Constructor(self): | ||
self.assertEqual(self.instance.verbose, self.verbose) | ||
self.assertEqual(self.instance.timeout, self.timeout) | ||
self.assertEqual(self.instance.dataset, self.dataset) | ||
|
||
''' | ||
Test the 'RunMetrics' function. | ||
''' | ||
def test_RunMetrics(self): | ||
result = self.instance.RunMetrics({}) | ||
self.assertTrue(result["Runtime"] > 0) | ||
self.assertTrue(result["ACC"] > 0) | ||
self.assertTrue(result["Precision"] > 0) | ||
self.assertTrue(result["Recall"] > 0) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters