geo.asciidoc 2.6 KB

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