> print ("incorrect: " + str (evaluation.incorrect)) Clusterers > print ("pctCorrect: "+ str(evaluation.percent_correct)) > evaluation.crossvalidate_model (classifier, data, 10, Random(42)) > classifier = Classifier(classname="48", options= ) > from weka.classifiers import Classifier, Evaluation
Let’s see the example for cross validating the J48 classifier on the dataset and the result of specific statistics, > remove = Filter (classname=".Remove", options=) The filter class we get from the weka.filters module which agree to filter the datasets, for example to remove the last attributes by using the Remove filter, >converters.save_any_file(data,"") Filters Those methods decides the loader and saver based on the file extension, The module has easy methods for storing and loading the datasets called the load_any_file and save_any_file. To load and save the datasets of different data formats we can make use of the Loader and Saver classes, let’s see the following code loads an ARFF file and save it in CSV, > DataGenerator.make_data (generator, ) Loaders and Savers > generator = DataGenerator (classname= ".Agrawal", options= )
> from weka.datagenerators import DataGenerator > Cls = Classifier (classname = "48", options= )īy using Weka’s Data Generators we can generate Artificial data for example Agrawal classification generator, > cls=Classifier(classname="48", options=)īy using the option property we can also get the current set options, as follows > cls= Classifier(classname = "weka.classifiers. > from weka.classifiers import Classifier There are two examples to instantiate a J48 classifier one is used for option property and another is for shortcut for constructor, The Option-Handling derived from OptionHandler it’s the module of it allows to get and set the options via property options. In the end we have to stop the JVM, for that follows the code as below Generally we have to increase the size of heap maximum for JVM, for that purpose we need to reserves as 512 MB, like start (packages="/my/packages/are/somewhere/else") If the Weka home directory is not available in wekafiles, then we have to specify in two options for alternative locations one is to make use of the WEKA_HOME environment variable or to make use the packages parameter to supplying the directory, let’s see the code below as follows > jvm.start (system_cp= True, packages= True) When we want to call the ClassPath variables and to make use of the installed packages in Weka we need to use the following code to call,