Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
236 views
in Technique[技术] by (71.8m points)

java - Label data based on prior records in spark

I am working on incorporating Spark and MySQL for data processing in Java for a small exercise to determine repetition in criminal behavior. I have been able to set up everything okay, but am banging my head against a wall in order to get the following logic to work.

Given a table of the following information - I want to be able to label the following, with the instance of how often that item has occurred. This is calculated when the person is doing their community service:

  • NO HISTORY : if the person has no prior criminal history; instance count of zero
  • GOOD HISTORY : if the person had no fight history and has done community service in the last 90 days; instance count of comm service in last 90 days
  • FIGHT HISTORY : if the person has atleast one fight in their history; instance count of fights

Given :

incident_date person_involved event_type
2020-02-01 Ronny G. FIGHT
2020-02-03 Ronny G. FIGHT
2020-02-10 Stella B. COM SERVE
2020-02-14 Ronny G. COM SERVE
2020-03-15 Stella B. COM SERVE
2020-05-01 Stella B. COM SERVE
2020-10-01 Stella B. COM SERVE

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...