ml-geo-functions.asciidoc 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. ["appendix",role="exclude",id="ml-geo-functions"]
  2. = Geographic functions
  3. The geographic functions detect anomalies in the geographic location of the
  4. input data.
  5. The {ml-features} include the following geographic function: `lat_long`.
  6. NOTE: You cannot create forecasts for {anomaly-jobs} that contain geographic
  7. functions. You also cannot add rules with conditions to detectors that use
  8. geographic functions.
  9. [discrete]
  10. [[ml-lat-long]]
  11. == Lat_long
  12. The `lat_long` function detects anomalies in the geographic location of the
  13. input data.
  14. This function supports the following properties:
  15. * `field_name` (required)
  16. * `by_field_name` (optional)
  17. * `over_field_name` (optional)
  18. * `partition_field_name` (optional)
  19. For more information about those properties, see the
  20. {ref}/ml-put-job.html#ml-put-job-request-body[create {anomaly-jobs} API].
  21. .Example 1: Analyzing transactions with the lat_long function
  22. [source,console]
  23. --------------------------------------------------
  24. PUT _ml/anomaly_detectors/example1
  25. {
  26. "analysis_config": {
  27. "detectors": [{
  28. "function" : "lat_long",
  29. "field_name" : "transaction_coordinates",
  30. "by_field_name" : "credit_card_number"
  31. }]
  32. },
  33. "data_description": {
  34. "time_field":"timestamp",
  35. "time_format": "epoch_ms"
  36. }
  37. }
  38. --------------------------------------------------
  39. // TEST[skip:needs-licence]
  40. If you use this `lat_long` function in a detector in your {anomaly-job}, it
  41. detects anomalies where the geographic location of a credit card transaction is
  42. unusual for a particular customer’s credit card. An anomaly might indicate
  43. fraud.
  44. IMPORTANT: The `field_name` that you supply must be a single string that
  45. contains two comma-separated numbers of the form `latitude,longitude`, a
  46. `geo_point` field, a `geo_shape` field that contains point values, or a
  47. `geo_centroid` aggregation. The `latitude` and `longitude` must be in the range
  48. -180 to 180 and represent a point on the surface of the Earth.
  49. For example, JSON data might contain the following transaction coordinates:
  50. [source,js]
  51. --------------------------------------------------
  52. {
  53. "time": 1460464275,
  54. "transaction_coordinates": "40.7,-74.0",
  55. "credit_card_number": "1234123412341234"
  56. }
  57. --------------------------------------------------
  58. // NOTCONSOLE
  59. In {es}, location data is likely to be stored in `geo_point` fields. For more
  60. information, see {ref}/geo-point.html[`geo_point` data type]. This data type is
  61. supported natively in {ml-features}. Specifically, when pulling data from a
  62. `geo_point` field, a {dfeed} will transform the data into the appropriate
  63. `lat,lon` string format before sending to the {anomaly-job}.
  64. For more information, see <<ml-configuring-transform>>.