ml-geo-functions.asciidoc 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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" : "transactionCoordinates",
  30. "by_field_name" : "creditCardNumber"
  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 fraud.
  43. IMPORTANT: The `field_name` that you supply must be a single string that contains
  44. two comma-separated numbers of the form `latitude,longitude`, a `geo_point` field,
  45. a `geo_shape` field that contains point values, or a `geo_centroid` aggregation.
  46. The `latitude` and `longitude` must be in the range -180 to 180 and represent a
  47. point on the surface of the Earth.
  48. For example, JSON data might contain the following transaction coordinates:
  49. [source,js]
  50. --------------------------------------------------
  51. {
  52. "time": 1460464275,
  53. "transactionCoordinates": "40.7,-74.0",
  54. "creditCardNumber": "1234123412341234"
  55. }
  56. --------------------------------------------------
  57. // NOTCONSOLE
  58. In {es}, location data is likely to be stored in `geo_point` fields. For more
  59. information, see {ref}/geo-point.html[`geo_point` data type]. This data type is
  60. supported natively in {ml-features}. Specifically, when pulling data from a
  61. `geo_point` field, a {dfeed} will transform the data into the appropriate
  62. `lat,lon` string format before sending to the {anomaly-job}.
  63. For more information, see <<ml-configuring-transform>>.