├── .gitignore ├── AndroidManifest.xml ├── README ├── project.properties └── src └── weka ├── associations ├── AbstractAssociator.java ├── Apriori.java ├── AprioriItemSet.java ├── AssociationRule.java ├── AssociationRules.java ├── AssociationRulesProducer.java ├── Associator.java ├── AssociatorEvaluation.java ├── BinaryItem.java ├── CARuleMiner.java ├── CheckAssociator.java ├── DefaultAssociationRule.java ├── FPGrowth.java ├── FilteredAssociationRules.java ├── FilteredAssociator.java ├── Item.java ├── ItemSet.java ├── LabeledItemSet.java ├── NominalItem.java ├── NumericItem.java └── SingleAssociatorEnhancer.java ├── attributeSelection ├── ASEvaluation.java ├── ASSearch.java ├── AttributeEvaluator.java ├── AttributeSelection.java ├── AttributeSetEvaluator.java ├── AttributeTransformer.java ├── BestFirst.java ├── CfsSubsetEval.java ├── CheckAttributeSelection.java ├── CorrelationAttributeEval.java ├── ErrorBasedMeritEvaluator.java ├── GainRatioAttributeEval.java ├── GreedyStepwise.java ├── HoldOutSubsetEvaluator.java ├── InfoGainAttributeEval.java ├── OneRAttributeEval.java ├── PrincipalComponents.java ├── RankedOutputSearch.java ├── Ranker.java ├── ReliefFAttributeEval.java ├── StartSetHandler.java ├── SubsetEvaluator.java ├── SymmetricalUncertAttributeEval.java ├── UnsupervisedAttributeEvaluator.java ├── UnsupervisedSubsetEvaluator.java └── WrapperSubsetEval.java ├── classifiers ├── AbstractClassifier.java ├── AggregateableEvaluation.java ├── BVDecompose.java ├── BVDecomposeSegCVSub.java ├── CheckClassifier.java ├── CheckSource.java ├── Classifier.java ├── ConditionalDensityEstimator.java ├── CostMatrix.java ├── Evaluation.java ├── IntervalEstimator.java ├── IteratedSingleClassifierEnhancer.java ├── IterativeClassifier.java ├── MultipleClassifiersCombiner.java ├── ParallelIteratedSingleClassifierEnhancer.java ├── ParallelMultipleClassifiersCombiner.java ├── RandomizableClassifier.java ├── RandomizableIteratedSingleClassifierEnhancer.java ├── RandomizableMultipleClassifiersCombiner.java ├── RandomizableParallelIteratedSingleClassifierEnhancer.java ├── RandomizableParallelMultipleClassifiersCombiner.java ├── RandomizableSingleClassifierEnhancer.java ├── SingleClassifierEnhancer.java ├── Sourcable.java ├── UpdateableClassifier.java ├── bayes │ ├── BayesNet.java │ ├── NaiveBayes.java │ ├── NaiveBayesMultinomial.java │ ├── NaiveBayesMultinomialText.java │ ├── NaiveBayesMultinomialUpdateable.java │ ├── NaiveBayesUpdateable.java │ └── net │ │ ├── ADNode.java │ │ ├── BIFReader.java │ │ ├── BayesNetGenerator.java │ │ ├── EditableBayesNet.java │ │ ├── MarginCalculator.java │ │ ├── ParentSet.java │ │ ├── VaryNode.java │ │ ├── estimate │ │ ├── BMAEstimator.java │ │ ├── BayesNetEstimator.java │ │ ├── DiscreteEstimatorBayes.java │ │ ├── DiscreteEstimatorFullBayes.java │ │ ├── MultiNomialBMAEstimator.java │ │ └── SimpleEstimator.java │ │ └── search │ │ ├── SearchAlgorithm.java │ │ ├── ci │ │ ├── CISearchAlgorithm.java │ │ └── ICSSearchAlgorithm.java │ │ ├── fixed │ │ ├── FromFile.java │ │ └── NaiveBayes.java │ │ ├── global │ │ ├── GeneticSearch.java │ │ ├── GlobalScoreSearchAlgorithm.java │ │ ├── HillClimber.java │ │ ├── K2.java │ │ ├── RepeatedHillClimber.java │ │ ├── SimulatedAnnealing.java │ │ ├── TAN.java │ │ └── TabuSearch.java │ │ └── local │ │ ├── GeneticSearch.java │ │ ├── HillClimber.java │ │ ├── K2.java │ │ ├── LAGDHillClimber.java │ │ ├── LocalScoreSearchAlgorithm.java │ │ ├── RepeatedHillClimber.java │ │ ├── Scoreable.java │ │ ├── SimulatedAnnealing.java │ │ ├── TAN.java │ │ └── TabuSearch.java ├── evaluation │ ├── AbstractEvaluationMetric.java │ ├── AggregateableEvaluation.java │ ├── ConfusionMatrix.java │ ├── CostCurve.java │ ├── Evaluation.java │ ├── EvaluationUtils.java │ ├── InformationRetrievalEvaluationMetric.java │ ├── InformationTheoreticEvaluationMetric.java │ ├── IntervalBasedEvaluationMetric.java │ ├── MarginCurve.java │ ├── NominalPrediction.java │ ├── NumericPrediction.java │ ├── Prediction.java │ ├── StandardEvaluationMetric.java │ ├── ThresholdCurve.java │ ├── TwoClassStats.java │ └── output │ │ └── prediction │ │ ├── AbstractOutput.java │ │ ├── CSV.java │ │ ├── HTML.java │ │ ├── Null.java │ │ ├── PlainText.java │ │ └── XML.java ├── functions │ ├── GaussianProcesses.java │ ├── LinearRegression.java │ ├── Logistic.java │ ├── MultilayerPerceptron.java │ ├── SGD.java │ ├── SGDText.java │ ├── SMO.java │ ├── SMOreg.java │ ├── SimpleLinearRegression.java │ ├── SimpleLogistic.java │ ├── VotedPerceptron.java │ ├── neural │ │ ├── LinearUnit.java │ │ ├── NeuralConnection.java │ │ ├── NeuralMethod.java │ │ ├── NeuralNode.java │ │ └── SigmoidUnit.java │ └── supportVector │ │ ├── CachedKernel.java │ │ ├── CheckKernel.java │ │ ├── Kernel.java │ │ ├── KernelEvaluation.java │ │ ├── NormalizedPolyKernel.java │ │ ├── PolyKernel.java │ │ ├── PrecomputedKernelMatrixKernel.java │ │ ├── Puk.java │ │ ├── RBFKernel.java │ │ ├── RegOptimizer.java │ │ ├── RegSMO.java │ │ ├── RegSMOImproved.java │ │ ├── SMOset.java │ │ └── StringKernel.java ├── lazy │ ├── IBk.java │ ├── KStar.java │ ├── LWL.java │ └── kstar │ │ ├── KStarCache.java │ │ ├── KStarConstants.java │ │ ├── KStarNominalAttribute.java │ │ ├── KStarNumericAttribute.java │ │ └── KStarWrapper.java ├── meta │ ├── AdaBoostM1.java │ ├── AdditiveRegression.java │ ├── AttributeSelectedClassifier.java │ ├── Bagging.java │ ├── CVParameterSelection.java │ ├── ClassificationViaRegression.java │ ├── CostSensitiveClassifier.java │ ├── FilteredClassifier.java │ ├── LogitBoost.java │ ├── MultiClassClassifier.java │ ├── MultiClassClassifierUpdateable.java │ ├── MultiScheme.java │ ├── RandomCommittee.java │ ├── RandomSubSpace.java │ ├── RegressionByDiscretization.java │ ├── Stacking.java │ └── Vote.java ├── misc │ ├── InputMappedClassifier.java │ ├── InputMappedClassifierBeanInfo.java │ └── SerializedClassifier.java ├── pmml │ └── consumer │ │ ├── GeneralRegression.java │ │ ├── NeuralNetwork.java │ │ ├── PMMLClassifier.java │ │ ├── Regression.java │ │ ├── RuleSetModel.java │ │ ├── SupportVectorMachineModel.java │ │ └── TreeModel.java ├── rules │ ├── DecisionTable.java │ ├── DecisionTableHashKey.java │ ├── JRip.java │ ├── M5Rules.java │ ├── OneR.java │ ├── PART.java │ ├── Rule.java │ ├── RuleStats.java │ ├── ZeroR.java │ └── part │ │ ├── C45PruneableDecList.java │ │ ├── ClassifierDecList.java │ │ ├── MakeDecList.java │ │ └── PruneableDecList.java ├── trees │ ├── DecisionStump.java │ ├── HoeffdingTree.java │ ├── J48.java │ ├── LMT.java │ ├── M5P.java │ ├── REPTree.java │ ├── RandomForest.java │ ├── RandomTree.java │ ├── ht │ │ ├── ActiveHNode.java │ │ ├── ConditionalSufficientStats.java │ │ ├── GaussianConditionalSufficientStats.java │ │ ├── GiniSplitMetric.java │ │ ├── HNode.java │ │ ├── InactiveHNode.java │ │ ├── InfoGainSplitMetric.java │ │ ├── LeafNode.java │ │ ├── LearningNode.java │ │ ├── NBNode.java │ │ ├── NBNodeAdaptive.java │ │ ├── NominalConditionalSufficientStats.java │ │ ├── Split.java │ │ ├── SplitCandidate.java │ │ ├── SplitMetric.java │ │ ├── SplitNode.java │ │ ├── UnivariateNominalMultiwaySplit.java │ │ ├── UnivariateNumericBinarySplit.java │ │ └── WeightMass.java │ ├── j48 │ │ ├── BinC45ModelSelection.java │ │ ├── BinC45Split.java │ │ ├── C45ModelSelection.java │ │ ├── C45PruneableClassifierTree.java │ │ ├── C45Split.java │ │ ├── ClassifierSplitModel.java │ │ ├── ClassifierTree.java │ │ ├── Distribution.java │ │ ├── EntropyBasedSplitCrit.java │ │ ├── EntropySplitCrit.java │ │ ├── GainRatioSplitCrit.java │ │ ├── InfoGainSplitCrit.java │ │ ├── ModelSelection.java │ │ ├── NBTreeClassifierTree.java │ │ ├── NBTreeModelSelection.java │ │ ├── NBTreeNoSplit.java │ │ ├── NBTreeSplit.java │ │ ├── NoSplit.java │ │ ├── PruneableClassifierTree.java │ │ ├── SplitCriterion.java │ │ └── Stats.java │ ├── lmt │ │ ├── LMTNode.java │ │ ├── LogisticBase.java │ │ ├── ResidualModelSelection.java │ │ └── ResidualSplit.java │ └── m5 │ │ ├── CorrelationSplitInfo.java │ │ ├── Impurity.java │ │ ├── M5Base.java │ │ ├── PreConstructedLinearModel.java │ │ ├── Rule.java │ │ ├── RuleNode.java │ │ ├── SplitEvaluate.java │ │ ├── Values.java │ │ └── YongSplitInfo.java └── xml │ └── XMLClassifier.java ├── clusterers ├── AbstractClusterer.java ├── AbstractDensityBasedClusterer.java ├── CheckClusterer.java ├── ClusterEvaluation.java ├── Clusterer.java ├── Cobweb.java ├── DensityBasedClusterer.java ├── EM.java ├── FarthestFirst.java ├── FilteredClusterer.java ├── HierarchicalClusterer.java ├── MakeDensityBasedClusterer.java ├── NumberOfClustersRequestable.java ├── RandomizableClusterer.java ├── RandomizableDensityBasedClusterer.java ├── RandomizableSingleClustererEnhancer.java ├── SimpleKMeans.java ├── SingleClustererEnhancer.java └── UpdateableClusterer.java ├── core ├── AbstractInstance.java ├── AdditionalMeasureProducer.java ├── Aggregateable.java ├── AlgVector.java ├── AllJavadoc.java ├── Attribute.java ├── AttributeExpression.java ├── AttributeLocator.java ├── AttributeStats.java ├── BatchPredictor.java ├── BinarySparseInstance.java ├── Capabilities.java ├── CapabilitiesHandler.java ├── ChebyshevDistance.java ├── Check.java ├── CheckGOE.java ├── CheckOptionHandler.java ├── CheckScheme.java ├── ClassCache.java ├── ClassDiscovery.java ├── ClassloaderUtil.java ├── CommandlineRunnable.java ├── ConjugateGradientOptimization.java ├── ContingencyTables.java ├── Copyable.java ├── Copyright.java ├── CustomDisplayStringProvider.java ├── Debug.java ├── DenseInstance.java ├── DistanceFunction.java ├── Drawable.java ├── Environment.java ├── EnvironmentHandler.java ├── EuclideanDistance.java ├── FastVector.java ├── FindWithCapabilities.java ├── GlobalInfoJavadoc.java ├── Instance.java ├── InstanceComparator.java ├── Instances.java ├── Javadoc.java ├── ListOptions.java ├── ManhattanDistance.java ├── Matchable.java ├── MathematicalExpression.java ├── Matrix.java ├── Memory.java ├── MinkowskiDistance.java ├── MultiInstanceCapabilitiesHandler.java ├── NoSupportForMissingValuesException.java ├── NormalizableDistance.java ├── Optimization.java ├── Option.java ├── OptionHandler.java ├── OptionHandlerJavadoc.java ├── PartitionGenerator.java ├── PropertyPath.java ├── ProtectedProperties.java ├── Queue.java ├── RandomVariates.java ├── Randomizable.java ├── Range.java ├── RelationalLocator.java ├── RepositoryIndexGenerator.java ├── RevisionHandler.java ├── RevisionUtils.java ├── SelectedTag.java ├── SerializationHelper.java ├── SerializedObject.java ├── SingleIndex.java ├── SparseInstance.java ├── SpecialFunctions.java ├── Statistics.java ├── Stopwords.java ├── StringLocator.java ├── Summarizable.java ├── SystemInfo.java ├── Tag.java ├── TechnicalInformation.java ├── TechnicalInformationHandler.java ├── TechnicalInformationHandlerJavadoc.java ├── Tee.java ├── TestInstances.java ├── ThreadSafe.java ├── Trie.java ├── UnassignedClassException.java ├── UnassignedDatasetException.java ├── Undoable.java ├── UnsupportedAttributeTypeException.java ├── UnsupportedClassTypeException.java ├── Utils.java ├── Version.java ├── WeightedInstancesHandler.java ├── WekaEnumeration.java ├── WekaException.java ├── converters │ ├── AbstractFileLoader.java │ ├── AbstractFileSaver.java │ ├── AbstractLoader.java │ ├── AbstractSaver.java │ ├── ArffLoader.java │ ├── ArffSaver.java │ ├── BatchConverter.java │ ├── C45Loader.java │ ├── C45Saver.java │ ├── CSVLoader.java │ ├── CSVSaver.java │ ├── ConverterUtils.java │ ├── DatabaseConnection.java │ ├── DatabaseConverter.java │ ├── DatabaseLoader.java │ ├── DatabaseSaver.java │ ├── FileSourcedConverter.java │ ├── IncrementalConverter.java │ ├── JSONLoader.java │ ├── JSONSaver.java │ ├── LibSVMLoader.java │ ├── LibSVMSaver.java │ ├── Loader.java │ ├── MatlabLoader.java │ ├── MatlabSaver.java │ ├── SVMLightLoader.java │ ├── SVMLightSaver.java │ ├── Saver.java │ ├── SerializedInstancesLoader.java │ ├── SerializedInstancesSaver.java │ ├── StreamTokenizerUtils.java │ ├── TextDirectoryLoader.java │ ├── URLSourcedLoader.java │ ├── XRFFLoader.java │ └── XRFFSaver.java ├── json │ ├── JSONInstances.java │ ├── JSONNode.java │ └── sym.java ├── logging │ ├── ConsoleLogger.java │ ├── FileLogger.java │ ├── Logger.java │ └── OutputLogger.java ├── mathematicalexpression │ └── sym.java ├── matrix │ ├── CholeskyDecomposition.java │ ├── DoubleVector.java │ ├── EigenvalueDecomposition.java │ ├── ExponentialFormat.java │ ├── FlexibleDecimalFormat.java │ ├── FloatingPointFormat.java │ ├── IntVector.java │ ├── LUDecomposition.java │ ├── LinearRegression.java │ ├── Maths.java │ ├── Matrix.java │ ├── QRDecomposition.java │ └── SingularValueDecomposition.java ├── neighboursearch │ ├── BallTree.java │ ├── CoverTree.java │ ├── KDTree.java │ ├── LinearNNSearch.java │ ├── NearestNeighbourSearch.java │ ├── PerformanceStats.java │ ├── TreePerformanceStats.java │ ├── balltrees │ │ ├── BallNode.java │ │ ├── BallSplitter.java │ │ ├── BallTreeConstructor.java │ │ ├── BottomUpConstructor.java │ │ ├── MedianDistanceFromArbitraryPoint.java │ │ ├── MedianOfWidestDimension.java │ │ ├── MiddleOutConstructor.java │ │ ├── PointsClosestToFurthestChildren.java │ │ └── TopDownConstructor.java │ ├── covertrees │ │ └── Stack.java │ └── kdtrees │ │ ├── KDTreeNode.java │ │ ├── KDTreeNodeSplitter.java │ │ ├── KMeansInpiredMethod.java │ │ ├── MedianOfWidestDimension.java │ │ ├── MidPointOfWidestDimension.java │ │ └── SlidingMidPointOfWidestSide.java ├── pmml │ ├── Apply.java │ ├── Array.java │ ├── BuiltInArithmetic.java │ ├── BuiltInMath.java │ ├── BuiltInString.java │ ├── Constant.java │ ├── DefineFunction.java │ ├── DerivedFieldMetaInfo.java │ ├── Discretize.java │ ├── Expression.java │ ├── FieldMetaInfo.java │ ├── FieldRef.java │ ├── Function.java │ ├── MappingInfo.java │ ├── MiningFieldMetaInfo.java │ ├── MiningSchema.java │ ├── NormContinuous.java │ ├── NormDiscrete.java │ ├── PMMLFactory.java │ ├── PMMLModel.java │ ├── PMMLUtils.java │ ├── SparseArray.java │ ├── TargetMetaInfo.java │ ├── TransformationDictionary.java │ ├── VectorDictionary.java │ └── VectorInstance.java ├── scripting │ ├── Groovy.java │ ├── Jython.java │ ├── JythonObject.java │ └── JythonSerializableObject.java ├── stemmers │ ├── IteratedLovinsStemmer.java │ ├── LovinsStemmer.java │ ├── NullStemmer.java │ ├── SnowballStemmer.java │ ├── Stemmer.java │ └── Stemming.java ├── tokenizers │ ├── AlphabeticTokenizer.java │ ├── CharacterDelimitedTokenizer.java │ ├── NGramTokenizer.java │ ├── Tokenizer.java │ └── WordTokenizer.java └── xml │ ├── KOML.java │ ├── MethodHandler.java │ ├── PropertyHandler.java │ ├── SerialUIDChanger.java │ ├── XMLBasicSerialization.java │ ├── XMLDocument.java │ ├── XMLInstances.java │ ├── XMLOptions.java │ ├── XMLSerialization.java │ ├── XMLSerializationMethodHandler.java │ └── XStream.java ├── datagenerators ├── ClassificationGenerator.java ├── ClusterDefinition.java ├── ClusterGenerator.java ├── DataGenerator.java ├── RegressionGenerator.java ├── Test.java ├── classifiers │ ├── classification │ │ ├── Agrawal.java │ │ ├── BayesNet.java │ │ ├── LED24.java │ │ ├── RDG1.java │ │ └── RandomRBF.java │ └── regression │ │ ├── Expression.java │ │ └── MexicanHat.java └── clusterers │ ├── BIRCHCluster.java │ ├── SubspaceCluster.java │ └── SubspaceClusterDefinition.java ├── estimators ├── CheckEstimator.java ├── ConditionalEstimator.java ├── DDConditionalEstimator.java ├── DKConditionalEstimator.java ├── DNConditionalEstimator.java ├── DiscreteEstimator.java ├── Estimator.java ├── EstimatorUtils.java ├── IncrementalEstimator.java ├── KDConditionalEstimator.java ├── KKConditionalEstimator.java ├── KernelEstimator.java ├── MahalanobisEstimator.java ├── MultivariateEstimator.java ├── MultivariateGaussianEstimator.java ├── NDConditionalEstimator.java ├── NNConditionalEstimator.java ├── NormalEstimator.java ├── PoissonEstimator.java ├── UnivariateDensityEstimator.java ├── UnivariateEqualFrequencyHistogramEstimator.java ├── UnivariateIntervalEstimator.java ├── UnivariateKernelEstimator.java ├── UnivariateNormalEstimator.java └── UnivariateQuantileEstimator.java ├── experiment ├── AveragingResultProducer.java ├── CSVResultListener.java ├── ClassifierSplitEvaluator.java ├── Compute.java ├── CostSensitiveClassifierSplitEvaluator.java ├── CrossValidationResultProducer.java ├── CrossValidationSplitResultProducer.java ├── DatabaseResultListener.java ├── DatabaseResultProducer.java ├── DatabaseUtils.java ├── DensityBasedClustererSplitEvaluator.java ├── Experiment.java ├── ExplicitTestsetResultProducer.java ├── InstanceQuery.java ├── InstanceQueryAdapter.java ├── InstancesResultListener.java ├── LearningRateResultProducer.java ├── OutputZipper.java ├── PairedCorrectedTTester.java ├── PairedStats.java ├── PairedStatsCorrected.java ├── PairedTTester.java ├── PropertyNode.java ├── RandomSplitResultProducer.java ├── RegressionSplitEvaluator.java ├── RemoteEngine.java ├── RemoteExperiment.java ├── RemoteExperimentEvent.java ├── RemoteExperimentListener.java ├── RemoteExperimentSubTask.java ├── ResultListener.java ├── ResultMatrix.java ├── ResultMatrixCSV.java ├── ResultMatrixGnuPlot.java ├── ResultMatrixHTML.java ├── ResultMatrixLatex.java ├── ResultMatrixPlainText.java ├── ResultMatrixSignificance.java ├── ResultProducer.java ├── SplitEvaluator.java ├── Stats.java ├── Task.java ├── TaskStatusInfo.java ├── Tester.java └── xml │ └── XMLExperiment.java ├── filters ├── AllFilter.java ├── CheckSource.java ├── Filter.java ├── MultiFilter.java ├── SimpleBatchFilter.java ├── SimpleFilter.java ├── SimpleStreamFilter.java ├── Sourcable.java ├── StreamableFilter.java ├── SupervisedFilter.java ├── UnsupervisedFilter.java ├── supervised │ ├── attribute │ │ ├── AddClassification.java │ │ ├── AttributeSelection.java │ │ ├── ClassOrder.java │ │ ├── Discretize.java │ │ ├── MergeNominalValues.java │ │ └── NominalToBinary.java │ └── instance │ │ ├── Resample.java │ │ ├── SpreadSubsample.java │ │ └── StratifiedRemoveFolds.java └── unsupervised │ ├── attribute │ ├── AbstractTimeSeries.java │ ├── Add.java │ ├── AddCluster.java │ ├── AddExpression.java │ ├── AddID.java │ ├── AddNoise.java │ ├── AddUserFields.java │ ├── AddUserFieldsBeanInfo.java │ ├── AddValues.java │ ├── Center.java │ ├── ChangeDateFormat.java │ ├── ClassAssigner.java │ ├── ClusterMembership.java │ ├── Copy.java │ ├── Discretize.java │ ├── FirstOrder.java │ ├── InterquartileRange.java │ ├── KernelFilter.java │ ├── MakeIndicator.java │ ├── MathExpression.java │ ├── MergeInfrequentNominalValues.java │ ├── MergeManyValues.java │ ├── MergeTwoValues.java │ ├── NominalToBinary.java │ ├── NominalToString.java │ ├── Normalize.java │ ├── NumericCleaner.java │ ├── NumericToBinary.java │ ├── NumericToNominal.java │ ├── NumericTransform.java │ ├── Obfuscate.java │ ├── PKIDiscretize.java │ ├── PartitionMembership.java │ ├── PartitionedMultiFilter.java │ ├── PotentialClassIgnorer.java │ ├── PrincipalComponents.java │ ├── RandomProjection.java │ ├── RandomSubset.java │ ├── Remove.java │ ├── RemoveByName.java │ ├── RemoveType.java │ ├── RemoveUseless.java │ ├── RenameAttribute.java │ ├── Reorder.java │ ├── ReplaceMissingValues.java │ ├── ReplaceMissingWithUserConstant.java │ ├── SortLabels.java │ ├── Standardize.java │ ├── StringToNominal.java │ ├── StringToWordVector.java │ ├── SwapValues.java │ ├── TimeSeriesDelta.java │ └── TimeSeriesTranslate.java │ └── instance │ ├── NonSparseToSparse.java │ ├── Randomize.java │ ├── RemoveFolds.java │ ├── RemoveFrequentValues.java │ ├── RemoveMisclassified.java │ ├── RemovePercentage.java │ ├── RemoveRange.java │ ├── RemoveWithValues.java │ ├── Resample.java │ ├── ReservoirSample.java │ ├── SparseToNonSparse.java │ ├── SubsetByExpression.java │ └── subsetbyexpression │ └── sym.java └── gui ├── GenericPropertiesCreator.java ├── Logger.java └── LookAndFeel.java /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | bin 3 | gen 4 | out 5 | *.iml 6 | .idea -------------------------------------------------------------------------------- /AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-19 15 | android.library=true 16 | -------------------------------------------------------------------------------- /src/weka/associations/AssociationRulesProducer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * AssociationRulesProducer.java 18 | * Copyright (C) 2010-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.associations; 23 | 24 | 25 | /** 26 | * Interface to something that can provide a list of 27 | * AssociationRules. 28 | * 29 | * @author Mark Hall (mhall{[at]}pentaho{[dot]}com) 30 | * @version $Revision: 8034 $ 31 | */ 32 | public interface AssociationRulesProducer { 33 | 34 | /** 35 | * Gets the list of mined association rules. 36 | * 37 | * @return the list of association rules discovered during mining. 38 | * Returns null if mining hasn't been performed yet. 39 | */ 40 | AssociationRules getAssociationRules(); 41 | 42 | /** 43 | * Gets a list of the names of the metrics output for 44 | * each rule. This list should be the same (in terms of 45 | * the names and order thereof) as that produced by 46 | * AssociationRule.getMetricNamesForRule(). 47 | * 48 | * @return an array of the names of the metrics available 49 | * for each rule learned by this producer. 50 | */ 51 | String[] getRuleMetricNames(); 52 | 53 | /** 54 | * Returns true if this AssociationRulesProducer can actually 55 | * produce rules. Most implementing classes will always return 56 | * true from this method (obviously :-)). However, an implementing 57 | * class that actually acts as a wrapper around things that may 58 | * or may not implement AssociationRulesProducer will want to 59 | * return false if the thing they wrap can't produce rules. 60 | * 61 | * @return true if this producer can produce rules in its current 62 | * configuration 63 | */ 64 | boolean canProduceRules(); 65 | } 66 | -------------------------------------------------------------------------------- /src/weka/associations/Associator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * Associator.java 18 | * Copyright (C) 1999-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.associations; 23 | 24 | import weka.core.Capabilities; 25 | import weka.core.Instances; 26 | 27 | public interface Associator { 28 | 29 | /** 30 | * Generates an associator. Must initialize all fields of the associator 31 | * that are not being set via options (ie. multiple calls of buildAssociator 32 | * must always lead to the same result). Must not change the dataset 33 | * in any way. 34 | * 35 | * @param data set of instances serving as training data 36 | * @exception Exception if the associator has not been 37 | * generated successfully 38 | */ 39 | void buildAssociations(Instances data) throws Exception; 40 | 41 | /** 42 | * Returns the Capabilities of this associator. Derived associators have to 43 | * override this method to enable capabilities. 44 | * 45 | * @return the capabilities of this object 46 | * @see Capabilities 47 | */ 48 | Capabilities getCapabilities(); 49 | } -------------------------------------------------------------------------------- /src/weka/associations/BinaryItem.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * BinaryItem.java 18 | * Copyright (C) 2010-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.associations; 23 | 24 | import java.io.Serializable; 25 | 26 | import weka.core.Attribute; 27 | 28 | 29 | /** 30 | * Class that encapsulates an item whose backing Attribute is 31 | * binary or unary. 32 | * 33 | * @author Mark Hall (mhall{[at]}pentaho{[dot]}com) 34 | * @version $Revision; $ 35 | */ 36 | public class BinaryItem extends NominalItem 37 | implements Serializable { 38 | 39 | /** For serialization */ 40 | private static final long serialVersionUID = -3372941834914147669L; 41 | 42 | /** 43 | * Constructor. 44 | * 45 | * @param att the attribute that backs this item. 46 | * @param valueIndex the index of the value for this item. 47 | * @throws Exception if the backing attribute is not binary or unary. 48 | */ 49 | public BinaryItem(Attribute att, int valueIndex) throws Exception { 50 | super(att, valueIndex); 51 | 52 | if (att.isNumeric() || (att.isNominal() && att.numValues() > 2)) { 53 | throw new Exception("BinaryItem must be constructed using a nominal attribute" + 54 | " with at most 2 values!"); 55 | } 56 | } 57 | 58 | /** 59 | * Equals. Just compares attribute and valueIndex. 60 | * @return true if this BinaryItem is equal to the argument. 61 | */ 62 | public boolean equals(Object compareTo) { 63 | if (!(compareTo instanceof BinaryItem)) { 64 | return false; 65 | } 66 | 67 | BinaryItem b = (BinaryItem)compareTo; 68 | if (m_attribute.equals(b.getAttribute()) && 69 | // m_frequency == b.getFrequency() && 70 | m_valueIndex == b.getValueIndex()) { 71 | return true; 72 | } 73 | 74 | return false; 75 | } 76 | 77 | public int hashCode() { 78 | return (m_attribute.name().hashCode() ^ 79 | m_attribute.numValues()) * m_frequency; 80 | } 81 | } -------------------------------------------------------------------------------- /src/weka/associations/CARuleMiner.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * CARuleMiner.java 18 | * Copyright (C) 2004-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.associations; 23 | 24 | import weka.core.FastVector; 25 | import weka.core.Instances; 26 | import weka.core.OptionHandler; 27 | 28 | /** 29 | * Interface for learning class association rules. All schemes for learning 30 | * class association rules implemement this interface. 31 | * 32 | * @author Stefan Mutter (mutter@cs.waikato.ac.nz) 33 | * @version $Revision: 8034 $ 34 | */ 35 | public interface CARuleMiner extends OptionHandler { 36 | 37 | /** 38 | * Method for mining class association rules. 39 | * Must initialize all fields of the CARuleMiner that are not being set via options (ie. multiple calls of mineCARs 40 | * must always lead to the same result). Must not change the dataset in any way. 41 | * @param data the insatnces for which class association rules are mined 42 | * @throws Exception throws exception if class association rules cannot be mined 43 | * @return class association rules and their scoring metric in an FastVector array 44 | */ 45 | public FastVector[] mineCARs(Instances data) throws Exception; 46 | 47 | /** 48 | * Gets the instances without the class attribute 49 | * @return the instances withoput the class attribute 50 | */ 51 | public Instances getInstancesNoClass(); 52 | 53 | /** 54 | * Gets the class attribute and its values for all instances 55 | * @return the class attribute and its values for all instances 56 | */ 57 | public Instances getInstancesOnlyClass(); 58 | 59 | /** 60 | * Gets name of the scoring metric used for car mining 61 | * @return string containing the name of the scoring metric 62 | */ 63 | public String metricString(); 64 | 65 | /** 66 | * Sets the class index for the class association rule miner 67 | * @param index the class index 68 | */ 69 | public void setClassIndex(int index); 70 | 71 | } 72 | -------------------------------------------------------------------------------- /src/weka/attributeSelection/AttributeEvaluator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * AttributeEvaluator.java 18 | * Copyright (C) 1999-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.attributeSelection; 23 | 24 | 25 | /** 26 | * Interface for classes that evaluate attributes individually. 27 | * 28 | * @author Mark Hall (mhall@cs.waikato.ac.nz) 29 | * @version $Revision: 8034 $ 30 | */ 31 | public interface AttributeEvaluator { 32 | 33 | /** 34 | * evaluates an individual attribute 35 | * 36 | * @param attribute the index of the attribute to be evaluated 37 | * @return the "merit" of the attribute 38 | * @exception Exception if the attribute could not be evaluated 39 | */ 40 | public abstract double evaluateAttribute(int attribute) throws Exception; 41 | } 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /src/weka/attributeSelection/AttributeTransformer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * AttributeTransformer.java 18 | * Copyright (C) 2000-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.attributeSelection; 23 | 24 | import weka.core.Instance; 25 | import weka.core.Instances; 26 | 27 | /** 28 | * Abstract attribute transformer. Transforms the dataset. 29 | * 30 | * @author Mark Hall (mhall@cs.waikato.ac.nz) 31 | * @version $Revision: 8034 $ 32 | */ 33 | public interface AttributeTransformer { 34 | // =============== 35 | // Public methods. 36 | // =============== 37 | 38 | /** 39 | * Returns just the header for the transformed data (ie. an empty 40 | * set of instances. This is so that AttributeSelection can 41 | * determine the structure of the transformed data without actually 42 | * having to get all the transformed data through getTransformedData(). 43 | * @return the header of the transformed data. 44 | * @exception Exception if the header of the transformed data can't 45 | * be determined. 46 | */ 47 | Instances transformedHeader() throws Exception; 48 | 49 | /** 50 | * Transform the supplied data set (assumed to be the same format 51 | * as the training data) 52 | * @return A set of instances representing the transformed data 53 | * @exception Exception if the attribute could not be evaluated 54 | */ 55 | Instances transformedData(Instances data) throws Exception; 56 | 57 | /** 58 | * Transforms an instance in the format of the original data to the 59 | * transformed space 60 | * @return a transformed instance 61 | * @exception Exception if the instance could not be transformed 62 | */ 63 | Instance convertInstance(Instance instance) throws Exception; 64 | } 65 | -------------------------------------------------------------------------------- /src/weka/attributeSelection/ErrorBasedMeritEvaluator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * ErrorBasedMeritEvaluator.java 18 | * Copyright (C) 2000-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.attributeSelection; 23 | 24 | 25 | /** 26 | * Interface for evaluators that calculate the "merit" of attributes/subsets 27 | * as the error of a learning scheme 28 | * 29 | * @author Mark Hall (mhall@cs.waikato.ac.nz) 30 | * @version $Revision: 8034 $ 31 | */ 32 | public interface ErrorBasedMeritEvaluator { 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/weka/attributeSelection/HoldOutSubsetEvaluator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * HoldOutSubsetEvaluator.java 18 | * Copyright (C) 2000-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.attributeSelection; 23 | 24 | import java.util.BitSet; 25 | 26 | import weka.core.Instance; 27 | import weka.core.Instances; 28 | 29 | /** 30 | * Abstract attribute subset evaluator capable of evaluating subsets with 31 | * respect to a data set that is distinct from that used to initialize/ 32 | * train the subset evaluator. 33 | * 34 | * @author Mark Hall (mhall@cs.waikato.ac.nz) 35 | * @version $Revision: 8034 $ 36 | */ 37 | public abstract class HoldOutSubsetEvaluator 38 | extends ASEvaluation 39 | implements SubsetEvaluator { 40 | 41 | /** for serialization */ 42 | private static final long serialVersionUID = 8280529785412054174L; 43 | 44 | /** 45 | * Evaluates a subset of attributes with respect to a set of instances. 46 | * @param subset a bitset representing the attribute subset to be 47 | * evaluated 48 | * @param holdOut a set of instances (possibly seperate and distinct 49 | * from those use to build/train the evaluator) with which to 50 | * evaluate the merit of the subset 51 | * @return the "merit" of the subset on the holdOut data 52 | * @exception Exception if the subset cannot be evaluated 53 | */ 54 | public abstract double evaluateSubset(BitSet subset, Instances holdOut) 55 | throws Exception; 56 | 57 | /** 58 | * Evaluates a subset of attributes with respect to a single instance. 59 | * @param subset a bitset representing the attribute subset to be 60 | * evaluated 61 | * @param holdOut a single instance (possibly not one of those used to 62 | * build/train the evaluator) with which to evaluate the merit of the subset 63 | * @param retrain true if the classifier should be retrained with respect 64 | * to the new subset before testing on the holdOut instance. 65 | * @return the "merit" of the subset on the holdOut instance 66 | * @exception Exception if the subset cannot be evaluated 67 | */ 68 | public abstract double evaluateSubset(BitSet subset, 69 | Instance holdOut, 70 | boolean retrain) 71 | throws Exception; 72 | } 73 | -------------------------------------------------------------------------------- /src/weka/attributeSelection/StartSetHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * StartSetHandler.java 18 | * Copyright (C) 1999-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | 23 | package weka.attributeSelection; 24 | 25 | /** 26 | * Interface for search methods capable of doing something sensible 27 | * given a starting set of attributes. 28 | * 29 | * @author Mark Hall (mhall@cs.waikato.ac.nz) 30 | * @version $Revision: 8034 $ 31 | */ 32 | public interface StartSetHandler { 33 | 34 | /** 35 | * Sets a starting set of attributes for the search. It is the 36 | * search method's responsibility to report this start set (if any) 37 | * in its toString() method. 38 | * @param startSet a string containing a list of attributes (and or ranges), 39 | * eg. 1,2,6,10-15. 40 | * @exception Exception if start set can't be set. 41 | */ 42 | void setStartSet (String startSet) throws Exception; 43 | 44 | /** 45 | * Returns a list of attributes (and or attribute ranges) as a String 46 | * @return a list of attributes (and or attribute ranges) 47 | */ 48 | String getStartSet (); 49 | } 50 | -------------------------------------------------------------------------------- /src/weka/attributeSelection/SubsetEvaluator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * SubsetEvaluator.java 18 | * Copyright (C) 1999-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.attributeSelection; 23 | 24 | import java.util.BitSet; 25 | 26 | /** 27 | * Interface for attribute subset evaluators. 28 | * 29 | * @author Mark Hall (mhall@cs.waikato.ac.nz) 30 | * @version $Revision: 8034 $ 31 | */ 32 | public interface SubsetEvaluator { 33 | 34 | /** 35 | * evaluates a subset of attributes 36 | * 37 | * @param subset a bitset representing the attribute subset to be 38 | * evaluated 39 | * @return the "merit" of the subset 40 | * @exception Exception if the subset could not be evaluated 41 | */ 42 | double evaluateSubset(BitSet subset) throws Exception; 43 | } 44 | 45 | -------------------------------------------------------------------------------- /src/weka/attributeSelection/UnsupervisedAttributeEvaluator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * UnsupervisedAttributeEvaluator.java 18 | * Copyright (C) 1999-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.attributeSelection; 23 | 24 | /** 25 | * Abstract unsupervised attribute evaluator. 26 | * 27 | * @author Mark Hall (mhall@cs.waikato.ac.nz) 28 | * @version $Revision: 8034 $ 29 | */ 30 | public abstract class UnsupervisedAttributeEvaluator 31 | extends ASEvaluation 32 | implements AttributeEvaluator { 33 | 34 | /** for serialization */ 35 | private static final long serialVersionUID = -4100897318675336178L; 36 | 37 | } 38 | 39 | -------------------------------------------------------------------------------- /src/weka/attributeSelection/UnsupervisedSubsetEvaluator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * UnsupervisedSubsetEvaluator.java 18 | * Copyright (C) 1999-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.attributeSelection; 23 | 24 | import weka.clusterers.Clusterer; 25 | 26 | /** 27 | * Abstract unsupervised attribute subset evaluator. 28 | * 29 | * @author Mark Hall (mhall@cs.waikato.ac.nz) 30 | * @version $Revision: 8034 $ 31 | */ 32 | public abstract class UnsupervisedSubsetEvaluator 33 | extends ASEvaluation 34 | implements SubsetEvaluator { 35 | 36 | /** for serialization */ 37 | static final long serialVersionUID = 627934376267488763L; 38 | 39 | /** 40 | * Return the number of clusters used by the subset evaluator 41 | * 42 | * @return the number of clusters used 43 | * @exception Exception if an error occurs 44 | */ 45 | public abstract int getNumClusters() throws Exception; 46 | 47 | /** 48 | * Get the clusterer 49 | * 50 | * @return the clusterer 51 | */ 52 | public abstract Clusterer getClusterer(); 53 | 54 | /** 55 | * Set the clusterer to use 56 | * 57 | * @param d the clusterer to use 58 | */ 59 | public abstract void setClusterer(Clusterer d); 60 | } 61 | -------------------------------------------------------------------------------- /src/weka/classifiers/AggregateableEvaluation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * AggregateableEvaluation.java 18 | * Copyright (C) 2011-2012 University of Waikato, Hamilton, New Zealand 19 | */ 20 | 21 | package weka.classifiers; 22 | 23 | import weka.core.Instances; 24 | 25 | /** 26 | * Subclass of Evaluation that provides a method for aggregating the results 27 | * stored in another Evaluation object. Delegates to the actual implementation 28 | * in weka.classifiers.evaluation.AggregateableEvaluation. 29 | * 30 | * @author Mark Hall (mhall{[at]}pentaho{[dot]}com) 31 | * @version $Revision: 9320 $ 32 | */ 33 | public class AggregateableEvaluation extends Evaluation { 34 | 35 | /** For serialization */ 36 | private static final long serialVersionUID = 6850546230173753210L; 37 | 38 | /** 39 | * Constructs a new AggregateableEvaluation object 40 | * 41 | * @param data the Instances to use 42 | * @throws Exception if a problem occurs 43 | */ 44 | public AggregateableEvaluation(Instances data) throws Exception { 45 | super(data); 46 | m_delegate = new weka.classifiers.evaluation.AggregateableEvaluation(data); 47 | } 48 | 49 | /** 50 | * Constructs a new AggregateableEvaluation object 51 | * 52 | * @param data the Instances to use 53 | * @param costMatrix the cost matrix to use 54 | * @throws Exception if a problem occurs 55 | */ 56 | public AggregateableEvaluation(Instances data, CostMatrix costMatrix) 57 | throws Exception { 58 | super(data, costMatrix); 59 | m_delegate = new weka.classifiers.evaluation.AggregateableEvaluation(data, 60 | costMatrix); 61 | } 62 | 63 | /** 64 | * Constructs a new AggregateableEvaluation object based on an Evaluation 65 | * object 66 | * 67 | * @param eval the Evaluation object to use 68 | */ 69 | public AggregateableEvaluation(Evaluation eval) throws Exception { 70 | super(eval.getHeader()); 71 | m_delegate = new weka.classifiers.evaluation.AggregateableEvaluation( 72 | eval.m_delegate); 73 | } 74 | 75 | /** 76 | * Adds the statistics encapsulated in the supplied Evaluation object into 77 | * this one. Does not perform any checks for compatibility between the 78 | * supplied Evaluation object and this one. 79 | * 80 | * @param evaluation the evaluation object to aggregate 81 | */ 82 | public void aggregate(Evaluation evaluation) { 83 | ((weka.classifiers.evaluation.AggregateableEvaluation) m_delegate) 84 | .aggregate(evaluation.m_delegate); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/weka/classifiers/ConditionalDensityEstimator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * ConditionalDensityEstimator.java 18 | * Copyright (C) 2009-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.classifiers; 23 | 24 | import weka.core.Instance; 25 | 26 | /** 27 | * Interface for numeric prediction schemes that can output conditional 28 | * density estimates. 29 | * 30 | * @author Eibe Frank (eibe@cs.waikato.ac.nz) 31 | * @version $Revision: 8034 $ 32 | */ 33 | public interface ConditionalDensityEstimator { 34 | 35 | /** 36 | * Returns natural logarithm of density estimate for given value based on given instance. 37 | * 38 | * @param instance the instance to make the prediction for. 39 | * @param value the value to make the prediction for. 40 | * @return the natural logarithm of the density estimate 41 | * @exception Exception if the density cannot be computed 42 | */ 43 | public double logDensity(Instance instance, double value) throws Exception; 44 | } 45 | 46 | -------------------------------------------------------------------------------- /src/weka/classifiers/IntervalEstimator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * IntervalEstimator.java 18 | * Copyright (C) 2005-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.classifiers; 23 | 24 | import weka.core.Instance; 25 | 26 | /** 27 | * Interface for numeric prediction schemes that can output prediction 28 | * intervals. 29 | * 30 | * @author Kurt Driessens (kurtd@cs.waikato.ac.nz) 31 | * @version $Revision: 8034 $ 32 | */ 33 | public interface IntervalEstimator { 34 | 35 | /** 36 | * Returns an N * 2 array, where N is the number of prediction 37 | * intervals. In each row, the first element contains the lower 38 | * boundary of the corresponding prediction interval and the second 39 | * element the upper boundary. 40 | * 41 | * @param inst the instance to make the prediction for. 42 | * @param confidenceLevel the percentage of cases that the interval should cover. 43 | * @return an array of prediction intervals 44 | * @exception Exception if the intervals can't be computed 45 | */ 46 | double[][] predictIntervals(Instance inst, double confidenceLevel) throws Exception; 47 | } 48 | 49 | -------------------------------------------------------------------------------- /src/weka/classifiers/IterativeClassifier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * IterativeClassifier.java 18 | * Copyright (C) 2001-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.classifiers; 23 | 24 | import weka.core.Instances; 25 | 26 | /** 27 | * Interface for classifiers that can induce models of growing 28 | * complexity one step at a time. 29 | * 30 | * @author Gabi Schmidberger (gabi@cs.waikato.ac.nz) 31 | * @author Bernhard Pfahringer (bernhard@cs.waikato.ac.nz) 32 | * @version $Revision: 8034 $ 33 | */ 34 | 35 | public interface IterativeClassifier { 36 | 37 | /** 38 | * Inits an iterative classifier. 39 | * 40 | * @param instances the instances to be used in induction 41 | * @exception Exception if the model cannot be initialized 42 | */ 43 | void initClassifier(Instances instances) throws Exception; 44 | 45 | /** 46 | * Performs one iteration. 47 | * 48 | * @param iteration the index of the current iteration (0-based) 49 | * @exception Exception if this iteration fails 50 | */ 51 | void next(int iteration) throws Exception; 52 | 53 | /** 54 | * Signal end of iterating, useful for any house-keeping/cleanup 55 | * 56 | * @exception Exception if cleanup fails 57 | */ 58 | void done() throws Exception; 59 | 60 | /** 61 | * Performs a deep copy of the classifier, and a reference copy 62 | * of the training instances (or a deep copy if required). 63 | * 64 | * @return a clone of the classifier 65 | */ 66 | Object clone() throws CloneNotSupportedException; 67 | 68 | } 69 | -------------------------------------------------------------------------------- /src/weka/classifiers/Sourcable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * Sourcable.java 18 | * Copyright (C) 1999-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.classifiers; 23 | 24 | /** 25 | * Interface for classifiers that can be converted to Java source. 26 | * 27 | * @author Len Trigg (trigg@cs.waikato.ac.nz) 28 | * @version $Revision: 8034 $ 29 | */ 30 | public interface Sourcable { 31 | 32 | /** 33 | * Returns a string that describes the classifier as source. The 34 | * classifier will be contained in a class with the given name (there may 35 | * be auxiliary classes), 36 | * and will contain a method with the signature: 37 | *

38 |    * public static double classify(Object [] i);
39 |    * 
40 | * where the array i contains elements that are either 41 | * Double, String, with missing values represented as null. The generated 42 | * code is public domain and comes with no warranty. 43 | * 44 | * @param className the name that should be given to the source class. 45 | * @return the object source described by a string 46 | * @throws Exception if the source can't be computed 47 | */ 48 | String toSource(String className) throws Exception; 49 | } 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /src/weka/classifiers/UpdateableClassifier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * UpdateableClassifier.java 18 | * Copyright (C) 1999-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.classifiers; 23 | 24 | import weka.core.Instance; 25 | 26 | /** 27 | * Interface to incremental classification models that can learn using 28 | * one instance at a time. 29 | * 30 | * @author Eibe Frank (eibe@cs.waikato.ac.nz) 31 | * @version $Revision: 8034 $ 32 | */ 33 | public interface UpdateableClassifier { 34 | 35 | /** 36 | * Updates a classifier using the given instance. 37 | * 38 | * @param instance the instance to included 39 | * @exception Exception if instance could not be incorporated 40 | * successfully 41 | */ 42 | void updateClassifier(Instance instance) throws Exception; 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/weka/classifiers/bayes/net/search/fixed/NaiveBayes.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * NaiveBayes.java 18 | * Copyright (C) 2004-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | package weka.classifiers.bayes.net.search.fixed; 22 | 23 | import weka.classifiers.bayes.BayesNet; 24 | import weka.classifiers.bayes.net.search.SearchAlgorithm; 25 | import weka.core.Instances; 26 | import weka.core.RevisionUtils; 27 | 28 | /** 29 | 30 | * The NaiveBayes class generates a fixed Bayes network structure with arrows from the class variable to each of the attribute variables. 31 | *

32 | 33 | * 34 | 35 | 36 | * 37 | * @author Remco Bouckaert 38 | * @version $Revision: 8034 $ 39 | */ 40 | public class NaiveBayes 41 | extends SearchAlgorithm { 42 | 43 | /** for serialization */ 44 | static final long serialVersionUID = -4808572519709755811L; 45 | 46 | /** 47 | * Returns a string describing this object 48 | * @return a description of the classifier suitable for 49 | * displaying in the explorer/experimenter gui 50 | */ 51 | public String globalInfo() { 52 | return 53 | "The NaiveBayes class generates a fixed Bayes network structure " 54 | + "with arrows from the class variable to each of the attribute " 55 | + "variables."; 56 | } 57 | 58 | /** 59 | * 60 | * @param bayesNet 61 | * @param instances the instances to work with 62 | * @throws Exception if something goes wrong 63 | */ 64 | public void buildStructure (BayesNet bayesNet, Instances instances) throws Exception { 65 | for (int iAttribute = 0; iAttribute < instances.numAttributes(); iAttribute++) { 66 | if (iAttribute != instances.classIndex()) { 67 | bayesNet.getParentSet(iAttribute).addParent(instances.classIndex(), instances); 68 | } 69 | } 70 | } // buildStructure 71 | 72 | /** 73 | * Returns the revision string. 74 | * 75 | * @return the revision 76 | */ 77 | public String getRevision() { 78 | return RevisionUtils.extract("$Revision: 8034 $"); 79 | } 80 | 81 | } // class NaiveBayes 82 | -------------------------------------------------------------------------------- /src/weka/classifiers/bayes/net/search/local/Scoreable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * Scoreable.java 18 | * Copyright (C) 2001-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | package weka.classifiers.bayes.net.search.local; 22 | 23 | /** 24 | * Interface for allowing to score a classifier 25 | * 26 | * @author Remco Bouckaert (rrb@xm.co.nz) 27 | * @version $Revision: 8034 $ 28 | */ 29 | public interface Scoreable { 30 | 31 | /** 32 | * score types 33 | */ 34 | int BAYES = 0; 35 | int BDeu = 1; 36 | int MDL = 2; 37 | int ENTROPY = 3; 38 | int AIC = 4; 39 | 40 | /** 41 | * Returns log-score 42 | * 43 | * @param nType the score type 44 | * @return the log-score 45 | */ 46 | double logScore(int nType, int nCardinality); 47 | } // interface Scoreable 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /src/weka/classifiers/evaluation/IntervalBasedEvaluationMetric.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * IntervalBasedEvaluationMetric.java 18 | * Copyright (C) 2011-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.classifiers.evaluation; 23 | 24 | import weka.classifiers.IntervalEstimator; 25 | import weka.core.Instance; 26 | 27 | /** 28 | * Primarily a marker interface for interval-based evaluation metrics to 29 | * implement. Allows the command line interface to display these metrics or not 30 | * based on user-supplied options 31 | * 32 | * @author Mark Hall (mhall{[at]}pentaho{[dot]}com) 33 | * @version $Revision: 9320 $ 34 | */ 35 | public interface IntervalBasedEvaluationMetric { 36 | 37 | /** 38 | * Updates stats for interval estimator based on current test instance. 39 | * Implementers need only implement this method if it is not possible to 40 | * compute their statistics from what is stored in the base Evaluation object. 41 | * 42 | * @param classifier the interval estimator 43 | * @param classMissing the instance for which the intervals are computed, 44 | * without a class value 45 | * @param classValue the class value of this instance 46 | * @throws Exception if intervals could not be computed successfully 47 | */ 48 | void updateStatsForIntervalEstimator(IntervalEstimator classifier, 49 | Instance classMissing, double classValue) throws Exception; 50 | 51 | /** 52 | * Return a formatted string (suitable for displaying in console or GUI 53 | * output) containing all the statistics that this metric computes. 54 | * 55 | * @return a formatted string containing all the computed statistics 56 | */ 57 | String toSummaryString(); 58 | } 59 | -------------------------------------------------------------------------------- /src/weka/classifiers/evaluation/Prediction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * Prediction.java 18 | * Copyright (C) 2002-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.classifiers.evaluation; 23 | 24 | /** 25 | * Encapsulates a single evaluatable prediction: the predicted value plus the 26 | * actual class value. 27 | * 28 | * @author Len Trigg (len@reeltwo.com) 29 | * @version $Revision: 8034 $ 30 | */ 31 | public interface Prediction { 32 | 33 | /** 34 | * Constant representing a missing value. This should have the same value 35 | * as weka.core.Instance.MISSING_VALUE 36 | */ 37 | double MISSING_VALUE 38 | = weka.core.Utils.missingValue(); 39 | 40 | /** 41 | * Gets the weight assigned to this prediction. This is typically the weight 42 | * of the test instance the prediction was made for. 43 | * 44 | * @return the weight assigned to this prediction. 45 | */ 46 | double weight(); 47 | 48 | /** 49 | * Gets the actual class value. 50 | * 51 | * @return the actual class value, or MISSING_VALUE if no 52 | * prediction was made. 53 | */ 54 | double actual(); 55 | 56 | /** 57 | * Gets the predicted class value. 58 | * 59 | * @return the predicted class value, or MISSING_VALUE if no 60 | * prediction was made. 61 | */ 62 | double predicted(); 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/weka/classifiers/evaluation/StandardEvaluationMetric.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * StandardEvaluationMetric.java 18 | * Copyright (C) 2011-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.classifiers.evaluation; 23 | 24 | import weka.core.Instance; 25 | 26 | /** 27 | * Primarily a marker interface for a "standard" evaluation metric - i.e. one 28 | * that would be part of the normal output in Weka without having to turn 29 | * specific display options. 30 | * 31 | * @author Mark Hall (mhall{[at]}pentaho{[dot]}com) 32 | * @version $Revision: 9320 $ 33 | */ 34 | public interface StandardEvaluationMetric { 35 | 36 | /** 37 | * Return a formatted string (suitable for displaying in console or GUI 38 | * output) containing all the statistics that this metric computes. 39 | * 40 | * @return a formatted string containing all the computed statistics 41 | */ 42 | String toSummaryString(); 43 | 44 | /** 45 | * Updates the statistics about a classifiers performance for the current test 46 | * instance. Gets called when the class is nominal. Implementers need only 47 | * implement this method if it is not possible to compute their statistics 48 | * from what is stored in the base Evaluation object. 49 | * 50 | * @param predictedDistribution the probabilities assigned to each class 51 | * @param instance the instance to be classified 52 | * @throws Exception if the class of the instance is not set 53 | */ 54 | void updateStatsForClassifier(double[] predictedDistribution, 55 | Instance instance) throws Exception; 56 | 57 | /** 58 | * Updates the statistics about a predictors performance for the current test 59 | * instance. Gets called when the class is numeric. Implementers need only 60 | * implement this method if it is not possible to compute their statistics 61 | * from what is stored in the base Evaluation object. 62 | * 63 | * @param predictedValue the numeric value the classifier predicts 64 | * @param instance the instance to be classified 65 | * @throws Exception if the class of the instance is not set 66 | */ 67 | void updateStatsForPredictor(double predictedValue, Instance instance) 68 | throws Exception; 69 | } 70 | -------------------------------------------------------------------------------- /src/weka/classifiers/functions/neural/NeuralMethod.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * NeuralMethod.java 18 | * Copyright (C) 2001-2012 University of Waikato, Hamilton, New Zealand 19 | */ 20 | 21 | 22 | package weka.classifiers.functions.neural; 23 | 24 | import java.io.Serializable; 25 | 26 | /** 27 | * This is an interface used to create classes that can be used by the 28 | * neuralnode to perform all it's computations. 29 | * 30 | * @author Malcolm Ware (mfw4@cs.waikato.ac.nz) 31 | * @version $Revision: 8034 $ 32 | */ 33 | public interface NeuralMethod extends Serializable { 34 | 35 | /** 36 | * This function calculates what the output value should be. 37 | * @param node The node to calculate the value for. 38 | * @return The value. 39 | */ 40 | double outputValue(NeuralNode node); 41 | 42 | /** 43 | * This function calculates what the error value should be. 44 | * @param node The node to calculate the error for. 45 | * @return The error. 46 | */ 47 | double errorValue(NeuralNode node); 48 | 49 | /** 50 | * This function will calculate what the change in weights should be 51 | * and also update them. 52 | * @param node The node to update the weights for. 53 | * @param learn The learning rate to use. 54 | * @param momentum The momentum to use. 55 | */ 56 | void updateWeights(NeuralNode node, double learn, double momentum); 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/weka/classifiers/lazy/kstar/KStarConstants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /** 17 | * KStarConstants.java 18 | * Copyright (C) 1995-2012 Univeristy of Waikato 19 | * Java port to Weka by Abdelaziz Mahoui (am14@cs.waikato.ac.nz). 20 | * 21 | */ 22 | 23 | 24 | package weka.classifiers.lazy.kstar; 25 | 26 | /** 27 | * @author Len Trigg (len@reeltwo.com) 28 | * @author Abdelaziz Mahoui (am14@cs.waikato.ac.nz) 29 | * @version $Revision 1.0 $ 30 | */ 31 | public interface KStarConstants { 32 | 33 | /** Some usefull constants */ 34 | int ON = 1; 35 | int OFF = 0; 36 | int NUM_RAND_COLS = 5; 37 | double FLOOR = 0.0; 38 | double FLOOR1 = 0.1; 39 | double INITIAL_STEP = 0.05; 40 | double LOG2 = 0.693147181; 41 | double EPSILON = 1.0e-5; 42 | 43 | /** How close the root finder for numeric and nominal have to get */ 44 | int ROOT_FINDER_MAX_ITER = 40; 45 | double ROOT_FINDER_ACCURACY = 0.01; 46 | 47 | /** Blend setting modes */ 48 | int B_SPHERE = 1; /* Use sphere of influence */ 49 | int B_ENTROPY = 2; /* Use entropic blend setting */ 50 | 51 | /** Missing value handling mode */ 52 | 53 | /* Ignore the instance with the missing value */ 54 | int M_DELETE = 1; 55 | /* Treat missing values as maximally different */ 56 | int M_MAXDIFF = 2; 57 | /* Normilize over the attributes */ 58 | int M_NORMAL = 3; 59 | /* Average column entropy curves */ 60 | int M_AVERAGE = 4; 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/weka/classifiers/lazy/kstar/KStarWrapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /** 17 | * KStarWrapper.java 18 | * Copyright (C) 1995-2012 Univeristy of Waikato 19 | * Java port to Weka by Abdelaziz Mahoui (am14@cs.waikato.ac.nz). 20 | * 21 | */ 22 | 23 | package weka.classifiers.lazy.kstar; 24 | 25 | import weka.core.RevisionHandler; 26 | import weka.core.RevisionUtils; 27 | 28 | /* 29 | * @author Len Trigg (len@reeltwo.com) 30 | * @author Abdelaziz Mahoui (am14@cs.waikato.ac.nz) 31 | * @version $Revision 1.0 $ 32 | */ 33 | public class KStarWrapper 34 | implements RevisionHandler { 35 | 36 | /** used/reused to hold the sphere size */ 37 | public double sphere = 0.0; 38 | 39 | /** used/reused to hold the actual entropy */ 40 | public double actEntropy = 0.0; 41 | 42 | /** used/reused to hold the random entropy */ 43 | public double randEntropy = 0.0; 44 | 45 | /** used/reused to hold the average transformation probability */ 46 | public double avgProb = 0.0; 47 | 48 | /** used/reused to hold the smallest transformation probability */ 49 | public double minProb = 0.0; 50 | 51 | /** 52 | * Returns the revision string. 53 | * 54 | * @return the revision 55 | */ 56 | public String getRevision() { 57 | return RevisionUtils.extract("$Revision: 8034 $"); 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /src/weka/classifiers/misc/InputMappedClassifierBeanInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | 15 | 16 | 17 | * InputMappedClassifierBeanInfo.java 18 | * Copyright 2010-2012 University of Waikato 19 | 20 | 21 | package weka.classifiers.misc; 22 | 23 | 24 | *//** 25 | * Bean info class for the InputMappedClassifier. Ensures that the FileEnvironmentField class is used as the custom property editor in the GOE for the modelPath property. 26 | * 27 | * @author Mar Hall (mhall{[at]}pentaho{[dot]}com) 28 | * @version $Revision: 8034 $ 29 | * 30 | */ 31 | /* 32 | public class InputMappedClassifierBeanInfo extends SimpleBeanInfo { 33 | 34 | *//** 35 | * Get an array of PropertyDescriptors for the InputMappedClassifier's public properties. 36 | * 37 | * @return an array of PropertyDescriptors 38 | */ 39 | /* 40 | public PropertyDescriptor[] getPropertyDescriptors() { 41 | try { 42 | PropertyDescriptor p1; 43 | ArrayList pds = new ArrayList(); 44 | 45 | p1 = new PropertyDescriptor("modelPath", InputMappedClassifier.class); 46 | //p1.setPropertyEditorClass(weka.gui.beans.FileEnvironmentField.class); 47 | pds.add(p1); 48 | 49 | pds.add(new PropertyDescriptor("ignoreCaseForNames", InputMappedClassifier.class)); 50 | pds.add(new PropertyDescriptor("suppressMappingReport", InputMappedClassifier.class)); 51 | pds.add(new PropertyDescriptor("trim", InputMappedClassifier.class)); 52 | pds.add(new PropertyDescriptor("classifier", InputMappedClassifier.class)); 53 | 54 | // this one is only really needed for XMLSerialization 55 | pds.add(new PropertyDescriptor("options", InputMappedClassifier.class)); 56 | 57 | return pds.toArray(new PropertyDescriptor[1]); 58 | } catch (Exception ex) { 59 | ex.printStackTrace(); 60 | } 61 | return null; 62 | } 63 | } 64 | */ -------------------------------------------------------------------------------- /src/weka/classifiers/rules/Rule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * Rule.java 18 | * Copyright (C) 2001-2012 University of Waikato, Hamilton, New Zealand 19 | */ 20 | 21 | package weka.classifiers.rules; 22 | 23 | import java.io.Serializable; 24 | 25 | import weka.core.Copyable; 26 | import weka.core.Instance; 27 | import weka.core.Instances; 28 | import weka.core.RevisionHandler; 29 | import weka.core.WeightedInstancesHandler; 30 | 31 | /** 32 | * Abstract class of generic rule 33 | * 34 | * @author Xin Xu (xx5@cs.waikato.ac.nz) 35 | * @version $Revision: 8034 $ 36 | */ 37 | public abstract class Rule 38 | implements WeightedInstancesHandler, Copyable, Serializable, RevisionHandler { 39 | 40 | /** for serialization */ 41 | private static final long serialVersionUID = 8815687740470471229L; 42 | 43 | /** 44 | * Get a shallow copy of this rule 45 | * 46 | * @return the copy 47 | */ 48 | public Object copy(){ return this;} 49 | 50 | /** 51 | * Whether the instance covered by this rule 52 | * 53 | * @param datum the instance in question 54 | * @return the boolean value indicating whether the instance 55 | * is covered by this rule 56 | */ 57 | public abstract boolean covers(Instance datum); 58 | 59 | /** 60 | * Build this rule 61 | * 62 | * @param data the data used to build the rule 63 | * @exception Exception if rule cannot be built 64 | */ 65 | public abstract void grow(Instances data) throws Exception; 66 | 67 | /** 68 | * Whether this rule has antecedents, i.e. whether it is a default rule 69 | * 70 | * @return the boolean value indicating whether the rule has antecedents 71 | */ 72 | public abstract boolean hasAntds(); 73 | 74 | /** 75 | * Get the consequent of this rule, i.e. the predicted class 76 | * 77 | * @return the consequent 78 | */ 79 | public abstract double getConsequent(); 80 | 81 | /** 82 | * The size of the rule. Could be number of antecedents in the case 83 | * of conjunctive rule 84 | * 85 | * @return the size of the rule 86 | */ 87 | public abstract double size(); 88 | } 89 | -------------------------------------------------------------------------------- /src/weka/classifiers/trees/ht/ConditionalSufficientStats.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * ConditionalSufficientStats.java 18 | * Copyright (C) 2013 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.classifiers.trees.ht; 23 | 24 | import java.io.Serializable; 25 | import java.util.HashMap; 26 | import java.util.Map; 27 | 28 | /** 29 | * Records sufficient stats for an attribute 30 | * 31 | * @author Richard Kirkby (rkirkby@cs.waikato.ac.nz) 32 | * @author Mark Hall (mhall{[at]}pentaho{[dot]}com) 33 | * @version $Revision: 9705 $ 34 | */ 35 | public abstract class ConditionalSufficientStats implements Serializable { 36 | 37 | /** 38 | * For serialization 39 | */ 40 | private static final long serialVersionUID = 8724787722646808376L; 41 | 42 | /** Lookup by class value */ 43 | protected Map m_classLookup = new HashMap(); 44 | 45 | /** 46 | * Update this stat with the supplied attribute value and class value 47 | * 48 | * @param attVal the value of the attribute 49 | * @param classVal the class value 50 | * @param weight the weight of this observation 51 | */ 52 | public abstract void update(double attVal, String classVal, double weight); 53 | 54 | /** 55 | * Return the probability of an attribute value conditioned on a class value 56 | * 57 | * @param attVal the attribute value to compute the conditional probability 58 | * for 59 | * @param classVal the class value 60 | * @return the probability 61 | */ 62 | public abstract double probabilityOfAttValConditionedOnClass(double attVal, 63 | String classVal); 64 | 65 | /** 66 | * Return the best split 67 | * 68 | * @param splitMetric the split metric to use 69 | * @param preSplitDist the distribution of class values prior to splitting 70 | * @param attName the name of the attribute being considered for splitting 71 | * @return the best split for the attribute 72 | */ 73 | public abstract SplitCandidate bestSplit(SplitMetric splitMetric, 74 | Map preSplitDist, String attName); 75 | } 76 | -------------------------------------------------------------------------------- /src/weka/classifiers/trees/ht/GiniSplitMetric.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * GiniSplitMetric.java 18 | * Copyright (C) 2013 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.classifiers.trees.ht; 23 | 24 | import java.io.Serializable; 25 | import java.util.List; 26 | import java.util.Map; 27 | 28 | /** 29 | * Implements the gini splitting criterion 30 | * 31 | * @author Richard Kirkby (rkirkby@cs.waikato.ac.nz) 32 | * @author Mark Hall (mhall{[at]}pentaho{[dot]}com) 33 | * @version $Revision: 9720 $ 34 | */ 35 | public class GiniSplitMetric extends SplitMetric implements Serializable { 36 | 37 | /** 38 | * For serialization 39 | */ 40 | private static final long serialVersionUID = -2037586582742660298L; 41 | 42 | @Override 43 | public double evaluateSplit(Map preDist, 44 | List> postDist) { 45 | double totalWeight = 0.0; 46 | double[] distWeights = new double[postDist.size()]; 47 | 48 | for (int i = 0; i < postDist.size(); i++) { 49 | distWeights[i] = SplitMetric.sum(postDist.get(i)); 50 | totalWeight += distWeights[i]; 51 | } 52 | double gini = 0; 53 | for (int i = 0; i < postDist.size(); i++) { 54 | gini += (distWeights[i] / totalWeight) 55 | * gini(postDist.get(i), distWeights[i]); 56 | } 57 | 58 | return 1.0 - gini; 59 | } 60 | 61 | /** 62 | * Return the gini metric computed from the supplied distribution 63 | * 64 | * @param dist the distribution to compute the gini metric from 65 | * @param sumOfWeights the sum of the distribution weights 66 | * @return the gini metric 67 | */ 68 | protected static double gini(Map dist, double sumOfWeights) { 69 | double gini = 1.0; 70 | 71 | for (Map.Entry e : dist.entrySet()) { 72 | double frac = e.getValue().m_weight / sumOfWeights; 73 | gini -= frac * frac; 74 | } 75 | 76 | return gini; 77 | } 78 | 79 | /** 80 | * Return the gini metric computed from the supplied distribution 81 | * 82 | * @param dist dist the distribution to compute the gini metric from 83 | * @return 84 | */ 85 | public static double gini(Map dist) { 86 | return gini(dist, SplitMetric.sum(dist)); 87 | } 88 | 89 | @Override 90 | public double getMetricRange(Map preDist) { 91 | return 1.0; 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /src/weka/classifiers/trees/ht/InactiveHNode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * InactiveHNode.java 18 | * Copyright (C) 2013 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.classifiers.trees.ht; 23 | 24 | import java.io.Serializable; 25 | import java.util.Map; 26 | 27 | import weka.core.Instance; 28 | 29 | /** 30 | * Class implementing an inactive node (i.e. one that does not allow growth) 31 | * 32 | * @author Richard Kirkby (rkirkby@cs.waikato.ac.nz) 33 | * @author Mark Hall (mhall{[at]}pentaho{[dot]}com) 34 | * @version $Revision: 9705 $ 35 | */ 36 | public class InactiveHNode extends LeafNode implements LearningNode, 37 | Serializable { 38 | 39 | /** 40 | * For serialization 41 | */ 42 | private static final long serialVersionUID = -8747567733141700911L; 43 | 44 | /** 45 | * Constructor 46 | * 47 | * @param classDistrib the class distribution at this node 48 | */ 49 | public InactiveHNode(Map classDistrib) { 50 | m_classDistribution = classDistrib; 51 | } 52 | 53 | @Override 54 | public void updateNode(Instance inst) { 55 | super.updateDistribution(inst); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/weka/classifiers/trees/ht/LeafNode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * LeafNode.java 18 | * Copyright (C) 2013 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.classifiers.trees.ht; 23 | 24 | import java.io.Serializable; 25 | 26 | import weka.core.Instance; 27 | 28 | /** 29 | * Leaf node in a HoeffdingTree 30 | * 31 | * @author Richard Kirkby (rkirkby@cs.waikato.ac.nz) 32 | * @author Mark Hall (mhall{[at]}pentaho{[dot]}com) 33 | * @version $Revision: 9705 $ 34 | */ 35 | public class LeafNode extends HNode implements Serializable { 36 | 37 | /** 38 | * For serialization 39 | */ 40 | private static final long serialVersionUID = -3359429731894384404L; 41 | 42 | /** The actual node for this leaf */ 43 | public HNode m_theNode; 44 | 45 | /** Parent split node */ 46 | public SplitNode m_parentNode; 47 | 48 | /** Parent branch leading to this node */ 49 | public String m_parentBranch; 50 | 51 | /** 52 | * Construct an empty leaf node 53 | */ 54 | public LeafNode() { 55 | } 56 | 57 | /** 58 | * Construct a leaf node with the given actual node, parent and parent branch 59 | * 60 | * @param node the actual node at this leaf 61 | * @param parentNode the parent split node 62 | * @param parentBranch the branch leading to this node 63 | */ 64 | public LeafNode(HNode node, SplitNode parentNode, String parentBranch) { 65 | m_theNode = node; 66 | m_parentNode = parentNode; 67 | m_parentBranch = parentBranch; 68 | } 69 | 70 | @Override 71 | public void updateNode(Instance inst) throws Exception { 72 | if (m_theNode != null) { 73 | m_theNode.updateDistribution(inst); 74 | } else { 75 | super.updateDistribution(inst); 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/weka/classifiers/trees/ht/LearningNode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * LearningNode.java 18 | * Copyright (C) 2013 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.classifiers.trees.ht; 23 | 24 | /** 25 | * Marker interface for a node that can be updated with incoming instances in a 26 | * HoeffdingTree. Implementations include ActiveHNode, NBNode and NBNodeAdaptive 27 | * 28 | * @author Mark Hall (mhall{[at]}pentaho{[dot]}com) 29 | * @version $Revision: 9705 $ 30 | */ 31 | public interface LearningNode { 32 | } 33 | -------------------------------------------------------------------------------- /src/weka/classifiers/trees/ht/Split.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * Split.java 18 | * Copyright (C) 2013 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.classifiers.trees.ht; 23 | 24 | import java.util.ArrayList; 25 | import java.util.List; 26 | 27 | import weka.core.Instance; 28 | 29 | /** 30 | * Base class for different split types 31 | * 32 | * @author Richard Kirkby (rkirkby@cs.waikato.ac.nz) 33 | * @author Mark Hall (mhall{[at]}pentaho{[dot]}com) 34 | * @version $Revision: 9705 $ 35 | */ 36 | public abstract class Split { 37 | 38 | /** name(s) of attribute(s) involved in the split */ 39 | protected List m_splitAttNames = new ArrayList(); 40 | 41 | /** 42 | * Returns the name of the branch that the supplied instance would go down 43 | * 44 | * @param inst the instance to find the branch for 45 | * @return the name of the branch that the instance would go down 46 | */ 47 | public abstract String branchForInstance(Instance inst); 48 | 49 | /** 50 | * Returns the condition for the supplied branch name 51 | * 52 | * @param branch the name of the branch to get the condition for 53 | * @return the condition (test) that corresponds to the named branch 54 | */ 55 | public abstract String conditionForBranch(String branch); 56 | 57 | public List splitAttributes() { 58 | return m_splitAttNames; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/weka/classifiers/trees/ht/SplitCandidate.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * SplitCandidate.java 18 | * Copyright (C) 2013 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.classifiers.trees.ht; 23 | 24 | import java.util.List; 25 | import java.util.Map; 26 | 27 | /** 28 | * Encapsulates a candidate split 29 | * 30 | * @author Richard Kirkby (rkirkby@cs.waikato.ac.nz) 31 | * @author Mark Hall (mhall{[at]}pentaho{[dot]}com) 32 | * @version $Revision: 9705 $ 33 | */ 34 | public class SplitCandidate implements Comparable { 35 | 36 | public Split m_splitTest; 37 | 38 | /** 39 | * list of class distributions resulting from a split - 2 entries in the outer 40 | * list for numeric splits and n for nominal splits 41 | */ 42 | public List> m_postSplitClassDistributions; 43 | 44 | /** The merit of the split */ 45 | public double m_splitMerit; 46 | 47 | /** 48 | * Constructor 49 | * 50 | * @param splitTest the splitting test 51 | * @param postSplitDists the distributions resulting from the split 52 | * @param merit the merit of the split 53 | */ 54 | public SplitCandidate(Split splitTest, 55 | List> postSplitDists, double merit) { 56 | m_splitTest = splitTest; 57 | m_postSplitClassDistributions = postSplitDists; 58 | m_splitMerit = merit; 59 | } 60 | 61 | /** 62 | * Number of branches resulting from the split 63 | * 64 | * @return the number of subsets of instances resulting from the split 65 | */ 66 | public int numSplits() { 67 | return m_postSplitClassDistributions.size(); 68 | } 69 | 70 | @Override 71 | public int compareTo(SplitCandidate comp) { 72 | return Double.compare(m_splitMerit, comp.m_splitMerit); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/weka/classifiers/trees/ht/SplitMetric.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * SplitMetric.java 18 | * Copyright (C) 2013 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.classifiers.trees.ht; 23 | 24 | import java.io.Serializable; 25 | import java.util.List; 26 | import java.util.Map; 27 | 28 | /** 29 | * Base class for split metrics 30 | * 31 | * @author Richard Kirkby (rkirkby@cs.waikato.ac.nz) 32 | * @author Mark Hall (mhall{[at]}pentaho{[dot]}com) 33 | * @version $Revision: 9720 $ 34 | */ 35 | public abstract class SplitMetric implements Serializable { 36 | 37 | /** 38 | * For serialization 39 | */ 40 | private static final long serialVersionUID = 2891555018707080818L; 41 | 42 | /** 43 | * Utility method to return the sum of instance weight in a distribution 44 | * 45 | * @param dist the distribution 46 | * @return the sum of the weights contained in a distribution 47 | */ 48 | public static double sum(Map dist) { 49 | double sum = 0; 50 | 51 | for (Map.Entry e : dist.entrySet()) { 52 | sum += e.getValue().m_weight; 53 | } 54 | 55 | return sum; 56 | } 57 | 58 | /** 59 | * Evaluate the merit of a split 60 | * 61 | * @param preDist the class distribution before the split 62 | * @param postDist the class distributions after the split 63 | * @return the merit of the split 64 | */ 65 | public abstract double evaluateSplit(Map preDist, 66 | List> postDist); 67 | 68 | /** 69 | * Get the range of the splitting metric 70 | * 71 | * @param preDist the pre-split class distribution 72 | * @return the range of the splitting metric 73 | */ 74 | public abstract double getMetricRange(Map preDist); 75 | } 76 | -------------------------------------------------------------------------------- /src/weka/classifiers/trees/ht/UnivariateNominalMultiwaySplit.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * UnivariateNominalMultiwaySplit.java 18 | * Copyright (C) 2013 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.classifiers.trees.ht; 23 | 24 | import java.io.Serializable; 25 | 26 | import weka.core.Attribute; 27 | import weka.core.Instance; 28 | 29 | /** 30 | * A multiway split based on a single nominal attribute 31 | * 32 | * @author Richard Kirkby (rkirkby@cs.waikato.ac.nz) 33 | * @author Mark Hall (mhall{[at]}pentaho{[dot]}com) 34 | * @version $Revision: 9705 $ 35 | */ 36 | public class UnivariateNominalMultiwaySplit extends Split implements 37 | Serializable { 38 | 39 | /** 40 | * For serialization 41 | */ 42 | private static final long serialVersionUID = -9094590488097956665L; 43 | 44 | /** 45 | * Constructor 46 | * 47 | * @param attName the name of the attribute to split on 48 | */ 49 | public UnivariateNominalMultiwaySplit(String attName) { 50 | m_splitAttNames.add(attName); 51 | } 52 | 53 | @Override 54 | public String branchForInstance(Instance inst) { 55 | Attribute att = inst.dataset().attribute(m_splitAttNames.get(0)); 56 | if (att == null || inst.isMissing(att)) { 57 | return null; 58 | } 59 | return att.value((int) inst.value(att)); 60 | } 61 | 62 | @Override 63 | public String conditionForBranch(String branch) { 64 | return m_splitAttNames.get(0) + " = " + branch; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/weka/classifiers/trees/ht/UnivariateNumericBinarySplit.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * UnivariateNumericBinarySplit.java 18 | * Copyright (C) 2013 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.classifiers.trees.ht; 23 | 24 | import java.io.Serializable; 25 | 26 | import weka.core.Attribute; 27 | import weka.core.Instance; 28 | 29 | /** 30 | * A binary split based on a single numeric attribute 31 | * 32 | * @author Richard Kirkby (rkirkby@cs.waikato.ac.nz) 33 | * @author Mark Hall (mhall{[at]}pentaho{[dot]}com) 34 | * @version $Revision: 9705 $ 35 | */ 36 | public class UnivariateNumericBinarySplit extends Split implements Serializable { 37 | 38 | /** 39 | * For serialization 40 | */ 41 | private static final long serialVersionUID = -7392204582942741097L; 42 | 43 | /** The split point */ 44 | protected double m_splitPoint; 45 | 46 | /** 47 | * Constructor 48 | * 49 | * @param attName the name of the attribute to split on 50 | * @param splitPoint the split point 51 | */ 52 | public UnivariateNumericBinarySplit(String attName, double splitPoint) { 53 | m_splitAttNames.add(attName); 54 | m_splitPoint = splitPoint; 55 | } 56 | 57 | @Override 58 | public String branchForInstance(Instance inst) { 59 | 60 | Attribute att = inst.dataset().attribute(m_splitAttNames.get(0)); 61 | if (att == null || inst.isMissing(att)) { 62 | // TODO ------------- 63 | return null; 64 | } 65 | 66 | if (inst.value(att) <= m_splitPoint) { 67 | return "left"; 68 | } 69 | 70 | return "right"; 71 | } 72 | 73 | @Override 74 | public String conditionForBranch(String branch) { 75 | String result = m_splitAttNames.get(0); 76 | 77 | if (branch.equalsIgnoreCase("left")) { 78 | result += " <= "; 79 | } else { 80 | result += " > "; 81 | } 82 | 83 | result += String.format("%-9.3f", m_splitPoint); 84 | 85 | return result; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/weka/classifiers/trees/ht/WeightMass.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * WeightMass.java 18 | * Copyright (C) 2013 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.classifiers.trees.ht; 23 | 24 | import java.io.Serializable; 25 | 26 | /** 27 | * Simple container for a weight 28 | * 29 | * @author Mark Hall (mhall{[at]}pentaho{[dot]}com) 30 | * @version $Revision: 9707 $ 31 | */ 32 | public class WeightMass implements Serializable { 33 | 34 | /** 35 | * For serialization 36 | */ 37 | private static final long serialVersionUID = 6794839107050779425L; 38 | 39 | public double m_weight; 40 | } 41 | -------------------------------------------------------------------------------- /src/weka/classifiers/trees/j48/EntropyBasedSplitCrit.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * EntropyBasedSplitCrit.java 18 | * Copyright (C) 1999-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.classifiers.trees.j48; 23 | 24 | /** 25 | * "Abstract" class for computing splitting criteria 26 | * based on the entropy of a class distribution. 27 | * 28 | * @author Eibe Frank (eibe@cs.waikato.ac.nz) 29 | * @version $Revision: 8034 $ 30 | */ 31 | public abstract class EntropyBasedSplitCrit 32 | extends SplitCriterion { 33 | 34 | /** for serialization */ 35 | private static final long serialVersionUID = -2618691439791653056L; 36 | 37 | /** The log of 2. */ 38 | protected static double log2 = Math.log(2); 39 | 40 | /** 41 | * Help method for computing entropy. 42 | */ 43 | public final double logFunc(double num) { 44 | 45 | // Constant hard coded for efficiency reasons 46 | if (num < 1e-6) 47 | return 0; 48 | else 49 | return num*Math.log(num)/log2; 50 | } 51 | 52 | /** 53 | * Computes entropy of distribution before splitting. 54 | */ 55 | public final double oldEnt(Distribution bags) { 56 | 57 | double returnValue = 0; 58 | int j; 59 | 60 | for (j=0;j. 14 | */ 15 | 16 | /* 17 | * EntropySplitCrit.java 18 | * Copyright (C) 1999-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.classifiers.trees.j48; 23 | 24 | import weka.core.RevisionUtils; 25 | import weka.core.Utils; 26 | 27 | /** 28 | * Class for computing the entropy for a given distribution. 29 | * 30 | * @author Eibe Frank (eibe@cs.waikato.ac.nz) 31 | * @version $Revision: 8034 $ 32 | */ 33 | public final class EntropySplitCrit 34 | extends EntropyBasedSplitCrit { 35 | 36 | /** for serialization */ 37 | private static final long serialVersionUID = 5986252682266803935L; 38 | 39 | /** 40 | * Computes entropy for given distribution. 41 | */ 42 | public final double splitCritValue(Distribution bags) { 43 | 44 | return newEnt(bags); 45 | } 46 | 47 | /** 48 | * Computes entropy of test distribution with respect to training distribution. 49 | */ 50 | public final double splitCritValue(Distribution train, Distribution test) { 51 | 52 | double result = 0; 53 | int numClasses = 0; 54 | int i, j; 55 | 56 | // Find out relevant number of classes 57 | for (j = 0; j < test.numClasses(); j++) 58 | if (Utils.gr(train.perClass(j), 0) || Utils.gr(test.perClass(j), 0)) 59 | numClasses++; 60 | 61 | // Compute entropy of test data with respect to training data 62 | for (i = 0; i < test.numBags(); i++) 63 | if (Utils.gr(test.perBag(i),0)) { 64 | for (j = 0; j < test.numClasses(); j++) 65 | if (Utils.gr(test.perClassPerBag(i, j), 0)) 66 | result -= test.perClassPerBag(i, j)* 67 | Math.log(train.perClassPerBag(i, j) + 1); 68 | result += test.perBag(i) * Math.log(train.perBag(i) + numClasses); 69 | } 70 | 71 | return result / log2; 72 | } 73 | 74 | /** 75 | * Returns the revision string. 76 | * 77 | * @return the revision 78 | */ 79 | public String getRevision() { 80 | return RevisionUtils.extract("$Revision: 8034 $"); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/weka/classifiers/trees/j48/ModelSelection.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * ModelSelection.java 18 | * Copyright (C) 1999-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.classifiers.trees.j48; 23 | 24 | import java.io.Serializable; 25 | 26 | import weka.core.Instances; 27 | import weka.core.RevisionHandler; 28 | 29 | /** 30 | * Abstract class for model selection criteria. 31 | * 32 | * @author Eibe Frank (eibe@cs.waikato.ac.nz) 33 | * @version $Revision: 8034 $ 34 | */ 35 | public abstract class ModelSelection 36 | implements Serializable, RevisionHandler { 37 | 38 | /** for serialization */ 39 | private static final long serialVersionUID = -4850147125096133642L; 40 | 41 | /** 42 | * Selects a model for the given dataset. 43 | * 44 | * @exception Exception if model can't be selected 45 | */ 46 | public abstract ClassifierSplitModel selectModel(Instances data) throws Exception; 47 | 48 | /** 49 | * Selects a model for the given train data using the given test data 50 | * 51 | * @exception Exception if model can't be selected 52 | */ 53 | public ClassifierSplitModel selectModel(Instances train, Instances test) 54 | throws Exception { 55 | 56 | throw new Exception("Model selection method not implemented"); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/weka/classifiers/trees/j48/SplitCriterion.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * SplitCriterion.java 18 | * Copyright (C) 1999-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.classifiers.trees.j48; 23 | 24 | import java.io.Serializable; 25 | 26 | import weka.core.RevisionHandler; 27 | 28 | /** 29 | * Abstract class for computing splitting criteria 30 | * with respect to distributions of class values. 31 | * 32 | * @author Eibe Frank (eibe@cs.waikato.ac.nz) 33 | * @version $Revision: 8034 $ 34 | */ 35 | public abstract class SplitCriterion 36 | implements Serializable, RevisionHandler { 37 | 38 | /** for serialization */ 39 | private static final long serialVersionUID = 5490996638027101259L; 40 | 41 | /** 42 | * Computes result of splitting criterion for given distribution. 43 | * 44 | * @return value of splitting criterion. 0 by default 45 | */ 46 | public double splitCritValue(Distribution bags){ 47 | 48 | return 0; 49 | } 50 | 51 | /** 52 | * Computes result of splitting criterion for given training and 53 | * test distributions. 54 | * 55 | * @return value of splitting criterion. 0 by default 56 | */ 57 | public double splitCritValue(Distribution train, Distribution test){ 58 | 59 | return 0; 60 | } 61 | 62 | /** 63 | * Computes result of splitting criterion for given training and 64 | * test distributions and given number of classes. 65 | * 66 | * @return value of splitting criterion. 0 by default 67 | */ 68 | public double splitCritValue(Distribution train, Distribution test, 69 | int noClassesDefault){ 70 | 71 | return 0; 72 | } 73 | 74 | /** 75 | * Computes result of splitting criterion for given training and 76 | * test distributions and given default distribution. 77 | * 78 | * @return value of splitting criterion. 0 by default 79 | */ 80 | public double splitCritValue(Distribution train, Distribution test, 81 | Distribution defC){ 82 | 83 | return 0; 84 | } 85 | } 86 | 87 | 88 | -------------------------------------------------------------------------------- /src/weka/classifiers/trees/m5/SplitEvaluate.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * SplitEvaluate.java 18 | * Copyright (C) 2000-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.classifiers.trees.m5; 23 | 24 | import weka.core.Instances; 25 | 26 | /** 27 | * Interface for objects that determine a split point on an attribute 28 | * 29 | * @author Mark Hall (mhall@cs.waikato.ac.nz) 30 | * @version $Revision: 8034 $ 31 | */ 32 | public interface SplitEvaluate { 33 | 34 | /** 35 | * makes a copy of the SplitEvaluate object 36 | * @return a copy of the object 37 | */ 38 | SplitEvaluate copy () throws Exception; 39 | 40 | /** 41 | * Finds the best splitting point for an attribute in the instances 42 | * @param attr the splitting attribute 43 | * @param inst the instances 44 | * @exception Exception if something goes wrong 45 | */ 46 | void attrSplit (int attr, Instances inst) throws Exception; 47 | 48 | /** 49 | * Returns the impurity of this split 50 | * 51 | * @return the impurity of this split 52 | */ 53 | double maxImpurity(); 54 | 55 | /** 56 | * Returns the position of the split in the sorted values. -1 indicates that 57 | * a split could not be found. 58 | * 59 | * @return an int value 60 | */ 61 | int position(); 62 | 63 | /** 64 | * Returns the attribute used in this split 65 | * 66 | * @return the attribute used in this split 67 | */ 68 | int splitAttr(); 69 | 70 | /** 71 | * Returns the split value 72 | * 73 | * @return the split value 74 | */ 75 | double splitValue(); 76 | 77 | } 78 | -------------------------------------------------------------------------------- /src/weka/classifiers/xml/XMLClassifier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | 15 | 16 | 17 | * XMLClassifier.java 18 | * Copyright (C) 2004-2012 University of Waikato, Hamilton, New Zealand 19 | 20 | 21 | package weka.classifiers.xml; 22 | 23 | import weka.core.RevisionUtils; 24 | import weka.core.xml.XMLBasicSerialization; 25 | 26 | *//** 27 | * This class serializes and deserializes a Classifier instance to and 28 | * fro XML.
29 | * 30 | * @author FracPete (fracpete at waikato dot ac dot nz) 31 | * @version $Revision: 8034 $ 32 | */ 33 | /* 34 | public class XMLClassifier 35 | extends XMLBasicSerialization { 36 | 37 | *//** 38 | * initializes the serialization 39 | * 40 | * @throws Exception if initialization fails 41 | */ 42 | /* 43 | public XMLClassifier() throws Exception { 44 | super(); 45 | } 46 | 47 | *//** 48 | * generates internally a new XML document and clears also the IgnoreList and 49 | * the mappings for the Read/Write-Methods 50 | */ 51 | /* 52 | public void clear() throws Exception { 53 | super.clear(); 54 | 55 | // allow 56 | m_Properties.addAllowed(weka.classifiers.Classifier.class, "debug"); 57 | m_Properties.addAllowed(weka.classifiers.Classifier.class, "options"); 58 | } 59 | 60 | *//** 61 | * Returns the revision string. 62 | * 63 | * @return the revision 64 | */ 65 | /* 66 | public String getRevision() { 67 | return RevisionUtils.extract("$Revision: 8034 $"); 68 | } 69 | } 70 | */ -------------------------------------------------------------------------------- /src/weka/clusterers/Clusterer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * Clusterer.java 18 | * Copyright (C) 1999-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.clusterers; 23 | 24 | import weka.core.Capabilities; 25 | import weka.core.Instance; 26 | import weka.core.Instances; 27 | 28 | /** 29 | * Interface for clusterers. Clients will typically extend either 30 | * AbstractClusterer or AbstractDensityBasedClusterer. 31 | * 32 | * @author Mark Hall (mhall@cs.waikato.ac.nz) 33 | * @version $Revision: 8034 $ 34 | */ 35 | public interface Clusterer { 36 | 37 | /** 38 | * Generates a clusterer. Has to initialize all fields of the clusterer 39 | * that are not being set via options. 40 | * 41 | * @param data set of instances serving as training data 42 | * @exception Exception if the clusterer has not been 43 | * generated successfully 44 | */ 45 | void buildClusterer(Instances data) throws Exception; 46 | 47 | /** 48 | * Classifies a given instance. Either this or distributionForInstance() 49 | * needs to be implemented by subclasses. 50 | * 51 | * @param instance the instance to be assigned to a cluster 52 | * @return the number of the assigned cluster as an integer 53 | * @exception Exception if instance could not be clustered 54 | * successfully 55 | */ 56 | int clusterInstance(Instance instance) throws Exception; 57 | 58 | /** 59 | * Predicts the cluster memberships for a given instance. Either 60 | * this or clusterInstance() needs to be implemented by subclasses. 61 | * 62 | * @param instance the instance to be assigned a cluster. 63 | * @return an array containing the estimated membership 64 | * probabilities of the test instance in each cluster (this 65 | * should sum to at most 1) 66 | * @exception Exception if distribution could not be 67 | * computed successfully 68 | */ 69 | public double[] distributionForInstance(Instance instance) throws Exception; 70 | 71 | /** 72 | * Returns the number of clusters. 73 | * 74 | * @return the number of clusters generated for a training dataset. 75 | * @exception Exception if number of clusters could not be returned 76 | * successfully 77 | */ 78 | int numberOfClusters() throws Exception; 79 | 80 | /** 81 | * Returns the Capabilities of this clusterer. Derived classifiers have to 82 | * override this method to enable capabilities. 83 | * 84 | * @return the capabilities of this object 85 | * @see Capabilities 86 | */ 87 | public Capabilities getCapabilities(); 88 | 89 | } 90 | -------------------------------------------------------------------------------- /src/weka/clusterers/DensityBasedClusterer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * DensityBasedClusterer.java 18 | * Copyright (C) 1999-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.clusterers; 23 | 24 | import weka.core.Instance; 25 | 26 | /** 27 | * Interface for clusterers that can estimate the density for a given instance. 28 | * Implementations will typically extend AbstractDensityBasedClusterer. 29 | * 30 | * @author Mark Hall (mhall@cs.waikato.ac.nz) 31 | * @author Eibe Frank (eibe@cs.waikato.ac.nz) 32 | * @version $Revision: 9379 $ 33 | */ 34 | public interface DensityBasedClusterer extends Clusterer { 35 | 36 | /** 37 | * Returns the prior probability of each cluster. 38 | * 39 | * @return the prior probability for each cluster 40 | * @exception Exception if priors could not be returned successfully 41 | */ 42 | double[] clusterPriors() throws Exception; 43 | 44 | /** 45 | * Computes the log of the conditional density (per cluster) for a given 46 | * instance. 47 | * 48 | * @param instance the instance to compute the density for 49 | * @return an array containing the estimated densities 50 | * @exception Exception if the density could not be computed successfully 51 | */ 52 | double[] logDensityPerClusterForInstance(Instance instance) throws Exception; 53 | 54 | /** 55 | * Computes the density for a given instance. 56 | * 57 | * @param instance the instance to compute the density for 58 | * @return the density. 59 | * @exception Exception if the density could not be computed successfully 60 | */ 61 | double logDensityForInstance(Instance instance) throws Exception; 62 | 63 | /** 64 | * Returns the logs of the joint densities for a given instance. 65 | * 66 | * @param inst the instance 67 | * @return the array of values 68 | * @exception Exception if values could not be computed 69 | */ 70 | double[] logJointDensitiesForInstance(Instance inst) throws Exception; 71 | 72 | /** 73 | * Returns the cluster probability distribution for an instance. 74 | * 75 | * @param instance the instance to be clustered 76 | * @return the probability distribution 77 | * @throws Exception if computation fails 78 | */ 79 | @Override 80 | double[] distributionForInstance(Instance instance) throws Exception; 81 | } 82 | -------------------------------------------------------------------------------- /src/weka/clusterers/NumberOfClustersRequestable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * NumberOfClustersRequestable.java 18 | * Copyright (C) 2004-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.clusterers; 23 | 24 | /** 25 | * Interface to a clusterer that can generate a requested number of 26 | * clusters 27 | * 28 | * @author Mark Hall 29 | * @version $Revision: 8034 $ 30 | */ 31 | public interface NumberOfClustersRequestable { 32 | 33 | /** 34 | * Set the number of clusters to generate 35 | * 36 | * @param numClusters the number of clusters to generate 37 | * @exception Exception if the requested number of 38 | * clusters in inapropriate 39 | */ 40 | void setNumClusters(int numClusters) throws Exception; 41 | 42 | } 43 | 44 | -------------------------------------------------------------------------------- /src/weka/clusterers/UpdateableClusterer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * UpdateableClusterer.java 18 | * Copyright (C) 2006-2012 University of Waikato, Hamilton, New Zealand 19 | */ 20 | 21 | package weka.clusterers; 22 | 23 | import weka.core.Instance; 24 | 25 | /** 26 | * Interface to incremental cluster models that can learn using one instance 27 | * at a time. 28 | * 29 | * @author FracPete (fracpete at waikato dot ac dot nz) 30 | * @version $Revision: 8034 $ 31 | */ 32 | public interface UpdateableClusterer { 33 | 34 | /** 35 | * Adds an instance to the clusterer. 36 | * 37 | * @param newInstance the instance to be added 38 | * @throws Exception if something goes wrong 39 | */ 40 | public void updateClusterer(Instance newInstance) throws Exception; 41 | 42 | /** 43 | * Singals the end of the updating. 44 | */ 45 | public void updateFinished(); 46 | } 47 | -------------------------------------------------------------------------------- /src/weka/core/AdditionalMeasureProducer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * AdditionalMeasureProducer.java 18 | * Copyright (C) 2000-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.core; 23 | 24 | import java.util.Enumeration; 25 | 26 | /** 27 | * Interface to something that can produce measures other than those 28 | * calculated by evaluation modules. 29 | * 30 | * @author Mark Hall (mhall@cs.waikato.ac.nz) 31 | * @version $Revision: 8034 $ 32 | */ 33 | public interface AdditionalMeasureProducer { 34 | 35 | /** 36 | * Returns an enumeration of the measure names. Additional measures 37 | * must follow the naming convention of starting with "measure", eg. 38 | * double measureBlah() 39 | * @return an enumeration of the measure names 40 | */ 41 | Enumeration enumerateMeasures(); 42 | 43 | /** 44 | * Returns the value of the named measure 45 | * @param measureName the name of the measure to query for its value 46 | * @return the value of the named measure 47 | * @exception IllegalArgumentException if the named measure is not supported 48 | */ 49 | double getMeasure(String measureName); 50 | } 51 | -------------------------------------------------------------------------------- /src/weka/core/Aggregateable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * Aggregateable.java 18 | * Copyright (C) 2013 University of Waikato, Hamilton, New Zealand 19 | */ 20 | 21 | package weka.core; 22 | 23 | /** 24 | * Interface to something that can aggregate an object of the same type with 25 | * itself. 26 | * 27 | * @author Mark Hall (mhall{[at]}pentaho{[dot]}com) 28 | * @version $Revision: 9784 $ 29 | */ 30 | public interface Aggregateable { 31 | 32 | /** 33 | * Aggregate an object with this one 34 | * 35 | * @param toAggregate the object to aggregate 36 | * @return the result of aggregation 37 | * @throws Exception if the supplied object can't be aggregated for some 38 | * reason 39 | */ 40 | E aggregate(E toAggregate) throws Exception; 41 | 42 | /** 43 | * Call to complete the aggregation process. Allows implementers to do any 44 | * final processing based on how many objects were aggregated. 45 | * 46 | * @throws Exception if the aggregation can't be finalized for some reason 47 | */ 48 | void finalizeAggregation() throws Exception; 49 | } 50 | -------------------------------------------------------------------------------- /src/weka/core/BatchPredictor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * BatchPredictor.java 18 | * Copyright (C) 2012 University of Waikato, Hamilton, New Zealand. 19 | * 20 | */ 21 | 22 | package weka.core; 23 | 24 | /** 25 | * Interface to something that can produce predictions in a batch manner 26 | * when presented with a set of Instances. 27 | * 28 | * @author Mark Hall (mhall{[at]}pentaho{[dot]}com) 29 | * @version $Revision: 8937 $ 30 | */ 31 | public interface BatchPredictor { 32 | 33 | /** 34 | * Set the batch size to use. The implementer will 35 | * prefer (but not necessarily expect) this many instances 36 | * to be passed in to distributionsForInstances(). 37 | * 38 | * @param size the batch size to use 39 | */ 40 | void setBatchSize(String size); 41 | 42 | /** 43 | * Get the batch size to use. The implementer will prefer (but not 44 | * necessarily expect) this many instances to be passed in to 45 | * distributionsForInstances(). Allows the preferred batch size 46 | * to be encapsulated with the client. 47 | * 48 | * @return the batch size to use 49 | */ 50 | String getBatchSize(); 51 | 52 | /** 53 | * Batch scoring method 54 | * 55 | * @param insts the instances to get predictions for 56 | * @return an array of probability distributions, one for each instance 57 | * @throws Exception if a problem occurs 58 | */ 59 | double[][] distributionsForInstances(Instances insts) throws Exception; 60 | } 61 | -------------------------------------------------------------------------------- /src/weka/core/CapabilitiesHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * CapabilitiesHandler.java 18 | * Copyright (C) 2006-2012 University of Waikato, Hamilton, New Zealand 19 | */ 20 | 21 | package weka.core; 22 | 23 | /** 24 | * Classes implementing this interface return their capabilities in regards 25 | * to datasets. 26 | * 27 | * @author FracPete (fracpete at waikato dot ac dot nz) 28 | * @version $Revision: 8034 $ 29 | * @see Capabilities 30 | */ 31 | public interface CapabilitiesHandler { 32 | 33 | /** 34 | * Returns the capabilities of this object. 35 | * 36 | * @return the capabilities of this object 37 | * @see Capabilities 38 | */ 39 | public Capabilities getCapabilities(); 40 | } 41 | -------------------------------------------------------------------------------- /src/weka/core/CommandlineRunnable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * CommandlineRunnable.java 18 | * Copyright (C) 2010-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.core; 23 | 24 | /** 25 | * Interface to something that can be run from the command line. 26 | * 27 | * @author Mark Hall (mhall{[at]}pentaho{[dot]}com) 28 | * @version $Revision: 8034 $ 29 | */ 30 | public interface CommandlineRunnable { 31 | 32 | /** 33 | * Execute the supplied object. 34 | * 35 | * @param toRun the object to execute 36 | * @param options any options to pass to the object 37 | * @throws IllegalArgumentException if the object is not of the expected 38 | * type. 39 | */ 40 | void run(Object toRun, String[] options) throws IllegalArgumentException; 41 | } 42 | -------------------------------------------------------------------------------- /src/weka/core/Copyable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * Copyable.java 18 | * Copyright (C) 1999-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.core; 23 | 24 | /** 25 | * Interface implemented by classes that can produce "shallow" copies 26 | * of their objects. (As opposed to clone(), which is supposed to 27 | * produce a "deep" copy.) 28 | * 29 | * @author Eibe Frank (eibe@cs.waikato.ac.nz) 30 | * @version $Revision: 8034 $ 31 | */ 32 | public interface Copyable { 33 | 34 | /** 35 | * This method produces a shallow copy of an object. 36 | * It does the same as the clone() method in Object, which also produces 37 | * a shallow copy. 38 | */ 39 | Object copy(); 40 | } 41 | -------------------------------------------------------------------------------- /src/weka/core/CustomDisplayStringProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /** 17 | * CustomDisplayStringProvider.java 18 | * Copyright (C) 2010-2012 University of Waikato, Hamilton, New Zealand 19 | */ 20 | package weka.core; 21 | 22 | /** 23 | * For classes that do not implement the OptionHandler interface and want to 24 | * provide a custom display string in the GenericObjectEditor, which is more 25 | * descriptive than the class name. 26 | * 27 | * @author fracpete (fracpete at waikato dot ac dot nz) 28 | * @version $Revision: 8034 $ 29 | */ 30 | public interface CustomDisplayStringProvider { 31 | 32 | /** 33 | * Returns the custom display string. 34 | * 35 | * @return the string 36 | */ 37 | public String toDisplay(); 38 | } 39 | -------------------------------------------------------------------------------- /src/weka/core/Drawable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * Drawable.java 18 | * Copyright (C) 1999-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.core; 23 | 24 | /** 25 | * Interface to something that can be drawn as a graph. 26 | * 27 | * @author Ashraf M. Kibriya(amk14@cs.waikato.ac.nz), Eibe Frank(eibe@cs.waikato.ac.nz) 28 | * @version $Revision: 8034 $ 29 | */ 30 | public interface Drawable { 31 | 32 | int NOT_DRAWABLE = 0, TREE = 1, BayesNet = 2, Newick = 3; 33 | 34 | /** 35 | * Returns the type of graph representing 36 | * the object. 37 | * 38 | * @return the type of graph representing the object 39 | */ 40 | int graphType(); 41 | 42 | /** 43 | * Returns a string that describes a graph representing 44 | * the object. The string should be in XMLBIF ver. 45 | * 0.3 format if the graph is a BayesNet, otherwise 46 | * it should be in dotty format. 47 | * 48 | * @return the graph described by a string 49 | * @exception Exception if the graph can't be computed 50 | */ 51 | String graph() throws Exception; 52 | } 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /src/weka/core/EnvironmentHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * EnvironmentHandler.java 18 | * Copyright (C) 2009-2012 University of Waikato, Hamilton, New Zealand 19 | */ 20 | 21 | package weka.core; 22 | 23 | 24 | /** 25 | * Interface for something that can utilize environment 26 | * variables. NOTE: since environment variables should 27 | * be transient, the implementer needs to be careful 28 | * of state after de-serialization. Default system-wide 29 | * environment variables can be got via a call to 30 | * weka.core.Environment.getSystemWide() 31 | * 32 | * @author mhall (mhall{[at]}pentaho{[dot]}com) 33 | * @version $Revision: 8034 $ 34 | */ 35 | public interface EnvironmentHandler { 36 | 37 | /** 38 | * Set environment variables to use. 39 | * 40 | * @param env the environment variables to 41 | * use 42 | */ 43 | void setEnvironment(Environment env); 44 | } 45 | -------------------------------------------------------------------------------- /src/weka/core/Matchable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * Matchable.java 18 | * Copyright (C) 1999-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.core; 23 | 24 | /** 25 | * Interface to something that can be matched with tree matching 26 | * algorithms. 27 | * 28 | * @author Len Trigg (trigg@cs.waikato.ac.nz) 29 | * @version $Revision: 8034 $ 30 | */ 31 | public interface Matchable { 32 | 33 | /** 34 | * Returns a string that describes a tree representing 35 | * the object in prefix order. 36 | * 37 | * @return the tree described as a string 38 | * @exception Exception if the tree can't be computed 39 | */ 40 | String prefix() throws Exception; 41 | } 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /src/weka/core/MultiInstanceCapabilitiesHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * MultiInstanceClassifier.java 18 | * Copyright (C) 2006-2012 University of Waikato, Hamilton, New Zealand 19 | */ 20 | 21 | package weka.core; 22 | 23 | /** 24 | * Multi-Instance classifiers can specify an additional Capabilities object 25 | * for the data in the relational attribute, since the format of multi-instance 26 | * data is fixed to "bag/NOMINAL,data/RELATIONAL,class". 27 | * 28 | * @author fracpete (fracpete at waikato dot ac dot nz) 29 | * @version $Revision: 8034 $ 30 | */ 31 | public interface MultiInstanceCapabilitiesHandler 32 | extends CapabilitiesHandler { 33 | 34 | /** 35 | * Returns the capabilities of this multi-instance classifier for the 36 | * relational data (i.e., the bags). 37 | * 38 | * @return the capabilities of this object 39 | * @see Capabilities 40 | */ 41 | public Capabilities getMultiInstanceCapabilities(); 42 | } 43 | -------------------------------------------------------------------------------- /src/weka/core/NoSupportForMissingValuesException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * NoSupportForMissingValuesException.java 18 | * Copyright (C) 2002-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.core; 23 | 24 | /** 25 | * Exception that is raised by an object that is unable to process 26 | * data with missing values. 27 | * 28 | * @author Eibe Frank (eibe@cs.waikato.ac.nz) 29 | * @version $Revision: 8034 $ 30 | */ 31 | public class NoSupportForMissingValuesException 32 | extends WekaException { 33 | 34 | /** for serialization */ 35 | private static final long serialVersionUID = 5161175307725893973L; 36 | 37 | /** 38 | * Creates a new NoSupportForMissingValuesException with no message. 39 | * 40 | */ 41 | public NoSupportForMissingValuesException() { 42 | 43 | super(); 44 | } 45 | 46 | /** 47 | * Creates a new NoSupportForMissingValuesException. 48 | * 49 | * @param message the reason for raising an exception. 50 | */ 51 | public NoSupportForMissingValuesException(String message) { 52 | 53 | super(message); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/weka/core/Option.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * Option.java 18 | * Copyright (C) 1999-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.core; 23 | 24 | /** 25 | * Class to store information about an option.

26 | * 27 | * Typical usage:

28 | * 29 | * Option myOption = new Option("Uses extended mode.", "E", 0, "-E"));

30 | * 31 | * @author Eibe Frank (eibe@cs.waikato.ac.nz) 32 | * @version $Revision: 8034 $ 33 | */ 34 | public class Option 35 | implements RevisionHandler { 36 | 37 | /** What does this option do? */ 38 | private String m_Description; 39 | 40 | /** The synopsis. */ 41 | private String m_Synopsis; 42 | 43 | /** What's the option's name? */ 44 | private String m_Name; 45 | 46 | /** How many arguments does it take? */ 47 | private int m_NumArguments; 48 | 49 | /** 50 | * Creates new option with the given parameters. 51 | * 52 | * @param description the option's description 53 | * @param name the option's name 54 | * @param numArguments the number of arguments 55 | */ 56 | public Option(String description, String name, 57 | int numArguments, String synopsis) { 58 | 59 | m_Description = description; 60 | m_Name = name; 61 | m_NumArguments = numArguments; 62 | m_Synopsis = synopsis; 63 | } 64 | 65 | /** 66 | * Returns the option's description. 67 | * 68 | * @return the option's description 69 | */ 70 | public String description() { 71 | 72 | return m_Description; 73 | } 74 | 75 | /** 76 | * Returns the option's name. 77 | * 78 | * @return the option's name 79 | */ 80 | public String name() { 81 | 82 | return m_Name; 83 | } 84 | 85 | /** 86 | * Returns the option's number of arguments. 87 | * 88 | * @return the option's number of arguments 89 | */ 90 | public int numArguments() { 91 | 92 | return m_NumArguments; 93 | } 94 | 95 | /** 96 | * Returns the option's synopsis. 97 | * 98 | * @return the option's synopsis 99 | */ 100 | public String synopsis() { 101 | 102 | return m_Synopsis; 103 | } 104 | 105 | /** 106 | * Returns the revision string. 107 | * 108 | * @return the revision 109 | */ 110 | public String getRevision() { 111 | return RevisionUtils.extract("$Revision: 8034 $"); 112 | } 113 | } 114 | 115 | -------------------------------------------------------------------------------- /src/weka/core/OptionHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * OptionHandler.java 18 | * Copyright (C) 1999-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.core; 23 | 24 | import java.util.Enumeration; 25 | 26 | /** 27 | * Interface to something that understands options. 28 | * 29 | * @author Eibe Frank (eibe@cs.waikato.ac.nz) 30 | * @author Len Trigg (trigg@cs.waikato.ac.nz) 31 | * @version $Revision: 8034 $ 32 | */ 33 | public interface OptionHandler { 34 | 35 | /** 36 | * Returns an enumeration of all the available options.. 37 | * 38 | * @return an enumeration of all available options. 39 | */ 40 | Enumeration listOptions(); 41 | 42 | /** 43 | * Sets the OptionHandler's options using the given list. All options 44 | * will be set (or reset) during this call (i.e. incremental setting 45 | * of options is not possible). 46 | * 47 | * @param options the list of options as an array of strings 48 | * @exception Exception if an option is not supported 49 | */ 50 | //@ requires options != null; 51 | //@ requires \nonnullelements(options); 52 | void setOptions(String[] options) throws Exception; 53 | 54 | /** 55 | * Gets the current option settings for the OptionHandler. 56 | * 57 | * @return the list of current option settings as an array of strings 58 | */ 59 | //@ ensures \result != null; 60 | //@ ensures \nonnullelements(\result); 61 | /*@pure@*/ String[] getOptions(); 62 | } 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /src/weka/core/PartitionGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * PartitionGenerator.java 18 | * Copyright (C) 2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | package weka.core; 22 | 23 | /** 24 | * This interface can be implemented by algorithms that generate 25 | * a partition of the instance space (e.g., decision trees). 26 | * 27 | * @author Eibe Frank (eibe@cs.waikato.ac.nz) 28 | * @version $Revision: 9117 $ 29 | */ 30 | public interface PartitionGenerator extends CapabilitiesHandler { 31 | 32 | /** 33 | * Builds the classifier to generate a partition. 34 | */ 35 | public void generatePartition(Instances data) throws Exception; 36 | 37 | /** 38 | * Computes an array that has a value for each element in the partition. 39 | */ 40 | public double[] getMembershipValues(Instance inst) throws Exception; 41 | 42 | /** 43 | * Returns the number of elements in the partition. 44 | */ 45 | public int numElements() throws Exception; 46 | } 47 | -------------------------------------------------------------------------------- /src/weka/core/Randomizable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * Randomizable.java 18 | * Copyright (C) 2003-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.core; 23 | 24 | /** 25 | * Interface to something that has random behaviour that is able to be 26 | * seeded with an integer. 27 | * 28 | * @author Richard Kirkby (rkirkby@cs.waikato.ac.nz) 29 | * @version $Revision: 8034 $ 30 | */ 31 | public interface Randomizable { 32 | 33 | /** 34 | * Set the seed for random number generation. 35 | * 36 | * @param seed the seed 37 | */ 38 | void setSeed(int seed); 39 | 40 | /** 41 | * Gets the seed for the random number generations 42 | * 43 | * @return the seed for the random number generation 44 | */ 45 | int getSeed(); 46 | } 47 | -------------------------------------------------------------------------------- /src/weka/core/RevisionHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * RevisionHandler.java 18 | * Copyright (C) 2008-2012 University of Waikato, Hamilton, New Zealand 19 | */ 20 | 21 | package weka.core; 22 | 23 | /** 24 | * For classes that should return their source control revision. 25 | * 26 | * @author fracpete (fracpete at waikato dot ac dot nz) 27 | * @version $Revision: 8034 $ 28 | * @see weka.core.RevisionUtils 29 | */ 30 | public interface RevisionHandler { 31 | 32 | /** 33 | * Returns the revision string. 34 | * 35 | * @return the revision 36 | */ 37 | public String getRevision(); 38 | } 39 | -------------------------------------------------------------------------------- /src/weka/core/Summarizable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * Summarizable.java 18 | * Copyright (C) 1999-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.core; 23 | 24 | /** 25 | * Interface to something that provides a short textual summary (as opposed 26 | * to toString() which is usually a fairly complete description) of itself. 27 | * 28 | * @author Len Trigg (trigg@cs.waikato.ac.nz) 29 | * @version $Revision: 8034 $ 30 | */ 31 | public interface Summarizable { 32 | 33 | /** 34 | * Returns a string that summarizes the object. 35 | * 36 | * @return the object summarized as a string 37 | */ 38 | String toSummaryString(); 39 | } 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /src/weka/core/TechnicalInformationHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * TechnicalInformationHandler.java 18 | * Copyright (C) 2006-2012 University of Waikato, Hamilton, New Zealand 19 | */ 20 | 21 | package weka.core; 22 | 23 | /** 24 | * For classes that are based on some kind of publications. They return 25 | * a TechnicalInformation object filled with the data of the publication. 26 | * 27 | * @author fracpete (fracpete at waikato dot ac dot nz) 28 | * @version $Revision: 8034 $ 29 | * @see TechnicalInformation 30 | */ 31 | public interface TechnicalInformationHandler { 32 | 33 | /** 34 | * Returns an instance of a TechnicalInformation object, containing 35 | * detailed information about the technical background of this class, 36 | * e.g., paper reference or book this class is based on. 37 | * 38 | * @return the technical information about this class 39 | */ 40 | public TechnicalInformation getTechnicalInformation(); 41 | } 42 | -------------------------------------------------------------------------------- /src/weka/core/ThreadSafe.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * ThreadSafe.java 18 | * Copyright (C) 2013 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.core; 23 | 24 | /** 25 | * Interface to something that is thread safe 26 | * 27 | * @author Mark Hall (mhall{[at]}pentaho{[dot]}com) 28 | * @version $Revision: 9847 $ 29 | */ 30 | public interface ThreadSafe { 31 | // marker interface only 32 | } 33 | -------------------------------------------------------------------------------- /src/weka/core/UnassignedClassException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * UnassignedClassException.java 18 | * Copyright (C) 2002-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.core; 23 | 24 | /** 25 | * Exception that is raised when trying to use some data that has no 26 | * class assigned to it, but a class is needed to perform the operation. 27 | * 28 | * @author Richard Kirkby (rkirkby@cs.waikato.ac.nz) 29 | * @version $Revision: 8034 $ 30 | */ 31 | public class UnassignedClassException 32 | extends RuntimeException { 33 | 34 | /** for serialization */ 35 | private static final long serialVersionUID = 6268278694768818235L; 36 | 37 | /** 38 | * Creates a new UnassignedClassException with no message. 39 | * 40 | */ 41 | public UnassignedClassException() { 42 | 43 | super(); 44 | } 45 | 46 | /** 47 | * Creates a new UnassignedClassException. 48 | * 49 | * @param message the reason for raising an exception. 50 | */ 51 | public UnassignedClassException(String message) { 52 | 53 | super(message); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/weka/core/UnassignedDatasetException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * UnassignedDatasetException.java 18 | * Copyright (C) 2002-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.core; 23 | 24 | /** 25 | * Exception that is raised when trying to use something that has no 26 | * reference to a dataset, when one is required. 27 | * 28 | * @author Richard Kirkby (rkirkby@cs.waikato.ac.nz) 29 | * @version $Revision: 8034 $ 30 | */ 31 | public class UnassignedDatasetException 32 | extends RuntimeException { 33 | 34 | /** for serialization */ 35 | private static final long serialVersionUID = -9000116786626328854L; 36 | 37 | /** 38 | * Creates a new UnassignedDatasetException with no message. 39 | * 40 | */ 41 | public UnassignedDatasetException() { 42 | 43 | super(); 44 | } 45 | 46 | /** 47 | * Creates a new UnassignedDatasetException. 48 | * 49 | * @param message the reason for raising an exception. 50 | */ 51 | public UnassignedDatasetException(String message) { 52 | 53 | super(message); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/weka/core/Undoable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * Copyable.java 18 | * Copyright (C) 2005-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.core; 23 | 24 | /** 25 | * Interface implemented by classes that support undo. 26 | * 27 | * @author FracPete (fracpete at waikato dot ac dot nz) 28 | * @version $Revision: 8034 $ 29 | */ 30 | public interface Undoable { 31 | /** 32 | * returns whether undo support is enabled 33 | */ 34 | public boolean isUndoEnabled(); 35 | 36 | /** 37 | * sets whether undo support is enabled 38 | */ 39 | public void setUndoEnabled(boolean enabled); 40 | 41 | /** 42 | * removes the undo history 43 | */ 44 | public void clearUndo(); 45 | 46 | /** 47 | * returns whether an undo is possible, i.e. whether there are any undo points 48 | * saved so far 49 | * 50 | * @return returns TRUE if there is an undo possible 51 | */ 52 | public boolean canUndo(); 53 | 54 | /** 55 | * undoes the last action 56 | */ 57 | public void undo(); 58 | 59 | /** 60 | * adds an undo point to the undo history 61 | */ 62 | public void addUndoPoint(); 63 | } 64 | -------------------------------------------------------------------------------- /src/weka/core/UnsupportedAttributeTypeException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * UnsuppotedAttributeTypeException.java 18 | * Copyright (C) 2002-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.core; 23 | 24 | /** 25 | * Exception that is raised by an object that is unable to process some of the 26 | * attribute types it has been passed. 27 | * 28 | * @author Richard Kirkby (rkirkby@cs.waikato.ac.nz) 29 | * @version $Revision: 8034 $ 30 | */ 31 | public class UnsupportedAttributeTypeException 32 | extends WekaException { 33 | 34 | /** for serialization */ 35 | private static final long serialVersionUID = 2658987325328414838L; 36 | 37 | /** 38 | * Creates a new UnsupportedAttributeTypeException with no message. 39 | * 40 | */ 41 | public UnsupportedAttributeTypeException() { 42 | 43 | super(); 44 | } 45 | 46 | /** 47 | * Creates a new UnsupportedAttributeTypeException. 48 | * 49 | * @param message the reason for raising an exception. 50 | */ 51 | public UnsupportedAttributeTypeException(String message) { 52 | 53 | super(message); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/weka/core/UnsupportedClassTypeException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * UnsuppotedClassTypeException.java 18 | * Copyright (C) 2002-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.core; 23 | 24 | /** 25 | * Exception that is raised by an object that is unable to process the 26 | * class type of the data it has been passed. 27 | * 28 | * @author Richard Kirkby (rkirkby@cs.waikato.ac.nz) 29 | * @version $Revision: 8034 $ 30 | */ 31 | public class UnsupportedClassTypeException 32 | extends WekaException { 33 | 34 | /** for serialization */ 35 | private static final long serialVersionUID = 5175741076972192151L; 36 | 37 | /** 38 | * Creates a new UnsupportedClassTypeException with no message. 39 | * 40 | */ 41 | public UnsupportedClassTypeException() { 42 | 43 | super(); 44 | } 45 | 46 | /** 47 | * Creates a new UnsupportedClassTypeException. 48 | * 49 | * @param message the reason for raising an exception. 50 | */ 51 | public UnsupportedClassTypeException(String message) { 52 | 53 | super(message); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/weka/core/WeightedInstancesHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * WeightedInstancesHandler.java 18 | * Copyright (C) 1999-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.core; 23 | 24 | /** 25 | * Interface to something that makes use of the information provided 26 | * by instance weights. 27 | * 28 | * @author Eibe Frank (eibe@cs.waikato.ac.nz) 29 | * @version $Revision: 8034 $ 30 | */ 31 | public interface WeightedInstancesHandler { 32 | 33 | // Nothing in here, because the class is just used as an indicator 34 | } 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /src/weka/core/WekaException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * WekaException.java 18 | * Copyright (C) 2002-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.core; 23 | 24 | /** 25 | * Class for Weka-specific exceptions. 26 | * 27 | * @author Richard Kirkby (rkirkby@cs.waikato.ac.nz) 28 | * @version $Revision: 8034 $ 29 | */ 30 | public class WekaException 31 | extends Exception { 32 | 33 | /** for serialization */ 34 | private static final long serialVersionUID = 6428269989006208585L; 35 | 36 | /** 37 | * Creates a new WekaException with no message. 38 | * 39 | */ 40 | public WekaException() { 41 | 42 | super(); 43 | } 44 | 45 | /** 46 | * Creates a new WekaException. 47 | * 48 | * @param message the reason for raising an exception. 49 | */ 50 | public WekaException(String message) { 51 | 52 | super(message); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/weka/core/converters/AbstractLoader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * AbstractLoader.java 18 | * Copyright (C) 2002-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.core.converters; 23 | 24 | import java.io.File; 25 | import java.io.IOException; 26 | import java.io.InputStream; 27 | 28 | import weka.core.Instance; 29 | import weka.core.Instances; 30 | 31 | /** 32 | * Abstract class gives default implementation of setSource 33 | * methods. All other methods must be overridden. 34 | * 35 | * @author Richard Kirkby (rkirkby@cs.waikato.ac.nz) 36 | * @version $Revision: 8034 $ 37 | */ 38 | public abstract class AbstractLoader implements Loader { 39 | 40 | /** The current retrieval mode */ 41 | protected int m_retrieval; 42 | 43 | /** 44 | * Sets the retrieval mode. 45 | * 46 | * @param mode the retrieval mode 47 | */ 48 | public void setRetrieval(int mode) { 49 | 50 | m_retrieval = mode; 51 | } 52 | 53 | /** 54 | * Gets the retrieval mode. 55 | * 56 | * @return the retrieval mode 57 | */ 58 | protected int getRetrieval() { 59 | 60 | return m_retrieval; 61 | } 62 | 63 | /** 64 | * Default implementation throws an IOException. 65 | * 66 | * @param file the File 67 | * @exception IOException always 68 | */ 69 | public void setSource(File file) throws IOException { 70 | 71 | throw new IOException("Setting File as source not supported"); 72 | } 73 | 74 | /** 75 | * Default implementation sets retrieval mode to NONE 76 | * 77 | * @exception never. 78 | */ 79 | public void reset() throws Exception { 80 | m_retrieval = NONE; 81 | } 82 | 83 | /** 84 | * Default implementation throws an IOException. 85 | * 86 | * @param input the input stream 87 | * @exception IOException always 88 | */ 89 | public void setSource(InputStream input) throws IOException { 90 | 91 | throw new IOException("Setting InputStream as source not supported"); 92 | } 93 | 94 | /* 95 | * To be overridden. 96 | */ 97 | public abstract Instances getStructure() throws IOException; 98 | 99 | /* 100 | * To be overridden. 101 | */ 102 | public abstract Instances getDataSet() throws IOException; 103 | 104 | /* 105 | * To be overridden. 106 | */ 107 | public abstract Instance getNextInstance(Instances structure) throws IOException; 108 | } 109 | -------------------------------------------------------------------------------- /src/weka/core/converters/BatchConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * BatchConverter.java 18 | * Copyright (C) 2004-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.core.converters; 23 | 24 | /** 25 | * Marker interface for a loader/saver that can retrieve instances in batch mode 26 | * 27 | * @author Mark Hall 28 | * @version $Revision 1.0 $ 29 | */ 30 | public interface BatchConverter { 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/weka/core/converters/DatabaseConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * DatabaseConverter.java 18 | * Copyright (C) 2004-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.core.converters; 23 | 24 | /** 25 | * Marker interface for a loader/saver that uses a database 26 | * 27 | * @author Mark Hall 28 | * @version $Revision 1.0 $ 29 | */ 30 | public interface DatabaseConverter { 31 | 32 | public String getUrl(); 33 | 34 | public String getUser(); 35 | 36 | public void setUrl(String url); 37 | 38 | public void setUser(String user); 39 | 40 | public void setPassword(String password); 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/weka/core/converters/FileSourcedConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * FileSourcedConverter.java 18 | * Copyright (C) 2004-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | package weka.core.converters; 22 | 23 | import java.io.File; 24 | import java.io.IOException; 25 | 26 | /** 27 | * Interface to a loader/saver that loads/saves from a file source. 28 | * 29 | * @author Mark Hall 30 | * @version $Revision: 8034 $ 31 | */ 32 | public interface FileSourcedConverter { 33 | 34 | /** 35 | * Get the file extension used for this type of file 36 | * 37 | * @return the file extension 38 | */ 39 | public String getFileExtension(); 40 | 41 | /** 42 | * Gets all the file extensions used for this type of file 43 | * 44 | * @return the file extensions 45 | */ 46 | public String[] getFileExtensions(); 47 | 48 | /** 49 | * Get a one line description of the type of file 50 | * 51 | * @return a description of the file type 52 | */ 53 | public String getFileDescription(); 54 | 55 | /** 56 | * Set the file to load from/ to save in 57 | * 58 | * @param file the file to load from 59 | * @exception IOException if an error occurs 60 | */ 61 | public void setFile(File file) throws IOException; 62 | 63 | /** 64 | * Return the current source file/ destination file 65 | * 66 | * @return a File value 67 | */ 68 | public File retrieveFile(); 69 | 70 | /** 71 | * Set whether to use relative rather than absolute paths 72 | * 73 | * @param rp true if relative paths are to be used 74 | */ 75 | public void setUseRelativePath(boolean rp); 76 | 77 | /** 78 | * Gets whether relative paths are to be used 79 | * 80 | * @return true if relative paths are to be used 81 | */ 82 | public boolean getUseRelativePath(); 83 | 84 | } 85 | -------------------------------------------------------------------------------- /src/weka/core/converters/IncrementalConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * IncremenalConverter.java 18 | * Copyright (C) 2004-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | package weka.core.converters; 22 | 23 | /** 24 | * Marker interface for a loader/saver that can retrieve instances incrementally 25 | * 26 | * @author Mark Hall 27 | * @version $Revision 1.0 $ 28 | */ 29 | public interface IncrementalConverter { 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/weka/core/converters/URLSourcedLoader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * URLSourcedLoader.java 18 | * Copyright (C) 2006-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | package weka.core.converters; 22 | 23 | 24 | /** 25 | * Interface to a loader that can load from a http url 26 | * 27 | * @author Mark Hall 28 | * @version $Revision 1.0 $ 29 | */ 30 | public interface URLSourcedLoader { 31 | 32 | /** 33 | * Set the url to load from 34 | * 35 | * @param url the url to load from 36 | * @exception Exception if the url can't be set. 37 | */ 38 | void setURL(String url) throws Exception; 39 | 40 | /** 41 | * Return the current url 42 | * 43 | * @return the current url 44 | */ 45 | String retrieveURL(); 46 | } 47 | -------------------------------------------------------------------------------- /src/weka/core/json/sym.java: -------------------------------------------------------------------------------- 1 | 2 | //---------------------------------------------------- 3 | // The following code was generated by CUP v0.11a beta 20060608 4 | // Sun Aug 14 10:44:48 NZST 2011 5 | //---------------------------------------------------- 6 | 7 | package weka.core.json; 8 | 9 | /** CUP generated interface containing symbol constants. */ 10 | public interface sym { 11 | /* terminals */ 12 | public static final int LSQUARE = 3; 13 | public static final int INTEGER = 10; 14 | public static final int COLON = 7; 15 | public static final int BOOLEAN = 9; 16 | public static final int NULL = 8; 17 | public static final int RSQUARE = 4; 18 | public static final int STRING = 12; 19 | public static final int EOF = 0; 20 | public static final int DOUBLE = 11; 21 | public static final int error = 1; 22 | public static final int COMMA = 2; 23 | public static final int RCURLY = 6; 24 | public static final int LCURLY = 5; 25 | } 26 | 27 | -------------------------------------------------------------------------------- /src/weka/core/logging/ConsoleLogger.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * ConsoleLogger.java 18 | * Copyright (C) 2008-2012 University of Waikato, Hamilton, New Zealand 19 | */ 20 | 21 | package weka.core.logging; 22 | 23 | import java.util.Date; 24 | 25 | import weka.core.RevisionUtils; 26 | 27 | /** 28 | * A simple logger that outputs the logging information in the console. 29 | * 30 | * @author fracpete (fracpete at waikato dot ac dot nz) 31 | * @version $Revision: 8034 $ 32 | */ 33 | public class ConsoleLogger 34 | extends Logger { 35 | 36 | /** 37 | * Performs the actual logging. 38 | * 39 | * @param level the level of the message 40 | * @param msg the message to log 41 | * @param cls the classname originating the log event 42 | * @param method the method originating the log event 43 | * @param lineno the line number originating the log event 44 | */ 45 | protected void doLog(Level level, String msg, String cls, String method, int lineno) { 46 | System.err.println( 47 | m_DateFormat.format(new Date()) + " " + cls + " " + method + "\n" 48 | + level + ": " + msg); 49 | } 50 | 51 | /** 52 | * Returns the revision string. 53 | * 54 | * @return the revision 55 | */ 56 | public String getRevision() { 57 | return RevisionUtils.extract("$Revision: 8034 $"); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/weka/core/mathematicalexpression/sym.java: -------------------------------------------------------------------------------- 1 | 2 | //---------------------------------------------------- 3 | // The following code was generated by CUP v0.11a beta 20060608 4 | // Mon Apr 26 10:55:03 NZST 2010 5 | //---------------------------------------------------- 6 | 7 | package weka.core.mathematicalexpression; 8 | 9 | /** CUP generated interface containing symbol constants. */ 10 | public interface sym { 11 | /* terminals */ 12 | public static final int TIMES = 7; 13 | public static final int AND = 29; 14 | public static final int IFELSE = 20; 15 | public static final int LT = 23; 16 | public static final int SIN = 13; 17 | public static final int PLUS = 6; 18 | public static final int OR = 30; 19 | public static final int RPAREN = 4; 20 | public static final int COS = 14; 21 | public static final int DIVISION = 8; 22 | public static final int NOT = 28; 23 | public static final int POW = 18; 24 | public static final int SQRT = 10; 25 | public static final int VARIABLE = 33; 26 | public static final int TRUE = 21; 27 | public static final int FLOOR = 17; 28 | public static final int RINT = 16; 29 | public static final int GT = 25; 30 | public static final int CEIL = 19; 31 | public static final int LPAREN = 3; 32 | public static final int LE = 24; 33 | public static final int LOG = 11; 34 | public static final int EXP = 12; 35 | public static final int BOOLEAN = 32; 36 | public static final int COMMA = 2; 37 | public static final int NUMBER = 31; 38 | public static final int EOF = 0; 39 | public static final int ABS = 9; 40 | public static final int GE = 26; 41 | public static final int FALSE = 22; 42 | public static final int MINUS = 5; 43 | public static final int error = 1; 44 | public static final int EQ = 27; 45 | public static final int TAN = 15; 46 | } 47 | 48 | -------------------------------------------------------------------------------- /src/weka/core/pmml/PMMLModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * PMMLModel.java 18 | * Copyright (C) 2008-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.core.pmml; 23 | 24 | import org.w3c.dom.Document; 25 | 26 | import weka.gui.Logger; 27 | 28 | /** 29 | * Interface for all PMML models 30 | * 31 | * @author Mark Hall (mhall{[at]}pentaho{[dot]}com) 32 | * @version $Revision: 8034 $ 33 | */ 34 | public interface PMMLModel { 35 | 36 | /** 37 | * Set the version of the PMML. 38 | * 39 | * @param doc the Document encapsulating the pmml 40 | */ 41 | void setPMMLVersion(Document doc); 42 | 43 | /** 44 | * Get the version of PMML used to encode this model. 45 | * 46 | * @return the version as a String 47 | */ 48 | String getPMMLVersion(); 49 | 50 | /** 51 | * Set the name of the application (if specified) that created this. 52 | * model 53 | * 54 | * @param doc the Document encapsulating the pmml 55 | */ 56 | void setCreatorApplication(Document doc); 57 | 58 | /** 59 | * Get the name of the application that created this model. 60 | * 61 | * @return the name of the creating application or null 62 | * if not specified in the pmml. 63 | */ 64 | String getCreatorApplication(); 65 | 66 | /** 67 | * Get the mining schema. 68 | * 69 | * @return the mining schema 70 | */ 71 | MiningSchema getMiningSchema(); 72 | 73 | /** 74 | * Set a logger to use. 75 | * 76 | * @param log the logger to use 77 | */ 78 | void setLog(Logger log); 79 | 80 | /** 81 | * Get the logger. 82 | * 83 | * @return the logger (or null if none is being used) 84 | */ 85 | Logger getLog(); 86 | } 87 | -------------------------------------------------------------------------------- /src/weka/core/pmml/PMMLUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * PMMLUtils.java 18 | * Copyright (C) 2008-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.core.pmml; 23 | 24 | /** 25 | * Utility routines. 26 | * 27 | * @author Mark Hall (mhall{[at]}pentaho{[dot]}com) 28 | * @version $Revision: 8034 $ 29 | */ 30 | public class PMMLUtils { 31 | 32 | /** 33 | * Utility method to left or right pad strings with arbitrary characters. 34 | * 35 | * @param source the source string 36 | * @param padChar the character to pad with 37 | * @param length the length of the resulting string 38 | * @param leftPad pad to the left instead of the right 39 | * @return a padded string 40 | */ 41 | public static String pad(String source, String padChar, 42 | int length, boolean leftPad) { 43 | StringBuffer temp = new StringBuffer(); 44 | 45 | if (leftPad) { 46 | for (int i = 0; i< length; i++) { 47 | temp.append(padChar); 48 | } 49 | temp.append(source); 50 | } else { 51 | temp.append(source); 52 | for (int i = 0; i< length; i++) { 53 | temp.append(padChar); 54 | } 55 | } 56 | return temp.toString(); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/weka/core/scripting/JythonObject.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * JythonObject.java 18 | * Copyright (C) 2007-2012 University of Waikato, Hamilton, New Zealand 19 | */ 20 | 21 | package weka.core.scripting; 22 | 23 | 24 | /** 25 | * An indicator interface for Jython objects. 26 | * 27 | * @author fracpete (fracpete at waikato dot ac dot nz) 28 | * @version $Revision: 8034 $ 29 | */ 30 | public interface JythonObject { 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/weka/core/scripting/JythonSerializableObject.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * JythonSerializableObject.java 18 | * Copyright (C) 2007-2012 University of Waikato, Hamilton, New Zealand 19 | */ 20 | 21 | package weka.core.scripting; 22 | 23 | 24 | import java.io.Serializable; 25 | 26 | 27 | /** 28 | * An indicator interface for serializable Jython objects. 29 | * 30 | * @author fracpete (fracpete at waikato dot ac dot nz) 31 | * @version $Revision: 8034 $ 32 | */ 33 | public interface JythonSerializableObject extends Serializable, JythonObject { 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/weka/core/stemmers/NullStemmer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * NullStemmer.java 18 | * Copyright (C) 2005-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.core.stemmers; 23 | 24 | import weka.core.RevisionUtils; 25 | 26 | /** 27 | 28 | * A dummy stemmer that performs no stemming at all. 29 | *

30 | 31 | * 32 | * @author FracPete (fracpete at waikato dot ac dot nz) 33 | * @version $Revision: 8034 $ 34 | */ 35 | public class NullStemmer 36 | implements Stemmer { 37 | 38 | /** for serialization */ 39 | static final long serialVersionUID = -3671261636532625496L; 40 | 41 | /** 42 | * Returns a string describing the stemmer 43 | * @return a description suitable for 44 | * displaying in the explorer/experimenter gui 45 | */ 46 | public String globalInfo() { 47 | return 48 | "A dummy stemmer that performs no stemming at all."; 49 | } 50 | 51 | /** 52 | * Returns the word as it is. 53 | * 54 | * @param word the unstemmed word 55 | * @return the unstemmed word, again 56 | */ 57 | public String stem(String word) { 58 | return new String(word); 59 | } 60 | 61 | /** 62 | * returns a string representation of the stemmer 63 | * 64 | * @return a string representation of the stemmer 65 | */ 66 | public String toString() { 67 | return getClass().getName(); 68 | } 69 | 70 | /** 71 | * Returns the revision string. 72 | * 73 | * @return the revision 74 | */ 75 | public String getRevision() { 76 | return RevisionUtils.extract("$Revision: 8034 $"); 77 | } 78 | 79 | /** 80 | * Runs the stemmer with the given options 81 | * 82 | * @param args the options 83 | */ 84 | public static void main(String[] args) { 85 | try { 86 | Stemming.useStemmer(new NullStemmer(), args); 87 | } 88 | catch (Exception e) { 89 | e.printStackTrace(); 90 | } 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /src/weka/core/stemmers/Stemmer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * Stemmer.java 18 | * Copyright (C) 2005-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.core.stemmers; 23 | 24 | import java.io.Serializable; 25 | 26 | import weka.core.RevisionHandler; 27 | 28 | /** 29 | * Interface for all stemming algorithms. 30 | * 31 | * @author FracPete (fracpete at waikato dot ac dot nz) 32 | * @version $Revision: 8034 $ 33 | */ 34 | public interface Stemmer 35 | extends Serializable, RevisionHandler { 36 | 37 | /** 38 | * Stems the given word and returns the stemmed version 39 | * 40 | * @param word the unstemmed word 41 | * @return the stemmed word 42 | */ 43 | public String stem(String word); 44 | } 45 | -------------------------------------------------------------------------------- /src/weka/estimators/ConditionalEstimator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * ConditionalEstimator.java 18 | * Copyright (C) 1999-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.estimators; 23 | 24 | import weka.core.RevisionHandler; 25 | 26 | 27 | /** 28 | * Interface for conditional probability estimators. Example code:

29 | * 30 | *

31 |  *   NNConditionalEstimator newEst = new NNConditionalEstimator();
32 |  *
33 |  *   // Create 50 random points and add them
34 |  *   Random r = new Random(seed);
35 |  *   for(int i = 0; i < 50; i++) {
36 |  *     int x = Math.abs(r.nextInt() % 100);
37 |  *     int y = Math.abs(r.nextInt() % 100);
38 |  *     System.out.println("# " + x + "  " + y);
39 |  *     newEst.addValue(x, y, 1);
40 |  *   }
41 |  *
42 |  *   // Pick a random conditional value
43 |  *   int cond = Math.abs(r.nextInt() % 100);
44 |  *   System.out.println("## Conditional = " + cond);
45 |  *
46 |  *   // Print the probabilities conditional on that value
47 |  *   Estimator result = newEst.getEstimator(cond);
48 |  *   for(int i = 0; i <= 100; i+= 5) {
49 |  *     System.out.println(" " + i + "  " + result.getProbability(i));
50 |  *   }
51 |  * 
52 | * 53 | * @author Len Trigg (trigg@cs.waikato.ac.nz) 54 | * @version $Revision: 8034 $ 55 | */ 56 | public interface ConditionalEstimator extends RevisionHandler { 57 | 58 | /** 59 | * Add a new data value to the current estimator. 60 | * 61 | * @param data the new data value 62 | * @param given the new value that data is conditional upon 63 | * @param weight the weight assigned to the data value 64 | */ 65 | void addValue(double data, double given, double weight); 66 | 67 | /** 68 | * Get a probability estimator for a value 69 | * 70 | * @param given the new value that data is conditional upon 71 | * @return the estimator for the supplied value given the condition 72 | */ 73 | Estimator getEstimator(double given); 74 | 75 | /** 76 | * Get a probability for a value conditional on another value 77 | * 78 | * @param data the value to estimate the probability of 79 | * @param given the new value that data is conditional upon 80 | * @return the estimator for the supplied value given the condition 81 | */ 82 | double getProbability(double data, double given); 83 | 84 | } 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /src/weka/estimators/IncrementalEstimator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * IncrementalEstimator.java 18 | * Copyright (C) 2004-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.estimators; 23 | 24 | 25 | /** 26 | * Interface for an incremental probability estimators.

27 | * 28 | * @author Gabi Schmidberger (gabi@cs.waikato.ac.nz) 29 | * @version $Revision: 8034 $ 30 | */ 31 | public interface IncrementalEstimator { 32 | 33 | /** 34 | * Add one value to the current estimator. 35 | * 36 | * @param data the new data value 37 | * @param weight the weight assigned to the data value 38 | */ 39 | void addValue(double data, double weight); 40 | 41 | } 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /src/weka/estimators/MultivariateEstimator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * MultivariateEstimator.java 18 | * Copyright (C) 2013 University of Waikato 19 | */ 20 | 21 | package weka.estimators; 22 | 23 | /** 24 | * Interface to Multivariate Distribution Estimation 25 | * 26 | * @author Uday Kamath, PhD candidate George Mason University 27 | * @version $Revision: 9460 $ 28 | */ 29 | public interface MultivariateEstimator { 30 | 31 | /** 32 | * Fits the value to the density estimator. 33 | * 34 | * @param value the value to add 35 | * @param weight the weight of the value 36 | */ 37 | void estimate(double[][] value, double[] weight); 38 | 39 | /** 40 | * Returns the natural logarithm of the density estimate at the given point. 41 | * 42 | * @param value the value at which to evaluate 43 | * @return the natural logarithm of the density estimate at the given value 44 | */ 45 | double logDensity(double[] value); 46 | 47 | /** 48 | * Returns the probability density estimate at the given point. 49 | * 50 | * @param value the value at which to evaluate 51 | * @return the the density estimate at the given value 52 | */ 53 | double getProbability(double[] value); 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/weka/estimators/UnivariateDensityEstimator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * UnivariateDensityEstimator.java 18 | * Copyright (C) 2009-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.estimators; 23 | 24 | /** 25 | * Interface that can be implemented by simple weighted univariate 26 | * density estimators. 27 | * 28 | * @author Eibe Frank (eibe@cs.waikato.ac.nz) 29 | * @version $Revision: 8034 $ 30 | */ 31 | public interface UnivariateDensityEstimator { 32 | 33 | /** 34 | * Adds a value to the density estimator. 35 | * 36 | * @param value the value to add 37 | * @param weight the weight of the value 38 | */ 39 | void addValue(double value, double weight); 40 | 41 | /** 42 | * Returns the natural logarithm of the density estimate at the given 43 | * point. 44 | * 45 | * @param value the value at which to evaluate 46 | * @return the natural logarithm of the density estimate at the given 47 | * value 48 | */ 49 | double logDensity(double value); 50 | } -------------------------------------------------------------------------------- /src/weka/estimators/UnivariateIntervalEstimator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * UnivariateIntervalEstimator.java 18 | * Copyright (C) 2009-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.estimators; 23 | 24 | /** 25 | * Interface that can be implemented by simple weighted univariate 26 | * interval estimators. 27 | * 28 | * @author Eibe Frank (eibe@cs.waikato.ac.nz) 29 | * @version $Revision: 8034 $ 30 | */ 31 | public interface UnivariateIntervalEstimator { 32 | 33 | /** 34 | * Adds a value to the interval estimator. 35 | * 36 | * @param value the value to add 37 | * @param weight the weight of the value 38 | */ 39 | void addValue(double value, double weight); 40 | 41 | /** 42 | * Returns the intervals at the given confidence value. Each row has 43 | * one interval. The first element in each row is the lower bound, 44 | * the second element the upper one. 45 | * 46 | * @param confidenceValue the value at which to evaluate 47 | * @return the interval 48 | */ 49 | double[][] predictIntervals(double confidenceValue); 50 | } -------------------------------------------------------------------------------- /src/weka/estimators/UnivariateQuantileEstimator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * UnivariateQuantileEstimator.java 18 | * Copyright (C) 2009-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.estimators; 23 | 24 | /** 25 | * Interface that can be implemented by simple weighted univariate 26 | * quantile estimators. 27 | * 28 | * @author Eibe Frank (eibe@cs.waikato.ac.nz) 29 | * @version $Revision: 8034 $ 30 | */ 31 | public interface UnivariateQuantileEstimator { 32 | 33 | /** 34 | * Adds a value to the interval estimator. 35 | * 36 | * @param value the value to add 37 | * @param weight the weight of the value 38 | */ 39 | void addValue(double value, double weight); 40 | 41 | /** 42 | * Returns the quantile for the given percentage 43 | * 44 | * @param value the value at which to evaluate 45 | * @return the quantile 46 | */ 47 | double predictQuantile(double quantile); 48 | } -------------------------------------------------------------------------------- /src/weka/experiment/Compute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | 15 | 16 | 17 | * Compute.java 18 | * Copyright (C) 2000-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | 21 | 22 | package weka.experiment; 23 | 24 | import java.rmi.Remote; 25 | import java.rmi.RemoteException; 26 | 27 | *//** 28 | * Interface to something that can accept remote connections and execute 29 | * a task. 30 | * 31 | * @author Mark Hall (mhall@cs.waikato.ac.nz) 32 | * @version $Revision: 8034 $ 33 | */ 34 | /* 35 | public interface Compute extends Remote { 36 | 37 | *//** 38 | * Execute a task 39 | * @param t Task to be executed 40 | * @exception RemoteException if something goes wrong. 41 | * @return a unique ID for the task 42 | */ 43 | /* 44 | Object executeTask(Task t) throws RemoteException; 45 | 46 | *//** 47 | * Check on the status of a Task 48 | * 49 | * @param taskId the ID for the Task to be checked 50 | * @return the status of the Task 51 | * @exception Exception if an error occurs 52 | */ 53 | /* 54 | Object checkStatus(Object taskId) throws Exception; 55 | } 56 | 57 | */ -------------------------------------------------------------------------------- /src/weka/experiment/InstanceQueryAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * InstanceQueryAdapter.java 18 | * Copyright (C) 2011-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.experiment; 23 | 24 | /** 25 | * An interface implemented by InstanceQuery and any user class that is 26 | * to be passed as the first argument to 27 | * InstanceQuery.retrieveInstances(InstanceQueryAdapter, ResultSet). 28 | * 29 | * @author Wes Munsil (wes_munsil@cytoanalytics.com) 30 | * @version $Revision: 8034 $ 31 | */ 32 | public interface InstanceQueryAdapter 33 | { 34 | /** 35 | * returns key column headings in their original case. Used for 36 | * those databases that create uppercase column names. 37 | * 38 | * @param columnName the column to retrieve the original case for 39 | * @return the original case 40 | */ 41 | public String attributeCaseFix(String columnName); 42 | 43 | /** 44 | * Gets whether there should be printed some debugging output to stderr or not. 45 | * 46 | * @return true if output should be printed 47 | */ 48 | public boolean getDebug(); 49 | 50 | /** 51 | * Gets whether data is to be returned as a set of sparse instances 52 | * @return true if data is to be encoded as sparse instances 53 | */ 54 | public boolean getSparseData(); 55 | 56 | /** 57 | * translates the column data type string to an integer value that indicates 58 | * which data type / get()-Method to use in order to retrieve values from the 59 | * database (see DatabaseUtils.Properties, InstanceQuery()). Blanks in the type 60 | * are replaced with underscores "_", since Java property names can't contain blanks. 61 | * 62 | * @param type the column type as retrieved with 63 | * java.sql.MetaData.getColumnTypeName(int) 64 | * @return an integer value that indicates 65 | * which data type / get()-Method to use in order to 66 | * retrieve values from the 67 | */ 68 | public int translateDBColumnType(String type); 69 | } 70 | -------------------------------------------------------------------------------- /src/weka/experiment/RemoteExperimentEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * RemoteExperimentEvent.java 18 | * Copyright (C) 2000-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.experiment; 23 | 24 | import java.io.Serializable; 25 | 26 | /** 27 | * Class encapsulating information on progress of a remote experiment 28 | * 29 | * @author Mark Hall (mhall@cs.waikato.ac.nz) 30 | * @version $Revision: 8034 $ 31 | */ 32 | public class RemoteExperimentEvent 33 | implements Serializable { 34 | 35 | /** for serialization */ 36 | private static final long serialVersionUID = 7000867987391866451L; 37 | 38 | /** A status type message */ 39 | public boolean m_statusMessage; 40 | 41 | /** A log type message */ 42 | public boolean m_logMessage; 43 | 44 | /** The message */ 45 | public String m_messageString; 46 | 47 | /** True if a remote experiment has finished */ 48 | public boolean m_experimentFinished; 49 | 50 | /** 51 | * Constructor 52 | * @param status true for status type messages 53 | * @param log true for log type messages 54 | * @param finished true if experiment has finished 55 | * @param message the message 56 | */ 57 | public RemoteExperimentEvent(boolean status, boolean log, boolean finished, 58 | String message) { 59 | m_statusMessage = status; 60 | m_logMessage = log; 61 | m_experimentFinished = finished; 62 | m_messageString = message; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/weka/experiment/RemoteExperimentListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * RemoteExperimentListener.java 18 | * Copyright (C) 2000-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | 23 | package weka.experiment; 24 | 25 | /** 26 | * Interface for classes that want to listen for updates on RemoteExperiment 27 | * progress 28 | * 29 | * @author Mark Hall (mhall@cs.waikato.ac.nz) 30 | * @version $Revision: 8034 $ 31 | */ 32 | public interface RemoteExperimentListener { 33 | 34 | /** 35 | * Called when progress has been made in a remote experiment 36 | * @param e the event encapsulating what happened 37 | */ 38 | void remoteExperimentStatus(RemoteExperimentEvent e); 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/weka/experiment/Task.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * Task.java 18 | * Copyright (C) 2000-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | 23 | package weka.experiment; 24 | 25 | import java.io.Serializable; 26 | 27 | /** 28 | * Interface to something that can be remotely executed as a task. 29 | * 30 | * @author Mark Hall (mhall@cs.waikato.ac.nz) 31 | * @version $Revision: 8034 $ 32 | */ 33 | public interface Task extends Serializable { 34 | 35 | /** 36 | * Execute this task. 37 | */ 38 | void execute(); 39 | 40 | /** 41 | * Clients should be able to call this method at any time to obtain 42 | * information on a current task. 43 | * 44 | * @return a TaskStatusInfo object holding info and result (if available) for 45 | * this task 46 | */ 47 | TaskStatusInfo getTaskStatus(); 48 | } 49 | -------------------------------------------------------------------------------- /src/weka/filters/Sourcable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * Sourcable.java 18 | * Copyright (C) 2007-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.filters; 23 | 24 | import weka.core.Instances; 25 | 26 | /** 27 | * Interface for filters that can be converted to Java source. 28 | * 29 | * @author FracPete (fracpete at waikato dot ac dot nz) 30 | * @version $Revision: 8034 $ 31 | */ 32 | public interface Sourcable { 33 | 34 | /** 35 | * Returns a string that describes the filter as source. The 36 | * filter will be contained in a class with the given name (there may 37 | * be auxiliary classes), 38 | * and will contain two methods with these signatures: 39 | *


40 |    * // converts one row
41 |    * public static Object[] filter(Object[] i);
42 |    * // converts a full dataset (first dimension is row index)
43 |    * public static Object[][] filter(Object[][] i);
44 |    * 
45 | * where the array i contains elements that are either 46 | * Double, String, with missing values represented as null. The generated 47 | * code is public domain and comes with no warranty. 48 | * 49 | * @param className the name that should be given to the source class. 50 | * @param data the dataset used for initializing the filter 51 | * @return the object source described by a string 52 | * @throws Exception if the source can't be computed 53 | */ 54 | public String toSource(String className, Instances data) throws Exception; 55 | } 56 | -------------------------------------------------------------------------------- /src/weka/filters/StreamableFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * StreamableFilter.java 18 | * Copyright (C) 2002-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.filters; 23 | 24 | /** 25 | * Interface for filters can work with a stream of instances. 26 | * 27 | * @author Richard Kirkby (rkirkby@cs.waikato.ac.nz) 28 | * @version $Revision: 8034 $ 29 | */ 30 | 31 | public interface StreamableFilter { 32 | 33 | /** 34 | * Empty interface, to be used as a hint of the filters behaviour. 35 | */ 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/weka/filters/SupervisedFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * SupervisedFilter.java 18 | * Copyright (C) 2002-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.filters; 23 | 24 | /** 25 | * Interface for filters that make use of a class attribute. 26 | * 27 | * @author Richard Kirkby (rkirkby@cs.waikato.ac.nz) 28 | * @version $Revision: 8034 $ 29 | */ 30 | 31 | public interface SupervisedFilter { 32 | 33 | /** 34 | * Empty interface, to be used as a hint of the filters behaviour. 35 | */ 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/weka/filters/UnsupervisedFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * UnsupervisedFilter.java 18 | * Copyright (C) 2002-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | package weka.filters; 23 | 24 | /** 25 | * Interface for filters that do not need a class attribute. 26 | * 27 | * @author Richard Kirkby (rkirkby@cs.waikato.ac.nz) 28 | * @version $Revision: 8034 $ 29 | */ 30 | 31 | public interface UnsupervisedFilter { 32 | 33 | /** 34 | * Empty interface, to be used as a hint of the filters behaviour. 35 | */ 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/weka/filters/unsupervised/attribute/AddUserFieldsBeanInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | 15 | 16 | 17 | * AddUserFieldsBeanInfo.java 18 | * Copyright (C) 2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | 21 | 22 | package weka.filters.unsupervised.attribute; 23 | 24 | import java.beans.BeanDescriptor; 25 | import java.beans.SimpleBeanInfo; 26 | 27 | *//** 28 | * Bean info class for the AddUserFields filter. 29 | * 30 | * @author Mark Hall (mhall{[at]}pentaho{[dot]}com) 31 | * @version $Revision: 9002 $ 32 | */ 33 | /* 34 | public class AddUserFieldsBeanInfo extends SimpleBeanInfo { 35 | 36 | *//** 37 | * Get the bean descriptor for this bean 38 | * 39 | * @return a BeanDescriptor value 40 | */ 41 | /* 42 | @Override 43 | public BeanDescriptor getBeanDescriptor() { 44 | return new BeanDescriptor(null, null); 45 | // weka.filters.unsupervised.attribute.AddUserFields.class, 46 | // weka.gui.filters.AddUserFieldsCustomizer.class; 47 | } 48 | } 49 | */ -------------------------------------------------------------------------------- /src/weka/filters/unsupervised/instance/subsetbyexpression/sym.java: -------------------------------------------------------------------------------- 1 | 2 | //---------------------------------------------------- 3 | // The following code was generated by CUP v0.11a beta 20060608 4 | // Wed Jun 26 14:23:38 NZST 2013 5 | //---------------------------------------------------- 6 | 7 | package weka.filters.unsupervised.instance.subsetbyexpression; 8 | 9 | /** CUP generated interface containing symbol constants. */ 10 | public interface sym { 11 | /* terminals */ 12 | public static final int POW = 19; 13 | public static final int SQRT = 11; 14 | public static final int ABS = 10; 15 | public static final int GE = 26; 16 | public static final int ISMISSING = 5; 17 | public static final int LPAREN = 3; 18 | public static final int TAN = 16; 19 | public static final int MINUS = 6; 20 | public static final int FLOOR = 18; 21 | public static final int RPAREN = 4; 22 | public static final int NOT = 28; 23 | public static final int IS = 31; 24 | public static final int AND = 29; 25 | public static final int LT = 23; 26 | public static final int OR = 30; 27 | public static final int COMMA = 2; 28 | public static final int PLUS = 7; 29 | public static final int EXP = 13; 30 | public static final int LE = 24; 31 | public static final int EOF = 0; 32 | public static final int BOOLEAN = 33; 33 | public static final int TRUE = 21; 34 | public static final int error = 1; 35 | public static final int NUMBER = 32; 36 | public static final int COS = 15; 37 | public static final int EQ = 27; 38 | public static final int LOG = 12; 39 | public static final int TIMES = 8; 40 | public static final int SIN = 14; 41 | public static final int STRING = 35; 42 | public static final int RINT = 17; 43 | public static final int CEIL = 20; 44 | public static final int FALSE = 22; 45 | public static final int DIVISION = 9; 46 | public static final int ATTRIBUTE = 34; 47 | public static final int GT = 25; 48 | } 49 | 50 | -------------------------------------------------------------------------------- /src/weka/gui/Logger.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | /* 17 | * Logger.java 18 | * Copyright (C) 1999-2012 University of Waikato, Hamilton, New Zealand 19 | * 20 | */ 21 | 22 | 23 | package weka.gui; 24 | 25 | /** 26 | * Interface for objects that display log (permanent historical) and 27 | * status (transient) messages. 28 | * 29 | * @author Len Trigg (trigg@cs.waikato.ac.nz) 30 | * @version $Revision: 8034 $ 31 | */ 32 | public interface Logger { 33 | 34 | /** 35 | * Sends the supplied message to the log area. These message will typically 36 | * have the current timestamp prepended, and be viewable as a history. 37 | * 38 | * @param message the log message 39 | */ 40 | void logMessage(String message); 41 | 42 | /** 43 | * Sends the supplied message to the status line. These messages are 44 | * typically one-line status messages to inform the user of progress 45 | * during processing (i.e. it doesn't matter if the user doesn't happen 46 | * to look at each message) 47 | * 48 | * @param message the status message. 49 | */ 50 | void statusMessage(String message); 51 | 52 | } 53 | --------------------------------------------------------------------------------