# PostgreSQL (Beta)

### Deployments

We also offer the ability to *deploy* models based on your PostgreSQL datasets. Deployments allow you to make predictions on your PostgreSQL data based on a trained model.

*PostgreSQL deployments are currently only supported for data imported from PostgreSQL.*

To get started with these, first import train a model on your PostgreSQL data:

<figure><img src="https://71333621-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MUiovvmaDi_ad2DYdZ4%2Fuploads%2Fx1k2AL89LEWJRxyADp5g%2Fimage.png?alt=media&#x26;token=e8a47acb-280d-43e6-b275-b47e1baa5ac5" alt=""><figcaption></figcaption></figure>

Then, select the PostgreSQL option on the Deploy tab:

<figure><img src="https://71333621-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MUiovvmaDi_ad2DYdZ4%2Fuploads%2FEwzWeEyMWvV3mmkAs81q%2Fimage%20(73).webp?alt=media&#x26;token=eabc03d8-1fe7-4cca-93d0-25b312b52838" alt=""><figcaption></figcaption></figure>

Select Prediction Data and enter the Schema name and Table name.

<figure><img src="https://71333621-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MUiovvmaDi_ad2DYdZ4%2Fuploads%2FZhE0g3CzDkgQ8Twv1HyC%2Fimage%20(76).webp?alt=media&#x26;token=f1bd7271-cb6a-497a-a7ba-4bc36ef482a4" alt="" width="542"><figcaption></figcaption></figure>

Click "Verify Table" to validate that we can connect to the table.

<figure><img src="https://71333621-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MUiovvmaDi_ad2DYdZ4%2Fuploads%2FEP7UbU2jJXk7uQfUkPhE%2Fimage.png?alt=media&#x26;token=901786c7-a0fe-44c8-90d5-79e4a67b4e06" alt="" width="542"><figcaption></figcaption></figure>

Once the table is validated, deployment options will appear.

<figure><img src="https://71333621-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MUiovvmaDi_ad2DYdZ4%2Fuploads%2FUtGU2gmZ28lZKzOItAoH%2Fimage.png?alt=media&#x26;token=73650c1b-2a25-4663-939e-802f1b04d00b" alt="" width="539"><figcaption></figcaption></figure>

These options allow you to:

* **Scheduler:** Select how often we should run predictions on your provided table.
* **Run on Deploy:** Select whether you want us to run predictions whenever this job is created, as opposed to only on a scheduled basis.
* **Map Fields:** Allows you to map the fields from your trained model to the fields they should correspond to in this table, if they differ.
* **Apply Data Prep:** Whether we should transform the data with any Data Prep steps you specified in the Prepare tab.

Once you've selected your options, hit "Show Preview" for us to run some sample predictions.

<figure><img src="https://71333621-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MUiovvmaDi_ad2DYdZ4%2Fuploads%2Fb8gXEWA3pgPv9Jc2clG8%2Fimage.png?alt=media&#x26;token=de657da5-d828-4e11-8d6c-f6be41856f54" alt=""><figcaption></figcaption></figure>

Depending on the size of your table, this operation may be long-running.

Once complete, a preview table will be rendered with additional columns containing our predictions.

<figure><img src="https://71333621-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MUiovvmaDi_ad2DYdZ4%2Fuploads%2FxVKyLXDT5HafECTfyPtE%2Fimage.png?alt=media&#x26;token=2f212bd3-873b-40ab-9f94-9a71c540f706" alt=""><figcaption></figcaption></figure>

For classification models, these will be a column for the probability of this row being each category, as well as a category for the Unix Timestamp at which we made the prediction.

To actually deploy this model so it will make scheduled predictions, hit the "Deploy" button in the top-right:

<figure><img src="https://71333621-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MUiovvmaDi_ad2DYdZ4%2Fuploads%2FeEexODA8WD0WaFILUmF7%2Fimage.png?alt=media&#x26;token=942fc772-63fe-42ee-bb5c-250894c75ca6" alt=""><figcaption></figcaption></figure>

**We will push this new predictions table to a table that's named the same as the input table, but with `_akkio_predictions` added to the end.**

Once we've deployed this model, you'll get a notification like this.

<figure><img src="https://71333621-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MUiovvmaDi_ad2DYdZ4%2Fuploads%2FKGbM7hfB7tUIwactQ0Oc%2Fimage.png?alt=media&#x26;token=e23830ba-d2f6-478a-996c-1cf665d7725d" alt=""><figcaption></figcaption></figure>

And there you go! Model deployed.
