def remove_package(pkg):
    if packages.is_installed(pkg):
        print("Removing %s..." % pkg)
        packages.uninstall_package(pkg)
        print("Removed %s, please re-run script!" % pkg)
        jvm.stop()
        sys.exit(0)
    print('No such package is installed')
Esempio n. 2
0
def uninstall_unofficial_packages(path):
    with open(path, "r") as f:
        weka_packages = json.load(f)
        for package_name, package_path in weka_packages.items():
            if package_name != package_path and packages.is_installed(
                    package_name):
                v.app.logger.info("Uninstalling %s", package_name)
                packages.uninstall_package(package_name)
def install_package(pkg):
    # install weka package if necessary
    if not packages.is_installed(pkg):
        print("Installing %s..." % pkg)
        packages.install_package(pkg)
        print("Installed %s, please re-run script!" % pkg)
        jvm.stop()
        sys.exit(0)
    print('Package already installed.')
def main():
    if not is_installed("CLOPE"):
        print("CLOPE is not installed, installing now")
        install_package("CLOPE")
        print("please restart")
        return

    cls = Clusterer(classname="weka.clusterers.CLOPE")
    print("CLOPE is installed:", cls.to_commandline())
Esempio n. 5
0
def install_packages(path):
    """Install weka packages

    Arguments:
        path {str} -- path to install weka packages json
    """

    with open(path, "r") as f:
        weka_packages = json.load(f)
        for package_name, package_path in weka_packages.items():
            if not packages.is_installed(package_name):
                v.app.logger.info("Installing: %s %s", package_name,
                                  package_path)
                packages.install_package(package_path)
Esempio n. 6
0
import weka.core.jvm as jvm
import weka.core.packages as packages
from weka.core.classes import complete_classname

jvm.start(packages=True)

pkg = "SMOTE"

# install package if necessary
if not packages.is_installed(pkg):
    print("Installing %s..." % pkg)
    packages.install_package(pkg)
    print("Installed %s, please re-run script!" % pkg)
    jvm.stop()

# testing classname completion
print(complete_classname(".SMOTE"))

jvm.stop()
Esempio n. 7
0
import os

data_dir = os.environ.get("WEKAMOOC_DATA")
if data_dir is None:
    data_dir = "." + os.sep + "data"

import weka.core.jvm as jvm
from weka.core.converters import Loader
from weka.core.classes import Random
import weka.core.packages as packages
from weka.classifiers import Classifier, Evaluation

jvm.start(packages=True)

# install stackingC if necessary
if not packages.is_installed("stackingC"):
    print("Installing stackingC...")
    packages.install_package("stackingC")
    jvm.stop()
    print("Installed package, please restart")
    exit()

# load glass
loader = Loader(classname="weka.core.converters.ArffLoader")
fname = data_dir + os.sep + "glass.arff"
print("\nLoading dataset: " + fname + "\n")
data = loader.load_file(fname)
data.class_is_last()

# compare several meta-classifiers with J48
for classifier in [("weka.classifiers.trees.J48", []),
Esempio n. 8
0
import os
data_dir = os.environ.get("WEKAMOOC_DATA")
if data_dir is None:
  data_dir = "." + os.sep + "data"

import os
import weka.core.jvm as jvm
from weka.core.converters import Loader
from weka.core.classes import Random
import weka.core.packages as packages
from weka.classifiers import Classifier, Evaluation

jvm.start(packages=True)

# install stackingC if necessary
if not packages.is_installed("stackingC"):
    print("Installing stackingC...")
    packages.install_package("stackingC")
    jvm.stop()
    print("Please restart")
    exit()

# load glass
loader = Loader(classname="weka.core.converters.ArffLoader")
fname = data_dir + os.sep + "glass.arff"
print("\nLoading dataset: " + fname + "\n")
data = loader.load_file(fname)
data.set_class_index(data.num_attributes() - 1)

# compare several meta-classifiers with J48
for classifier in [("weka.classifiers.trees.J48", []), ("weka.classifiers.meta.Bagging", []),
Esempio n. 9
0
import os
data_dir = os.environ.get("WEKAMOOC_DATA")
if data_dir is None:
  data_dir = "." + os.sep + "data"

import os
import weka.core.jvm as jvm
import weka.core.packages as packages
from weka.core.converters import Loader
from weka.core.classes import Random
from weka.classifiers import Classifier, Evaluation

jvm.start(packages=True)

pkg = "simpleEducationalLearningSchemes"
if not packages.is_installed(pkg):
    packages.install_package(pkg):
    jvm.stop()
    print("Please restart")
    exit()

# load weather.nominal
fname = data_dir + os.sep + "weather.nominal.arff"
print("\nLoading dataset: " + fname + "\n")
loader = Loader(classname="weka.core.converters.ArffLoader")
data = loader.load_file(fname)
data.set_class_index(data.num_attributes() - 1)

# cross-validate classifiers
classifiers = [
    "weka.classifiers.trees.J48",
Esempio n. 10
0
import weka.core.packages as packages
from weka.classifiers import Classifier, Evaluation
import os
from weka.core.converters import Loader
from weka.attribute_selection import ASSearch, ASEvaluation, AttributeSelection
from weka.filters import Filter

########SetUp########################
os.environ["WEKA_HOME"] = os.path.abspath(
    "./weka-3-8-4")  #point it to your weka instalation folder
jvm.start(packages=True, max_heap_size='6g')
#####################################

########Install######################
packages.refresh_cache()
if not packages.is_installed('discriminantAnalysis'):
    print("Installing discriminantAnalysis")
    packages.install_package('discriminantAnalysis')
if not packages.is_installed('PBC4cip'):
    print("Installing PBC4cip")
    packages.install_package(os.path.abspath('./weka_packages/PBC4cip.zip'))
######################################

#############Data#####################
loader = Loader(classname="weka.core.converters.ArffLoader")
data = loader.load_file(os.path.abspath('./universities.arff'))
data.class_is_last()
######################################

#######rub1########################
print("rub1")