weka | A Python wrapper for Weka | Machine Learning library

 by   chrisspen Python Version: 2.0.2 License: LGPL-3.0

kandi X-RAY | weka Summary

kandi X-RAY | weka Summary

weka is a Python library typically used in Artificial Intelligence, Machine Learning applications. weka has no bugs, it has no vulnerabilities, it has build file available, it has a Weak Copyleft License and it has high support. You can install using 'pip install weka' or download it from GitHub, PyPI.

Provides a convenient wrapper for calling Weka classifiers from Python.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              weka has a highly active ecosystem.
              It has 75 star(s) with 17 fork(s). There are 4 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 0 open issues and 2 have been closed. On average issues are closed in 2 days. There are 3 open pull requests and 0 closed requests.
              It has a positive sentiment in the developer community.
              The latest version of weka is 2.0.2

            kandi-Quality Quality

              weka has 0 bugs and 0 code smells.

            kandi-Security Security

              weka has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              weka code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              weka is licensed under the LGPL-3.0 License. This license is Weak Copyleft.
              Weak Copyleft licenses have some restrictions, but you can use them in commercial projects.

            kandi-Reuse Reuse

              weka releases are not available. You will need to build from source code and install.
              Deployable package is available in PyPI.
              Build file is available. You can build the component from source.
              Installation instructions, examples and code snippets are available.
              weka saves you 616 person hours of effort in developing the same functionality from scratch.
              It has 1433 lines of code, 87 functions and 5 files.
              It has high code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed weka and discovered the below as its top functions. This is intended to give you an instant insight into weka implemented functionality, and help decide if they suit your requirements.
            • Query the classifier
            • Escape a string
            • Parse sparse data line
            • Append line to the stream
            • Train the classifier
            • Return a shallow copy of the object
            • Write the object to fout
            • Train the model
            • Load a classifier
            • Load a pickled file
            • Load a model from raw data
            • Load a schema from a file
            • Get requirements from files
            • Save the document to a file
            • Set the class name
            Get all kandi verified functions for this library.

            weka Key Features

            No Key Features are available at this moment for weka.

            weka Examples and Code Snippets

            How to use attributeselectedclassifier on pyweka?
            Pythondot img1Lines of Code : 12dot img1License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            from weka.core.classes import from_commandline, get_classname
            from weka.attribute_selection import ASSearch
            from weka.attribute_selection import ASEvaluation
            
            search = from_commandline('weka.attributeSelection.GreedyStepwise -B -T -1.79769
            Which are the possible options for pyweka multisearch function?
            Pythondot img2Lines of Code : 2dot img2License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            multi = MultiSearch(options=["-S", "1"])
            
            Converting .model file to .Json
            Pythondot img3Lines of Code : 11dot img3License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            from wekapy import *
            
            # CREATE NEW MODEL INSTANCE WITH A CLASSIFIER TYPE
            
            model = Model(classifier_type = "bayes.BayesNet")
            
            
            # LOAD A PREVIOUSLY TRAINED MODEL INTO OUR model OBJECT FOR TESTING AGAINST
            
            model.load_model("/path/to/model.mod
            Information Gain calculation with Scikit-learn
            Pythondot img4Lines of Code : 41dot img4License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            from sklearn.datasets import fetch_20newsgroups
            from sklearn.feature_selection import mutual_info_classif
            from sklearn.feature_extraction.text import CountVectorizer
            
            categories = ['talk.religion.misc',
                          'comp.graphics', 'sci.
            copy iconCopy
            sudo apt-get install python-pip python3-pip virtualenv build-essential
            
            sudo apt-get install openjdk-8-source openjdk-8-jdk
            
            DEBUG:weka.core.jvm:Adding bundled jars
            DEBUG:weka.core.jvm:Classp
            exporting dataframe to arff file python
            Pythondot img6Lines of Code : 6dot img6License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            import arff
            arff.dump('filename.arff'
                  , df.values
                  , relation='relation name'
                  , names=df.columns)`
            
            Getting specfic values related to result after using pythonwekawrapper3
            Pythondot img7Lines of Code : 3dot img7License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            list_of_sel_atts = list(attsel.selected_attributes))
            print(list_of_sel_atts)
            
            Why do I get an Error in import weka in python
            Pythondot img8Lines of Code : 2dot img8License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            pip install python-weka-wrapper
            
            Python-Weka-Wrapper3 removing attributes from arff file error
            Pythondot img9Lines of Code : 3dot img9License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            from weka.filters import Filter
            remove = Filter(classname="weka.filters.unsupervised.attribute.Remove", options=["-R", "1,2,3,4,5"])
            
            Convert Decision tree from text 2 visual
            Pythondot img10Lines of Code : 22dot img10License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            line = '|    |    |    |    |    "assembly" <= 0.5:'
            
            parts = line.split('"')
            indent = parts[0].count('|    ')
            predictor = parts[1]
            splitpoint = float(parts[2][-1-parts[2].rfind(' '):-1])
            

            Community Discussions

            QUESTION

            How to use the ADTrees classifier from weka as base of a bagging scikitlearn model?
            Asked 2022-Mar-31 at 22:42

            My intention is to recreate a big model done on weka using scikit-learn and other libraries.

            I have this base model done with pyweka.

            ...

            ANSWER

            Answered 2022-Mar-31 at 22:42

            I've just released a version 0.0.5 of sklearn-weka-plugin, with which you can do the following:

            Source https://stackoverflow.com/questions/71667153

            QUESTION

            How can do crossvalidation for a AttributeSelectedClassifier model?
            Asked 2022-Mar-16 at 02:30

            I did a model like that:

            ...

            ANSWER

            Answered 2022-Mar-16 at 02:30

            I have turned your code snippet into one with imports and fixed the MultiSearch setup for Bagging (mparam.prop = "numIterations" instead of mparam.prop = "numOfBoostingIterations"), allowing it to be executed.

            Since I do not have access to your data, I just used the UCI dataset vote.arff.

            Your code was a bit odd, as it did a 70/30 train/test split, trained the classifier and then performed cross-validation on the test data. For cross-validation you do not train the classifier, as this happens within the internal cross-validation loop (each trained classifier inside that loop gets discarded, as cross-validation is only used for gathering statistics).

            The code below has therefore three parts:

            1. your original evaluation code, but commented out
            2. performing proper cross-validation
            3. performing train/test evaluation

            I do not use Jupyter notebooks and tested the code successfully in a regular virtual environment on my Linux Mint:

            • Python: 3.8.10
            • Output of pip freeze:

            Source https://stackoverflow.com/questions/71487198

            QUESTION

            Can we make a prediction model in WEKA?
            Asked 2022-Mar-15 at 21:11

            I am trying to build a prediction model using WEKA. For example, I plan to build a model for classifying whether something is leading to A or P using Database 1. I will then use another Testing and Training dataset to predict outcomes whether something is A or B using this model. Are there any prediction packages for that? I saw Forecasting packages but that is for numeric data. I am looking prediction packages that could help me classify data and make predictions. Also, can I save this model and make it publicly available so that others can use it as well and make similar predictions? Is this possible in WEKA?

            ...

            ANSWER

            Answered 2022-Mar-15 at 21:11

            Yes, of course you can make predictions with a model. Since it is not clear, whether you want to do that from the command-line, in the GUI or from code, I recommend you have a look at the following Weka wiki article:

            https://waikato.github.io/weka-wiki/making_predictions/

            If you want to use the API, check the articles listed here:

            https://waikato.github.io/weka-wiki/using_the_api/

            Also, every Weka installation comes with code examples, aptly named wekaexamples.zip.

            Source https://stackoverflow.com/questions/71485315

            QUESTION

            How to use attributeselectedclassifier on pyweka?
            Asked 2022-Mar-14 at 20:20

            Im translating a model done on weka to python-weka-wrapper3 and i dont know how to an evaluator and search options on attributeselectedclassifier.

            This is the model on weka:

            ...

            ANSWER

            Answered 2022-Mar-14 at 20:20

            You need to instantiate ASSearch and ASEvaluation objects. If you have command-lines, you can use the from_commandline helper method like this:

            Source https://stackoverflow.com/questions/71468051

            QUESTION

            Calculate TF-IDF in WEKA API for single document to predict classification
            Asked 2022-Mar-13 at 19:53

            For some reason I am using the WEKA API...

            I have generated tf-idf scores for a set of documents,

            ...

            ANSWER

            Answered 2022-Mar-13 at 19:53

            The StringToWordVector filter uses the weka.core.DictionaryBuilder class under the hood for the TF/IDF computation.

            As long as you create a weka.core.Instance object with the text that you want to have converted, you can do that using the builder's vectorizeInstance(Instance) method.

            Edit 1:

            Below is an example based on your code (but with Weka classes), which shows how to either use the filter or the DictionaryBuilder for the TF/IDF transformation. Both get serialized, deserialized and re-used as well to demonstrate that these classes are serializable:

            Source https://stackoverflow.com/questions/71036021

            QUESTION

            Is there any way to use ADTrees on python with PYWEKA?
            Asked 2022-Mar-09 at 20:06

            Hi guys I have this question because im trying to use ADTrees of weka on python using pyweka like this:

            ...

            ANSWER

            Answered 2022-Mar-09 at 20:06

            python-weka-wrapper3, as the name suggests, is a light-weight wrapper around Weka classes. However, it mostly only wraps abstract superclasses, not all of the thousands of classes that make up Weka.

            The weka.classifiers.Classifier class is the wrapper to use for classifiers and you need to specify the Java classname of the actual classifier that you want to wrap (in your case weka.classifiers.trees.ADTree). And, yes, just like Python, Java is also case sensitive.

            Furthermore, if you require classes from packages, then you need to start the JVM with package support (default is no package support).

            Below is an example that outputs the command-line of ADTree with its default parameters. If necessary, it installs the package first.

            Source https://stackoverflow.com/questions/71413688

            QUESTION

            Bias to uniform class weka resample filter
            Asked 2022-Feb-27 at 01:20

            I am doing a data science project. My dataset is an imbalanced dataset. I am using Weka for classification purpose.

            The dataset has 1273 instances. Among them yes class instances are 174 and No class instances are 1099. Therefore, the dataset is bias to no class.

            I am using resample filter to maintain a ratio among yes class and no class. I am sharing a result below.

            The parameter that I have tweaked to see various yes: no ratio is bias to uniform class. As per weka's documentation the definition of term bias to uniform class is Whether to use bias towards a uniform class. A value of 0 leaves the class distribution as-is, a value of 1 ensures the class distribution is uniform in the output data.

            ...

            ANSWER

            Answered 2022-Feb-27 at 01:20

            I'm not quite sure why you have a problem with the output of the filter. Maybe the following will make it apparent to you how the filter functions.

            Here is your data in one table, slightly rearranged:

            Source https://stackoverflow.com/questions/71274785

            QUESTION

            how should i deal with this error on gridsearch and multisearch with pyweka?
            Asked 2022-Feb-21 at 22:40

            I have this code for gridsearch:

            ...

            ANSWER

            Answered 2022-Feb-21 at 22:40

            The exceptions that you listed do not affect the script execution, as they get handled internally by pww3 (error output could not be suppressed, unfortunately, despite catching the exceptions; this gets output by the underlying javabridge library).

            A bit of background: Since pww3 can run with and without package support, it first tries to load classes using the Java classloader. If that fails (that's the error message that you see), it will try loading them using Weka's mechanism for loading classes.

            The just released version 0.2.7 of pww3 approaches this a bit more intelligent and avoids the output of these exceptions.

            Final note: you need to drop the classifier. prefix in your property names when using MultiSearch.

            Source https://stackoverflow.com/questions/71131619

            QUESTION

            different tree for the same data set
            Asked 2022-Feb-21 at 19:57

            I am working on Pima Indians Diabetes Database in Weka. I noticed that for decision tree J48 the tree is smaller as compared to the Random Tree. I am unable to understand why it is like this? Thank you.

            ...

            ANSWER

            Answered 2022-Feb-21 at 19:57

            Though they both are decision trees, they employ different algorithms for constructing the tree, which will (most likely) give you a different outcome:

            • J48 prunes the tree by default after it built its tree (Wikipedia).
            • RandomTree (when using default parameters) inspects a maximum of log2(num_attributes) attributes for generating splits.

            Source https://stackoverflow.com/questions/71201615

            QUESTION

            Why doesn't this data work with the Naïve Bayes algorithm?
            Asked 2022-Jan-04 at 21:03

            It is in ARFF format. If you're not familiar with ARFF, it's basically that everything under the @data marker is in CSV.

            For clarification, I am trying to use the dataset on Weka but the option to use Naïve Bayes is greyed out.

            ...

            ANSWER

            Answered 2022-Jan-04 at 21:03

            Every classifier, clusterer, filter etc in Weka can only handle certain types of data, i.e., its capabilities (which you can check in GUI). These capabilities are then compared against the data. In case of a mismatch, the GUI won't allow you to apply the algorithm.

            Long story short: the dport attribute is of type string which NaiveBayes can't handle. You can convert that attribute into a nominal one using the StringToNominal filter.

            Source https://stackoverflow.com/questions/70566997

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install weka

            First install the Weka and LibSVM Java libraries. On Debian/Ubuntu this is simply:.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            Install
          • PyPI

            pip install weka

          • CLONE
          • HTTPS

            https://github.com/chrisspen/weka.git

          • CLI

            gh repo clone chrisspen/weka

          • sshUrl

            git@github.com:chrisspen/weka.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link