Introduction¶
python-weka-wrapper3 allows you to use Weka from within Python3.
The library uses the jpype library for starting up, communicating with and shutting down the Java Virtual Machine in which the Weka processes get executed.
python-weka-wrapper3 provides a thin wrapper around the basic (non-GUI) functionality of Weka (some plots are available using Python functionality). You can automatically add all your Weka packages to the classpath. Additional jars can be added as well.
Links:
Looking for code?
Questions? You can post them in the project’s Google Group
Requirements¶
The library has the following requirements:
Python 3 (does not work with Python 2)
jpype (required)
pygraphviz (optional)
PIL (optional)
matplotlib (optional)
lxml (optional)
OpenJDK 11 (or later)
Uses:
Weka (3.9.6)
Contents¶
- Installation
- Docker
- Troubleshooting
- Examples
- Start up JVM
- Location of the datasets
- Load dataset and print it
- Create dataset manually
- Create dataset from lists
- Create dataset from matrices
- Dataset subsets
- Data generators
- Filters
- Output help from underlying OptionHandler
- Option handling
- Build classifier on dataset, output predictions
- Build classifier on dataset, print model and draw graph
- Build classifier incrementally with data and print model
- Cross-validate filtered classifier and print evaluation and display ROC
- Cross-validate regressor, display classifier errors and predictions
- Parameter optimization - property names
- Parameter optimization - GridSearch
- Parameter optimization - MultiSearch
- Clustering
- Associations
- Attribute selection
- Timeseries
- Serialization
- Experiments
- Partial classnames
- Packages
- Stop JVM
- Database access
- Recreating environments
- Command-line
- Development
- Flow
API¶
- weka package
- Subpackages
- weka.core package
- weka.core.capabilities module
- weka.core.classes module
- weka.core.converters module
- weka.core.database module
- weka.core.dataset module
- weka.core.distances module
- weka.core.jvm module
- weka.core.packages module
- weka.core.serialization module
- weka.core.stemmers module
- weka.core.stopwords module
- weka.core.tokenizers module
- weka.core.typeconv module
- weka.core.utils module
- weka.core.version module
- Module contents
- weka.flow package
- weka.plot package
- weka.core package
- weka.associations module
AssociationRule
AssociationRule.consequence
AssociationRule.consequence_support
AssociationRule.metric_names
AssociationRule.metric_value()
AssociationRule.metric_values
AssociationRule.premise
AssociationRule.premise_support
AssociationRule.primary_metric_name
AssociationRule.primary_metric_value
AssociationRule.to_dict()
AssociationRule.total_support
AssociationRule.total_transactions
AssociationRules
AssociationRulesIterator
Associator
Item
main()
sys_main()
- weka.attribute_selection module
ASEvaluation
ASSearch
AttributeSelection
AttributeSelection.attribute_selection()
AttributeSelection.crossvalidation()
AttributeSelection.cv_results
AttributeSelection.evaluator()
AttributeSelection.folds()
AttributeSelection.number_attributes_selected
AttributeSelection.rank_results
AttributeSelection.ranked_attributes
AttributeSelection.ranking()
AttributeSelection.reduce_dimensionality()
AttributeSelection.results_string
AttributeSelection.search()
AttributeSelection.seed()
AttributeSelection.select_attributes()
AttributeSelection.select_attributes_cv_split()
AttributeSelection.selected_attributes
AttributeSelection.subset_results
main()
sys_main()
- weka.classifiers module
AttributeSelectedClassifier
Classifier
Classifier.additional_measure()
Classifier.additional_measures
Classifier.batch_size
Classifier.build_classifier()
Classifier.capabilities
Classifier.classify_instance()
Classifier.deserialize()
Classifier.distribution_for_instance()
Classifier.distributions_for_instances()
Classifier.graph
Classifier.graph_type
Classifier.has_efficient_batch_prediction()
Classifier.header
Classifier.make_copy()
Classifier.serialize()
Classifier.to_source()
Classifier.update_classifier()
CostMatrix
CostMatrix.apply_cost_matrix()
CostMatrix.expected_costs()
CostMatrix.get_cell()
CostMatrix.get_element()
CostMatrix.get_max_cost()
CostMatrix.initialize()
CostMatrix.normalize()
CostMatrix.num_columns
CostMatrix.num_rows
CostMatrix.parse_matlab()
CostMatrix.set_cell()
CostMatrix.set_element()
CostMatrix.size
CostMatrix.to_matlab()
Evaluation
Evaluation.area_under_prc()
Evaluation.area_under_roc()
Evaluation.avg_cost
Evaluation.class_details()
Evaluation.class_priors
Evaluation.confusion_matrix
Evaluation.correct
Evaluation.correlation_coefficient
Evaluation.coverage_of_test_cases_by_predicted_regions
Evaluation.crossvalidate_model()
Evaluation.cumulative_margin_distribution()
Evaluation.discard_predictions
Evaluation.error_rate
Evaluation.evaluate_model()
Evaluation.evaluate_train_test_split()
Evaluation.f_measure()
Evaluation.false_negative_rate()
Evaluation.false_positive_rate()
Evaluation.header
Evaluation.incorrect
Evaluation.kappa
Evaluation.kb_information
Evaluation.kb_mean_information
Evaluation.kb_relative_information
Evaluation.matrix()
Evaluation.matthews_correlation_coefficient()
Evaluation.mean_absolute_error
Evaluation.mean_prior_absolute_error
Evaluation.num_false_negatives()
Evaluation.num_false_positives()
Evaluation.num_instances
Evaluation.num_true_negatives()
Evaluation.num_true_positives()
Evaluation.percent_correct
Evaluation.percent_incorrect
Evaluation.percent_unclassified
Evaluation.precision()
Evaluation.predictions
Evaluation.recall()
Evaluation.relative_absolute_error
Evaluation.root_mean_prior_squared_error
Evaluation.root_mean_squared_error
Evaluation.root_relative_squared_error
Evaluation.sf_entropy_gain
Evaluation.sf_mean_entropy_gain
Evaluation.sf_mean_prior_entropy
Evaluation.sf_mean_scheme_entropy
Evaluation.sf_prior_entropy
Evaluation.sf_scheme_entropy
Evaluation.size_of_predicted_regions
Evaluation.summary()
Evaluation.test_model()
Evaluation.test_model_once()
Evaluation.total_cost
Evaluation.true_negative_rate()
Evaluation.true_positive_rate()
Evaluation.unclassified
Evaluation.unweighted_macro_f_measure
Evaluation.unweighted_micro_f_measure
Evaluation.weighted_area_under_prc
Evaluation.weighted_area_under_roc
Evaluation.weighted_f_measure
Evaluation.weighted_false_negative_rate
Evaluation.weighted_false_positive_rate
Evaluation.weighted_matthews_correlation
Evaluation.weighted_precision
Evaluation.weighted_recall
Evaluation.weighted_true_negative_rate
Evaluation.weighted_true_positive_rate
FilteredClassifier
GridSearch
Kernel
KernelClassifier
MultiSearch
MultipleClassifiersCombiner
NominalPrediction
NumericPrediction
Prediction
PredictionOutput
SingleClassifierEnhancer
main()
predictions_to_instances()
sys_main()
- weka.clusterers module
ClusterEvaluation
ClusterEvaluation.classes_to_clusters
ClusterEvaluation.cluster_assignments
ClusterEvaluation.cluster_results
ClusterEvaluation.crossvalidate_model()
ClusterEvaluation.evaluate_clusterer()
ClusterEvaluation.log_likelihood
ClusterEvaluation.num_clusters
ClusterEvaluation.set_model()
ClusterEvaluation.test_model()
Clusterer
Clusterer.build_clusterer()
Clusterer.capabilities
Clusterer.cluster_instance()
Clusterer.deserialize()
Clusterer.distribution_for_instance()
Clusterer.graph
Clusterer.graph_type
Clusterer.header
Clusterer.make_copy()
Clusterer.number_of_clusters
Clusterer.serialize()
Clusterer.update_clusterer()
Clusterer.update_finished()
FilteredClusterer
SingleClustererEnhancer
avg_silhouette_coefficient()
main()
sys_main()
- weka.datagenerators module
DataGenerator
DataGenerator.dataset_format
DataGenerator.define_data_format()
DataGenerator.generate_example()
DataGenerator.generate_examples()
DataGenerator.generate_finish()
DataGenerator.generate_start()
DataGenerator.make_copy()
DataGenerator.make_data()
DataGenerator.num_examples_act
DataGenerator.single_mode_flag
main()
sys_main()
- weka.experiments module
Experiment
ResultMatrix
ResultMatrix.average()
ResultMatrix.columns
ResultMatrix.get_col_name()
ResultMatrix.get_mean()
ResultMatrix.get_row_name()
ResultMatrix.get_stdev()
ResultMatrix.hide_col()
ResultMatrix.hide_row()
ResultMatrix.is_col_hidden()
ResultMatrix.is_row_hidden()
ResultMatrix.rows
ResultMatrix.set_col_name()
ResultMatrix.set_mean()
ResultMatrix.set_row_name()
ResultMatrix.set_stdev()
ResultMatrix.show_col()
ResultMatrix.show_row()
ResultMatrix.to_string_header()
ResultMatrix.to_string_key()
ResultMatrix.to_string_matrix()
ResultMatrix.to_string_ranking()
ResultMatrix.to_string_summary()
SimpleCrossValidationExperiment
SimpleExperiment
SimpleRandomSplitExperiment
Tester
- weka.filters module
- weka.timeseries module
ConfidenceIntervalForecaster
CustomPeriodicTest
ErrorModule
IncrementallyPrimeable
OverlayForecaster
Periodicity
PeriodicityHandler
TSEvalModule
TSEvaluation
TSEvaluation.evaluate()
TSEvaluation.evaluate_forecaster()
TSEvaluation.evaluate_on_test_data
TSEvaluation.evaluate_on_training_data
TSEvaluation.evaluation_modules
TSEvaluation.forecast_future
TSEvaluation.horizon
TSEvaluation.predictions_for_test_data()
TSEvaluation.predictions_for_training_data()
TSEvaluation.prime_for_test_data_with_test_data
TSEvaluation.prime_window_size
TSEvaluation.print_future_forecast_on_test_data()
TSEvaluation.print_future_forecast_on_training_data()
TSEvaluation.print_predictions_for_test_data()
TSEvaluation.print_predictions_for_training_data()
TSEvaluation.rebuild_model_after_each_test_forecast_step
TSEvaluation.summary()
TSEvaluation.test_data
TSEvaluation.training_data
TSForecaster
TSForecaster.algorithm_name
TSForecaster.base_model_has_serializer
TSForecaster.build_forecaster()
TSForecaster.clear_previous_state()
TSForecaster.fields_to_forecast
TSForecaster.forecast()
TSForecaster.header
TSForecaster.load_base_model()
TSForecaster.load_serialized_state()
TSForecaster.previous_state
TSForecaster.prime_forecaster()
TSForecaster.reset()
TSForecaster.run_forecaster()
TSForecaster.save_base_model()
TSForecaster.serialize_state()
TSForecaster.uses_state
TSLagMaker
TSLagMaker.add_am_indicator
TSLagMaker.add_custom_periodic()
TSLagMaker.add_day_of_month
TSLagMaker.add_day_of_week
TSLagMaker.add_month_of_year
TSLagMaker.add_num_days_in_month
TSLagMaker.add_quarter_of_year
TSLagMaker.add_weekend_indicator
TSLagMaker.adjust_for_trends
TSLagMaker.adjust_for_variance
TSLagMaker.artificial_time_start_value
TSLagMaker.average_consecutive_long_lags
TSLagMaker.average_lags_after
TSLagMaker.clear_custom_periodics()
TSLagMaker.clear_lag_histories()
TSLagMaker.create_time_lag_cross_products()
TSLagMaker.current_timestamp_value
TSLagMaker.delta_time
TSLagMaker.fields_to_lag
TSLagMaker.fields_to_lag_as_string
TSLagMaker.include_powers_of_time
TSLagMaker.include_timelag_products
TSLagMaker.increment_artificial_time_value()
TSLagMaker.is_using_artificial_time_index
TSLagMaker.lag_range
TSLagMaker.max_lag
TSLagMaker.min_lag
TSLagMaker.num_consecutive_long_lags_to_average
TSLagMaker.overlay_fields
TSLagMaker.periodicity
TSLagMaker.primary_periodic_field_name
TSLagMaker.remove_leading_instances_with_unknown_lag_values
TSLagMaker.skip_entries
TSLagMaker.timestamp_field
TSLagMaker.transformed_data()
TSLagUser
TestPart
WekaForecaster
- Subpackages