README.md

# Tangram for Elixir

- [Watch the Video](https://www.tangram.xyz)
- [Read the Docs](https://www.tangram.xyz/docs)

The Tangram Elixir library makes it easy to make predictions with your Tangram machine learning model from Elixir.

## Usage

```elixir
# mix.exs
def deps do
  [
    {:tangram, "~> 0.1.0"}
  ]
end
```

```elixir
model = Tangram.load_model_from_file("heart_disease.tangram")

input = %{
  "age" => 63.0,
  "gender" => "male",
  # ...
}

output = Tangram.predict(model, input)
```

For more information, [read the docs](https://www.tangram.xyz/docs).

## Platform Support

Tangram for Elixir is currently supported on Linux, macOS, and Windows with AMD64 CPUs. Are you interested in another platform? [Open an issue](https://github.com/tangramxyz/tangram/issues/new) or send us an email at [help@tangram.xyz](mailto:help@tangram.xyz).

## Examples

This folder contains two examples, [examples/basic.exs]([examples/basic.exs]) and [examples/advanced.exs](examples/advanced.exs).

### Basic

This example demonstrates loading a model from a `.tangram` file and making a prediction.

To run the example:

```
$ mix run examples/basic.exs
```

### Advanced

This example demonstrates logging predictions and true values to the Tangram reporting and monitoring web app. Before running the example, run `tangram app` to start the app running locally, open `http://localhost:8080` in your browser, and upload the file `examples/heart_disease.tangram` to it.

Then you can run the example:

```
$ TANGRAM_URL=http://localhost:8080 mix run examples/advanced.exs
```

Now if you refresh the production stats or production metrics tabs for the model you uploaded, you should see predictions and true values being reported.

For more information on reporting and monitoring, [read the docs](https://www.tangram.xyz/docs).

### Notes

* On Alpine Linux, Tangram for Elixir requires the `gcompat` and `libgcc` libraries to be installed. You can run `apk add gcompat libgcc` to install them.