def test_plot_experiment(self): """ Tests the plot_experiment method. """ datasets = [ self.datafile("bolts.arff"), self.datafile("bodyfat.arff"), self.datafile("autoPrice.arff") ] cls = [ classifiers.Classifier("weka.classifiers.trees.REPTree"), classifiers.Classifier( "weka.classifiers.functions.LinearRegression"), classifiers.Classifier("weka.classifiers.functions.SMOreg"), ] outfile = self.tempfile("results-rs.arff") exp = experiments.SimpleRandomSplitExperiment(classification=False, runs=10, percentage=66.6, preserve_order=False, datasets=datasets, classifiers=cls, result=outfile) exp.setup() exp.run() # evaluate loader = converters.loader_for_file(outfile) data = loader.load_file(outfile) matrix = experiments.ResultMatrix( "weka.experiment.ResultMatrixPlainText") tester = experiments.Tester("weka.experiment.PairedCorrectedTTester") tester.resultmatrix = matrix comparison_col = data.attribute_by_name( "Correlation_coefficient").index tester.instances = data tester.header(comparison_col) tester.multi_resultset_full(0, comparison_col) # plot plot.plot_experiment(matrix, title="Random split (w/ StdDev)", measure="Correlation coefficient", show_stdev=True, wait=False) plot.plot_experiment(matrix, title="Random split", measure="Correlation coefficient", wait=False)
def test_randomsplit_regression(self): """ Tests random split on regression. """ datasets = [self.datafile("bolts.arff"), self.datafile("bodyfat.arff")] cls = [ classifiers.Classifier(classname="weka.classifiers.rules.ZeroR"), classifiers.Classifier( classname="weka.classifiers.functions.LinearRegression") ] outfile = self.tempfile("results-rs.arff") exp = experiments.SimpleRandomSplitExperiment(classification=False, runs=10, percentage=66.6, preserve_order=False, datasets=datasets, classifiers=cls, result=outfile) self.assertIsNotNone(exp, msg="Failed to instantiate!") exp.setup() exp.run() # evaluate loader = converters.loader_for_file(outfile) data = loader.load_file(outfile) self.assertIsNotNone(data, msg="Failed to load data: " + outfile) matrix = experiments.ResultMatrix( classname="weka.experiment.ResultMatrixPlainText") self.assertIsNotNone(matrix, msg="Failed to instantiate!") tester = experiments.Tester( classname="weka.experiment.PairedCorrectedTTester") self.assertIsNotNone(tester, msg="Failed to instantiate!") tester.resultmatrix = matrix comparison_col = data.attribute_by_name( "Correlation_coefficient").index tester.instances = data self.assertGreater(len(tester.header(comparison_col)), 0, msg="Generated no header") self.assertGreater(len(tester.multi_resultset_full(0, comparison_col)), 0, msg="Generated no result")