# Export model

**URL:** <https://discuss.elastic.co/t/export-model/186690>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-machine-learning\
**Created:** [June 20, 2019, 12:57pm UTC](https://discuss.elastic.co/t/export-model/186690 "2019-06-20T12:57:29Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bharath\_Kumar\_R](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bharath_kumar_r/32/45474_2.png) [@Bharath\_Kumar\_R](https://discuss.elastic.co/u/Bharath_Kumar_R)\
**Post date:** [June 20, 2019, 12:57pm UTC](https://discuss.elastic.co/t/export-model/186690/1 "2019-06-20T12:57:29Z")

</div>

Assume the following scenario  
I have the resources to collect only 60 days of data  
My job has been running for more than 200 days  
Today I found out we captured an anomaly and we wanted to remove this through the following steps

1. Create calendar event that will have the timeline of anomaly occurance. This is to skip data from being learnt by the new job
2. Clone the existing job and run the cloned job

The problem with above approach is that the cloned job is trained only on the last 60 days of data. However my old job was based on a model that learnt from 200 days of data. So is there a way to take a snapshot of the model at any point of time (in this case, I want the snapshot of the model just before anomaly)? If yes, can I import this model in the cloned job and start feeding more data?

---

<div class="post-metadata">

**Author:** ![richcollier](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/richcollier/32/115035_2.png) [@richcollier](https://discuss.elastic.co/u/richcollier)\
**Post date:** [June 20, 2019, 3:07pm UTC](https://discuss.elastic.co/t/export-model/186690/2 "2019-06-20T15:07:30Z")

</div>

You can use the ML [Model Snapshots API](https://www.elastic.co/guide/en/elasticsearch/reference/7.1/ml-apis.html#ml-api-snapshot-endpoint) to revert the job to a model that was saved before your anomaly occurred, and you could pass the `delete_intervening_results` flag to delete the anomaly.

After this, you could start the datafeed again, but choose the start time to be _after_ the anomaly.

---

<div class="post-metadata">

**Author:** ![Bharath\_Kumar\_R](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bharath_kumar_r/32/45474_2.png) [@Bharath\_Kumar\_R](https://discuss.elastic.co/u/Bharath_Kumar_R)\
**Post date:** [June 21, 2019, 10:33am UTC](https://discuss.elastic.co/t/export-model/186690/4 "2019-06-21T10:33:06Z")

</div>

Is it possible to modify the "model\_snapshot\_retention\_days" of an existing job?

---

<div class="post-metadata">

**Author:** ![richcollier](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/richcollier/32/115035_2.png) [@richcollier](https://discuss.elastic.co/u/richcollier)\
**Post date:** [June 21, 2019, 12:13pm UTC](https://discuss.elastic.co/t/export-model/186690/5 "2019-06-21T12:13:22Z")

</div>

Yes - it is a settable parameter in the create job API call:

> **[Create jobs API | Elasticsearch Guide \[7.1\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/7.1/ml-put-job.html)**

> `model_snapshot_retention_days`  
> (long) The time in days that model snapshots are retained for the job. Older snapshots are deleted. The default value is `1` , which means snapshots are retained for one day (twenty-four hours).

---

<div class="post-metadata">

**Author:** ![Bharath\_Kumar\_R](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bharath_kumar_r/32/45474_2.png) [@Bharath\_Kumar\_R](https://discuss.elastic.co/u/Bharath_Kumar_R)\
**Post date:** [June 21, 2019, 12:20pm UTC](https://discuss.elastic.co/t/export-model/186690/6 "2019-06-21T12:20:18Z")

</div>

if I use create jobs api for an existing job, doesn't hit a resource\_already\_exists\_exception? I need to know if modification is possible in an already existing job?

---

<div class="post-metadata">

**Author:** ![richcollier](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/richcollier/32/115035_2.png) [@richcollier](https://discuss.elastic.co/u/richcollier)\
**Post date:** [June 21, 2019, 12:36pm UTC](https://discuss.elastic.co/t/export-model/186690/7 "2019-06-21T12:36:01Z")

</div>

Correct, you cannot `PUT` a new configuration to an existing named job. You'll need a new name (`job_id`) for the job.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 19, 2019, 12:49pm UTC](https://discuss.elastic.co/t/export-model/186690/8 "2019-07-19T12:49:22Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
