def weka_local_generic_learner(input_dict): if not jp.isThreadAttachedToJVM(): jp.attachThreadToJVM() model = jp.JClass(input_dict['weka_class'])() model.setOptions(common.parse_options(input_dict['params'])) sclassifier = common.serialize_weka_object(model) return {'Generic_Weka_learner': sclassifier}
def weka_local_libsvm(input_dict): if not jp.isThreadAttachedToJVM(): jp.attachThreadToJVM() model = jp.JClass('weka.classifiers.functions.LibSVM')() model.setOptions(common.parse_options(input_dict['params'])) sclassifier = common.serialize_weka_object(model) return {'LibSVM_learner': sclassifier}
def weka_local_smo(input_dict): '''A support vector classifier, trained using the Sequential Minimal Optimization (SMO) algorithm ''' if not jp.isThreadAttachedToJVM(): jp.attachThreadToJVM() model = jp.JClass('weka.classifiers.functions.SMO')() model.setOptions(common.parse_options(input_dict['params'])) sclassifier = common.serialize_weka_object(model) return {'SMO_learner': sclassifier}
def weka_local_random_forest(input_dict): '''Random Forest learner by Weka ''' if not jp.isThreadAttachedToJVM(): jp.attachThreadToJVM() model = jp.JClass('weka.classifiers.trees.RandomForest')() model.setOptions(common.parse_options(input_dict['params'])) sclassifier = common.serialize_weka_object(model) return {'RandomForest_learner': sclassifier}
def weka_local_rep_tree(input_dict): '''A REP Tree, which is a fast decision tree learner. Builds a decision/regression tree using information gain/variance and prunes it using reduced-error pruning ''' if not jp.isThreadAttachedToJVM(): jp.attachThreadToJVM() model = jp.JClass('weka.classifiers.trees.REPTree')() model.setOptions(common.parse_options(input_dict['params'])) sclassifier = common.serialize_weka_object(model) return {'REPTree_learner': sclassifier}
def weka_local_k_star(input_dict): '''Instance-Based learner K* by Weka ''' if not jp.isThreadAttachedToJVM(): jp.attachThreadToJVM() model = jp.JClass('weka.classifiers.lazy.KStar')() model.setOptions(common.parse_options(input_dict['params'])) sclassifier = common.serialize_weka_object(model) return {'KStar_learner': sclassifier}
def weka_local_naive_bayes(input_dict): '''Naive Bayes classifier provided by Weka. Naive Bayes is a simple probabilistic classifier based on applying the Bayes' theorem. ''' if not jp.isThreadAttachedToJVM(): jp.attachThreadToJVM() model = jp.JClass('weka.classifiers.bayes.NaiveBayes')() model.setOptions(common.parse_options(input_dict['params'])) sclassifier = common.serialize_weka_object(model) return {'Naive_Bayes_learner': sclassifier}
def weka_local_zeror(input_dict): '''Weka's rulesZeroR classifier: predicts the mean (for a numeric class) or the mode (for a nominal class). ''' if not jp.isThreadAttachedToJVM(): jp.attachThreadToJVM() model = jp.JClass('weka.classifiers.rules.ZeroR')() model.setOptions(common.parse_options(input_dict['params'])) sclassifier = common.serialize_weka_object(model) return {'classifier': sclassifier}
def weka_local_jrip(input_dict): '''The RIPPER rule learner by Weka ''' if not jp.isThreadAttachedToJVM(): jp.attachThreadToJVM() model = jp.JClass('weka.classifiers.rules.JRip')() model.setOptions(common.parse_options(input_dict['params'])) sclassifier = common.serialize_weka_object(model) return {'JRip_learner': sclassifier}
def weka_local_multilayer_perceptron(input_dict): '''Feedforward artificial neural network, using backpropagation to classify instances ''' if not jp.isThreadAttachedToJVM(): jp.attachThreadToJVM() model = jp.JClass('weka.classifiers.functions.MultilayerPerceptron')() model.setOptions(common.parse_options(input_dict['params'])) sclassifier = common.serialize_weka_object(model) return {'Multilayer_Perceptron_learner': sclassifier}
def weka_local_random_tree(input_dict): '''A tree that considers K randomly chosen attributes at each node, and performs no pruning ''' if not jp.isThreadAttachedToJVM(): jp.attachThreadToJVM() model = jp.JClass('weka.classifiers.trees.RandomTree')() model.setOptions(common.parse_options(input_dict['params'])) sclassifier = common.serialize_weka_object(model) return {'RandomTree_learner': sclassifier}
def weka_local_j48(input_dict): '''Weka decision tree learner J48 ''' if not jp.isThreadAttachedToJVM(): jp.attachThreadToJVM() model = jp.JClass('weka.classifiers.trees.J48')() model.setOptions(common.parse_options(input_dict['params'])) sclassifier = common.serialize_weka_object(model) return {'J48_learner': sclassifier}
def weka_local_ibk(input_dict): '''K-nearest neighbours classifier by Weka ''' if not jp.isThreadAttachedToJVM(): jp.attachThreadToJVM() model = jp.JClass('weka.classifiers.lazy.IBk')() model.setOptions(common.parse_options(input_dict['params'])) sclassifier = common.serialize_weka_object(model) return {'IBk_learner': sclassifier}
def random_tree(params=None): '''A tree that considers K randomly chosen attributes at each node, and performs no pruning :param params: parameters in textual form to pass to the RandomTree Weka class :return: a WekaClassifier object ''' if not jp.isThreadAttachedToJVM(): jp.attachThreadToJVM() model = jp.JClass('weka.classifiers.trees.RandomTree')() model.setOptions(common.parse_options(params)) return WekaClassifier(common.serialize_weka_object(model))
def multilayer_perceptron(params=None): '''Feedforward artificial neural network, using backpropagation to classify instances :param params: parameters in textual form to pass to the MultilayerPerceptron Weka class :return: a WekaClassifier object ''' if not jp.isThreadAttachedToJVM(): jp.attachThreadToJVM() model = jp.JClass('weka.classifiers.functions.MultilayerPerceptron')() model.setOptions(common.parse_options(params)) return WekaClassifier(common.serialize_weka_object(model))
def rep_tree(params=None): '''A REP Tree, which is a fast decision tree learner. Builds a decision/regression tree using information gain/variance and prunes it using reduced-error pruning :param params: parameters in textual form to pass to the REPTree Weka class :return: a WekaClassifier object ''' if not jp.isThreadAttachedToJVM(): jp.attachThreadToJVM() model = jp.JClass('weka.classifiers.trees.REPTree')() model.setOptions(common.parse_options(params)) return WekaClassifier(common.serialize_weka_object(model))
def naive_bayes(params=None): '''Naive Bayes classifier provided by Weka. Naive Bayes is a simple probabilistic classifier based on applying the Bayes' theorem. :param params: parameters in textual form to pass to the NaiveBayes Weka class :return: a WekaClassifier object ''' if not jp.isThreadAttachedToJVM(): jp.attachThreadToJVM() model = jp.JClass('weka.classifiers.bayes.NaiveBayes')() model.setOptions(common.parse_options(params)) return WekaClassifier(common.serialize_weka_object(model))
def smo(params=None): '''A support vector classifier, trained using the Sequential Minimal Optimization (SMO) algorithm :param params: parameters in textual form to pass to the SMO Weka class :return: a WekaClassifier object ''' if not jp.isThreadAttachedToJVM(): jp.attachThreadToJVM() model = jp.JClass('weka.classifiers.functions.SMO')() model.setOptions(common.parse_options(params)) return WekaClassifier(common.serialize_weka_object(model))
def random_forest(params=None): '''Random Forest learner by Weka :param params: parameters in textual form to pass to the RandomForest Weka class :return: a WekaClassifier object ''' if not jp.isThreadAttachedToJVM(): jp.attachThreadToJVM() model = jp.JClass('weka.classifiers.trees.RandomForest')() model.setOptions(common.parse_options(params)) return WekaClassifier(common.serialize_weka_object(model))
def k_star(params=None): '''Instance-Based learner K* by Weka :param params: parameters in textual form to pass to the KStar Weka class :return: a WekaClassifier object ''' if not jp.isThreadAttachedToJVM(): jp.attachThreadToJVM() model = jp.JClass('weka.classifiers.lazy.KStar')() model.setOptions(common.parse_options(params)) return WekaClassifier(common.serialize_weka_object(model))
def rules_zeror(params=None): '''Weka's rulesZeroR classifier: predicts the mean (for a numeric class) or the mode (for a nominal class). :param params: parameters in textual form to pass to the rulesZeroR Weka class :return: a WekaClassifier object ''' if not jp.isThreadAttachedToJVM(): jp.attachThreadToJVM() model = jp.JClass('weka.classifiers.rules.ZeroR')() model.setOptions(common.parse_options(params)) return WekaClassifier(common.serialize_weka_object(model))
def rules_jrip(params=None): '''The RIPPER rule learner by Weka :param params: parameters in textual form to pass to the JRip Weka class :return: a WekaClassifier object ''' if not jp.isThreadAttachedToJVM(): jp.attachThreadToJVM() model = jp.JClass('weka.classifiers.rules.JRip')() model.setOptions(common.parse_options(params)) return WekaClassifier(common.serialize_weka_object(model))
def ibk(params=None): '''K-nearest neighbours classifier by Weka :param params: parameters in textual form to pass to the IBk Weka class :return: a WekaClassifier object ''' if not jp.isThreadAttachedToJVM(): jp.attachThreadToJVM() model = jp.JClass('weka.classifiers.lazy.IBk')() model.setOptions(common.parse_options(params)) return WekaClassifier(common.serialize_weka_object(model))
def logistic(params=None): '''Logistic regression by Weka :param params: parameters in textual form to pass to the Logistic Weka class :return: a WekaClassifier object ''' if not jp.isThreadAttachedToJVM(): jp.attachThreadToJVM() model = jp.JClass('weka.classifiers.functions.Logistic')() model.setOptions(common.parse_options(params)) return WekaClassifier(common.serialize_weka_object(model))
def j48(params=None): '''Weka decision tree learner J48 :param params: parameters in textual form to pass to the J48 Weka class (e.g. "-C 0.25 -M 2") :return: a WekaClassifier object ''' if not jp.isThreadAttachedToJVM(): jp.attachThreadToJVM() model = jp.JClass('weka.classifiers.trees.J48')() model.setOptions(common.parse_options(params)) return WekaClassifier(common.serialize_weka_object(model))
def determine_analyzer_path(self): """Determine the path of the analyzer. Basically creating a temporary directory in the systemdrive, i.e., C:\\.""" systemdrive = self.determine_system_drive() options = parse_options(self.options["options"]) if options.get("analpath"): dirpath = systemdrive + options["analpath"] r = self.post("/mkdir", data={"dirpath": dirpath}) self.analyzer_path = dirpath else: r = self.post("/mkdtemp", data={"dirpath": systemdrive}) self.analyzer_path = r.json()["dirpath"]
def normalize(bunch, params=None): '''Normalizes all numeric values in the given dataset (apart from the class attribute, if set) :param bunch: dataset :param params: parameters in textual form to pass to the Normalize Weka class :return: dataset ''' if not jp.isThreadAttachedToJVM(): jp.attachThreadToJVM() # Instances data! data = utilities.convertBunchToWekaInstances(bunch) Filter = jp.JClass('weka.filters.Filter') Normalize = jp.JClass('weka.filters.unsupervised.attribute.Normalize') normalize_filter = Normalize() normalize_filter.setOptions(common.parse_options(params)) normalize_filter.setInputFormat(data) new_instances = Filter.useFilter(data, normalize_filter) return utilities.convertWekaInstancesToBunch(new_instances)
def handle_use(man, match): options = common.parse_options(man, match.group("options"), [("sep", "."), ("ref", None)]) man.doxygen.add_use(match.group("path"), options["sep"], options["ref"])
#!/usr/bin/env python from __future__ import print_function import os.path import common import utils.file_utils as file_utils import utils.mvn_utils as mvn_utils (ROOT_PROJECT_PATH, MAVEN_REPO_PATH, MVN_OPTS, ROOT_ONLY, TRACK_UNVERSIONED, vcs_gateway) = common.parse_options() def is_important(file_path): return not file_path.endswith(".iml") def get_unique_name(root_project_path): if os.name == 'nt': result = root_project_path.replace('\\', "_") else: result = root_project_path.replace('/', "_") result = result.replace(":", "_") return result changed_files = vcs_gateway.get_local_changed_files(ROOT_PROJECT_PATH, not TRACK_UNVERSIONED) important_files = filter(is_important, changed_files)
#!/usr/bin/env python import os.path import sys import common import utils.collections as collections import utils.file_utils as file_utils import utils.mvn_utils as mvn_utils (ROOT_PROJECT_PATH, MAVEN_REPO_PATH, MVN_OPTS, ROOT_ONLY, track_unversioned, vcs_gateway) = common.parse_options() def incremental_rebuild(last_revision, current_revision): changed_files = vcs_gateway.get_revision_changed_files(ROOT_PROJECT_PATH, last_revision, current_revision) changed_project_poms = set([]) for file_path in changed_files: file_path = file_utils.normalize_path(file_path) if os.path.isdir(file_path): parent_path = file_path else: parent_path = os.path.dirname(file_path) while parent_path and not (file_utils.is_root(parent_path)): pom_path = os.path.join(parent_path, "pom.xml") if os.path.exists(pom_path):
#!/usr/bin/env python from __future__ import print_function import os.path import common import utils.file_utils as file_utils import utils.mvn_utils as mvn_utils (ROOT_PROJECT_PATH, MAVEN_REPO_PATH, MVN_OPTS, ROOT_ONLY, TRACK_UNVERSIONED, vcs_gateway) = common.parse_options() def is_important(file_path): return not file_path.endswith(".iml") def get_unique_name(root_project_path): if os.name == 'nt': result = root_project_path.replace('\\', "_") else: result = root_project_path.replace('/', "_") result = result.replace(":", "_") return result changed_files = vcs_gateway.get_local_changed_files(ROOT_PROJECT_PATH, not TRACK_UNVERSIONED) important_files = filter(is_important, changed_files) pom_paths = set([])