Tangram (tangram v0.7.0) View Source

This is the main module in the tangram package.

Link to this section Summary

Types

This identifies the type of a feature contribution.

This is the input type of Tangram.predict. A predict input is a map from atoms or strings to strings or floats. The keys should match the columns in the CSV file you trained your model with.

This is the return type of Tangram.predict.

Functions

Add a prediction event to the queue. Remember to call Tangram.flush_log_queue at a later point to send the event to the app.

Add a true value event to the queue. Remember to call Tangram.flush_log_queue at a later point to send the event to the app.

Send all events in the queue to the app.

Load a model from a binary instead of a file. You should use this only if you already have a .tangram loaded into memory. Otherwise, use Tangram.load_model_from_path, which is faster because it memory maps the file.

Load a model from a .tangram file at path.

Send a prediction event to the app. If you want to batch events, you can use Tangram.enqueue_log_prediction instead.

Send a true value event to the app. If you want to batch events, you can use Tangram.enqueue_log_true_value instead.

Retrieve the model's id.

Link to this section Types

Specs

event() :: PredictionEvent.t() | TrueValueEvent.t()
Link to this type

feature_contribution_entry()

View Source

Specs

feature_contribution_entry() ::
  {:identity, IdentityFeatureContribution.t()}
  | {:normalized, NormalizedFeatureContribution.t()}
  | {:one_hot_encoded, OneHotEncodedFeatureContribution.t()}
  | {:bag_of_words, BagOfWordsFeatureContribution.t()}
  | {:bag_of_words_cosine_similarity,
     BagOfWordsCosineSimilarityFeatureContribution.t()}
  | {:word_embedding, WordEmbeddingFeatureContribution.t()}

This identifies the type of a feature contribution.

Specs

predict_input() :: %{required(atom() | String.t()) => String.t() | float()}

This is the input type of Tangram.predict. A predict input is a map from atoms or strings to strings or floats. The keys should match the columns in the CSV file you trained your model with.

Specs

predict_output() ::
  {:regression, RegressionPredictOutput.t()}
  | {:binary_classification, BinaryClassificationPredictOutput.t()}
  | {:multiclass_classification, MulticlassClassificationPredictOutput.t()}

This is the return type of Tangram.predict.

Specs

true_value() :: String.t() | float()

Link to this section Functions

Link to this function

enqueue_log_prediction(model, args)

View Source

Specs

enqueue_log_prediction(Tangram.Model.t(), Tangram.LogPredictionArgs.t()) ::
  Tangram.Model.t()

Add a prediction event to the queue. Remember to call Tangram.flush_log_queue at a later point to send the event to the app.

Link to this function

enqueue_log_true_value(model, args)

View Source

Specs

enqueue_log_true_value(Tangram.Model.t(), Tangram.LogTrueValueArgs.t()) ::
  Tangram.Model.t()

Add a true value event to the queue. Remember to call Tangram.flush_log_queue at a later point to send the event to the app.

Specs

flush_log_queue(Tangram.Model.t()) :: Tangram.Model.t()

Send all events in the queue to the app.

Link to this function

load_model_from_binary(binary, options \\ nil)

View Source

Specs

load_model_from_binary(String.t(), Tangram.LoadModelOptions | nil) ::
  Tangram.Model.t()

Load a model from a binary instead of a file. You should use this only if you already have a .tangram loaded into memory. Otherwise, use Tangram.load_model_from_path, which is faster because it memory maps the file.

Link to this function

load_model_from_path(path, options \\ nil)

View Source

Specs

load_model_from_path(String.t(), Tangram.LoadModelOptions | nil) ::
  Tangram.Model.t()

Load a model from a .tangram file at path.

Link to this function

log_prediction(model, args)

View Source

Specs

log_prediction(Tangram.Model.t(), Tangram.LogPredictionArgs.t()) ::
  {:ok, any()} | {:error, any()}

Send a prediction event to the app. If you want to batch events, you can use Tangram.enqueue_log_prediction instead.

Link to this function

log_true_value(model, args)

View Source

Specs

log_true_value(Tangram.Model.t(), Tangram.LogTrueValueArgs.t()) ::
  {:ok, any()} | {:error, any()}

Send a true value event to the app. If you want to batch events, you can use Tangram.enqueue_log_true_value instead.

Specs

model_id(Tangram.Model.t()) :: String.t()

Retrieve the model's id.

Link to this function

predict(model, input, options \\ nil)

View Source

Specs

Make a prediction!