Decidex v0.0.2 Decidex View Source

A decision tree library for small datasets.

Link to this section Summary

Types

A feature - a parameter of the data.

A value of some feature.

A predicted or actual outcome for an example feature vector features.

t()

A decision tree.

A training dataset.

Functions

An example decision tree.

An example training dataset.

Learns a decision tree from training_data.

Predicts the outcome for features feature vector using decision_tree.

Link to this section Types

Link to this type

feature() View Source
feature() :: any()

A feature - a parameter of the data.

Link to this type

feature_value() View Source
feature_value() :: any()

A value of some feature.

Link to this type

features() View Source
features() :: %{optional(feature()) => feature_value()}

A feature vector.

Represented as a map from feature to corresponding feature_value.

Link to this type

outcome() View Source
outcome() :: any()

A predicted or actual outcome for an example feature vector features.

Link to this type

t() View Source
t() ::
  {feature(), %{optional(feature_value()) => t() | outcome()}} | outcome()

A decision tree.

Represented as a recursive data structure, each node of which can either be an outcome, or a tuple of a feature and a map from all possible feature_values to subtrees or outcomes.

Link to this type

training_data() View Source
training_data() :: [{features(), outcome()}]

A training dataset.

Represented as a list of tuples of features (feature vectors) and outcomes.

Link to this section Functions

Link to this function

example() View Source
example() :: t()

An example decision tree.

This is a slightly modified example from these slides.

Link to this function

example_training_data() View Source
example_training_data() :: training_data()

An example training dataset.

This is a slightly modified example from these slides.

Link to this function

learn(training_data, opts \\ []) View Source
learn(training_data(), opts :: Keyword.t()) :: t()

Learns a decision tree from training_data.

You can switch learning algorithm using opts parameter :algorithm. By default it's set to Decidex.LearningAlgorithms.ID3.

Returns the learned decision tree.

Link to this function

predict(decision_tree, features) View Source
predict(decision_tree :: t(), features :: features()) :: outcome()

Predicts the outcome for features feature vector using decision_tree.

Returns an outcome.