ModelFox (modelfox v0.8.0) View Source

This is the main module in the modelfox package.

Link to this section Summary

Types

This identifies the type of a feature contribution.

This is the input type of ModelFox.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 ModelFox.predict.

Functions

Add a prediction event to the queue. Remember to call ModelFox.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 ModelFox.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 .modelfox loaded into memory. Otherwise, use ModelFox.load_model_from_path, which is faster because it memory maps the file.

Load a model from a .modelfox file at path.

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

Send a true value event to the app. If you want to batch events, you can use ModelFox.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 ModelFox.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 ModelFox.predict.

Specs

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

Link to this section Functions

Link to this function

enqueue_log_prediction(model, args)

View Source

Specs

Add a prediction event to the queue. Remember to call ModelFox.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

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

Specs

flush_log_queue(ModelFox.Model.t()) :: ModelFox.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(), ModelFox.LoadModelOptions | nil) ::
  ModelFox.Model.t()

Load a model from a binary instead of a file. You should use this only if you already have a .modelfox loaded into memory. Otherwise, use ModelFox.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(), ModelFox.LoadModelOptions | nil) ::
  ModelFox.Model.t()

Load a model from a .modelfox file at path.

Link to this function

log_prediction(model, args)

View Source

Specs

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

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

Link to this function

log_true_value(model, args)

View Source

Specs

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

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

Specs

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

Retrieve the model's id.

Link to this function

predict(model, input, options \\ nil)

View Source

Specs

Make a prediction!