{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":48014,"path":"servicenow-platform/metricbase/metricbase-data-explorer.md","title":"Get familiar with MetricBase APIs","bundle":null,"doc_type":null,"release":"australia","body":"\n# Get familiar with MetricBase APIs\n\nExperiment with MetricBase APIs using Data Explorer that is part of the MetricBase Demo application. Data Explorer uses the data installed with the MetricBase Demo application.\n\n## Before you begin\n\nRole required: clotho\\_admin\n\n## About this task\n\nData Explorer is a playground where you can see and edit example scripts that visualize data included with the MetricBase Demo application. The example scripts use the MetricBase JavaScript APIs. For information on the MetricBase JavaScript APIs, see [Client](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/api-reference/server-api-reference/ClientScopedAPI.md), [Data](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/api-reference/server-api-reference/DataScopedAPI.md), [DataBuilder](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/api-reference/server-api-reference/DataBuilderScopedAPI.md), [Transformer](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/api-reference/server-api-reference/TransformerScopedAPI.md), [TransformPart](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/api-reference/server-api-reference/TransformPartScopedAPI.md), [TransformResult](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/api-reference/server-api-reference/TransformResultScopedAPI.md).\n\nNote that the now/v1/clotho/transform/topic API endpoint is reserved for internal use only.\n\nExample scripts use either:\n\n-   Transforms, which use the [Transformer](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/api-reference/server-api-reference/TransformerScopedAPI.md) method.\n-   Machine Language, trained models that predict expected behavior. All the scripts without \"Transform\" in their title use Machine Language.\n\n## Procedure\n\n1.  Navigate to **All** &gt; **MetricBase Demo** &gt; **Data Explorer**.\n\n    The **Data Explorer** displays.\n\n    \\[Omitted image \"data-explorer.png\"\\] Alt text: Data Explorer UI\n\n    When you run a script, the data visualization appears under **Data Explorer Script Result Display**.\n\n2.  Select one of the sample scripts to run in the **Example Script** menu.\n\n    \\[Omitted image \"data-explorer-buttons.png\"\\] Alt text: Steps to run a script\n\n3.  Click **Load Example**.\n\n4.  Click **Run**.\n\n    The script displays the data visualization under **Data Explorer Script Result Display**.\n\n5.  Change the values or statements in the script or write an entirely new script and click **Run**.\n\n    **Note:** If you want to save the changes you made in the script, click **Save**.\n\n6.  Under **Server Output**, look at the server's response that might include error information.\n\n\n## Example\n\n<table id=\"table_v2g_vkq_23b\"><thead><tr><th>\n\nExample script\n\n</th><th>\n\nDefinition and visualization\n\n</th></tr></thead><tbody><tr><td>\n\nSimple Transform\n\n</td><td>\n\nUses the transformer API to display a single time-series metric, the average speed of the drones: `transformer.metric('mb_demo_mt_speed').avg`\\(\\). \\[Omitted image \"data-explorer-average-speed.png\"\\] Alt text: Simple transform using average\n\n</td></tr><tr><td>\n\nSimple Transform with Grouping\n\n</td><td>\n\nUses the transformer API to display a group of time-series metrics, the average altitude of the fleet of the drones: ```\ntransformer.groupBy(\"fleet\").metric(\"mb_demo_mt_altitude\").\n      avg().label('avg - %g:fleet:')\n```\n\n \\[Omitted image \"data-explorer-simple-xform-grouping.png\"\\] Alt text: Grouping transform\n\n</td></tr><tr><td>\n\nNormal Model\n\n</td><td>\n\nModels normal data, which approximates a bell-shaped or Gaussian curve for distributed values.\n\n</td></tr><tr><td>\n\nLinear Model\n\n</td><td>\n\nCreates a line to summarize the current data and predict future values. This example, about the remaining charge in drone batteries, graphs both the trained model values and the average of the values.```\nvar builder = new sn_clotho.Transformer(drones);\nvar fit = builder.metric(\"mb_demo_nt_rem_battery\").resample(100).\n          fit({model:\"linear\"}).label(\"Fitted\");\nbuilder.metric(\"nb_demp_mt_rem_battery\").avg().label(\"Original\")\n```\n\n \\[Omitted image \"data-explorer-linear-model.png\"\\] Alt text: Linear model\n\n</td></tr><tr><td>\n\nSeasonal Trend Decomposition Model\n\n</td><td>\n\nUses a seasonal trend model so that data can be subtracted to reveal non-seasonal trends. This model is similar in purpose to the Holt Winters model but arrives at the result using different algorithms.```\nvar builder = new sn_clotho.Transformer(drones);\nvar metric = \"nb_demo_mt_rem_battery\";\nvar fit = builder.metric(metric).fit({model:\"STL\",periodicity:\"PT2H\", \n          innerCycles:1, outerCycles:10})\n```\n\n \\[Omitted image \"data-explor-seasonal-trend-decomp.png\"\\] Alt text: Seasonal correction to trend\n\n</td></tr><tr><td>\n\nHolt Winters Model\n\n</td><td>\n\nUses the Holt Winters, seasonal trend model so that data can be subtracted to reveal non-seasonal trends. This model is similar in purpose to the Seasonal Trend Decomposition model but arrives at the result using different algorithms.\n\n</td></tr><tr><td>\n\nARIMA Model\n\n</td><td>\n\nThe most general class of models for predicting time-series data that has no trend, meaning all the data has the same value or the values fluctuate sinusoidally around the mean.\n\n</td></tr><tr><td>\n\nDeviation Model\n\n</td><td>\n\nUses chisquare model to show the differences between the real data and the model's prediction. ```\nvar metric = \"nb_demo_mt_rem_battery\";\nbuilder.metric(metric).deviation(model, \"chiSquare\");\n```\n\n \\[Omitted image \"data-explor-chisquare-deviation.png\"\\] Alt text: Deviation model\n\n</td></tr></tbody>\n</table>**Parent Topic:**[Working with MetricBase demo data](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/servicenow-platform/metricbase/working-with-metricbase-demo-data.md)\n\n"}}