Suicide Risk Prediction Using Social Media and Cassandra


Published on

Presentation at Cassandra Summit 2013

Published in: Technology, Business
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Suicide Risk Prediction Using Social Media and Cassandra

  1. 1. #CASSANDRA13Ken  Krugler  |  President,  Scale  UnlimitedSuicide Prevention Using Social Media and Cassandra
  2. 2. #CASSANDRA13What we will discuss today...*Using Cassandra to store social media content*Combining Hadoop workflows with Cassandra*Leveraging Solr search support in DataStax Enterprise*Doing good with big dataThis material is based upon work supported by the Defense Advance Research Project Agency (DARPA),and Space Warfare Systems Center Pacific under Contract N66001-11-4006. Any opinions, findings, andconclusions or recommendations expressed in this material are those of the authors(s) and do notnecessarily reflect the views of the Defense Advance Research Program Agency (DARPA) and Space andNaval Warfare Systems Center Pacific.Fine Print!
  3. 3. #CASSANDRA13Obligatory Background*Ken Krugler, Scale Unlimited - Nevada City, CA*Consulting on big data workflows, machine learning & search*Training for Hadoop, Cascading, Solr & Cassandra
  4. 4. #CASSANDRA13Durkheim Project OverviewIncluding things we didnt work on...
  5. 5. #CASSANDRA13Whats the problem?*More soldiers die from suicide than combat*Suicide rate has gone up 80% since 2002*Civilian suicide rates are also climbing*More suicides than homicides*Intervention after an "event" is often too lateGraph of suicide rates
  6. 6. #CASSANDRA13What is The Durkheim Project?*DARPA-funded initiative tohelp military physicians*Uses predictive analytics toestimate suicide risk fromwhat people write online*Each user is assigned asuicidality risk rating of red,yellow or green.Émile DurkheimNamed after Emile Durkheim, late 1800s sociologist who first used text analytics to help define suicide risk.
  7. 7. #CASSANDRA13Current Status of Durkheim*Collaborative effort involving Patterns and Predictions, DartmouthMedical School & Facebook*Details at*Finished phase I, now being rolled out to wider audiencePatterns and Predictions has its background expertise in predicting financial market events and trends from news, which led to the development of the predictivemodels used in Durkheim
  8. 8. #CASSANDRA13Predictive Analytics*Guessing at state of mind from text-"There are very few people in this world that know the REAL me."-"I lay down to go to sleep, but all I can do is cry"*Uses labeled training data from clinical notes*Phase I results promising, for small sample set-"ensemble" of predictors is a powerful ML technique
  9. 9. #CASSANDRA13Clinician Dashboard*Multiple views on patient*Prediction & confidence*Backing data (key phrases, etc)So this is the goal - give medical staff indications of who they should be most concerned about.
  10. 10. #CASSANDRA13Data CollectionWhere _do_ you put a billion text snippets?The previous section was the project overview, which was work done by others in the project.Now we get to the part that we worked, which involves Cassandra
  11. 11. #CASSANDRA13Saving Social Media Activity*System to continuous save new activity-Scalable data store*Also needs a scalable, reliable way to access data-Processed in bulk (workflows)-Accessed at individual level-Searched at activity levelFor the current size of the project, MySQL would be just fine.But we want an architecture that can scale if/when the project is rolled out to everyone
  12. 12. #CASSANDRA13Data Collection*Pink is what we wrote*Green is in Cassandra*Key data path in redExciting SocialMedia ActivityGigyaDaemonDurkheimSocial APIUsersTableDurkheimAppGigyaServiceActivityTable
  13. 13. #CASSANDRA13Designing the Column Families*What queries do we need to handle?-Always by user id (what we assign)*We want all the data for a user-Both for Users table, and Activities table-Sometimes we want a date range of activities*So one row per user-And ordered by date in the Activities table
  14. 14. #CASSANDRA13Users Table (Column Family)*One row per user - row key is a UUID we assign*Standard "static" columns-First name, last name, opt_in status, etc.*Easy to add more xxx_id columns for new servicesrow key first_name last_name facebook_id twitter_id opt_in
  15. 15. #CASSANDRA13Activities Table (Column Family)*One row per user - row key is a UUID we assign*One composite column per social media event-Timestamp (long value)-Source (FB, TW, GP, etc)-Type of column (data, activity id, user id, type of activity)row key ts_src_data ts_src_id ts_src_providerUid ts_src_typeRemember we wanted to get slices of data by date?So we use timestamp as the first (primary) ordering for the columns.We can use regular millisecond timestamp since its for one user, assume we dont get multiple entries.
  16. 16. #CASSANDRA13Two Views of Composite Columns*As a row/column view*As a key-value map 213_FB_data213_FB_id213_FB_providerUid213_FB_type"I feel tired""FB post #32""FB user #66""Status update""uuid1""uuid1" 213_FB_data 213_FB_id 213_FB_providerUid 213_FB_type"I feel tired" "FB post #32" "FB user #66" "Status update"
  17. 17. #CASSANDRA13Implementation Details*API access protected via signature*Gigya Daemon on both t1.micro servers-But only active on one of them*Astyanax client talks to Cassandra*Cluster uses 3 m1.large serversDurkheimSocial APIDurkheimAppAWS LoadBalancerEC2 m1.largeserversDurkheimSocial APIEC2 t1.microservers
  18. 18. #CASSANDRA13Predictive Analytics at ScaleRunning workflows against Cassandra data
  19. 19. #CASSANDRA13How to process all this social media goodness?*Models are defined elsewhere*These are "black boxes" to us213_FB_data 213_FB_id 213_FB_providerUid 213_FB_type"I feel tired" "FB post #32" "FB user #66" "Status update"307_TW_data 307_TW_id 307_TW_providerUid 307_TW_type"Where am I?" "Tweet #17" "TW user #109" "Tweet"FeatureExtractionModelmodel rating probability keywordsModels are data used by PA engine to generate scoresWe do not have or want access to the data used to generate the modelsGenerating the model is often NOT something that needs scalabilityAmount of labeled data is typically pretty small.Training often works best on a single server.
  20. 20. #CASSANDRA13Why do we need Hadoop?*Running one model on one user is easy-And n models on one user is still OK*But when a model changes...-all users with the model need processingModels can change frequentlyAnd when a user changes...- that user with all models needs processing- adding/removing models is also a change
  21. 21. #CASSANDRA13Batch processing is OK*No strict minimum latency requirements*So we use Hadoop, for scalability and reliability
  22. 22. #CASSANDRA13Hadoop Workflow Details*Implemented using Cascading*Read Activities Table using Cassandra Tap*Read models from MySQL via JDBC
  23. 23. #CASSANDRA13Hadoop Bulk Classification WorkflowConvert to CassandraWrite Classification Result TableRun Classifier modelsCoGroup by user profile IDConvert from CassandraRead User Profiles TableConvert from CassandraRead Social Media Activity TableSeparate from this, weve loaded the models into memory and serialized them with the classification stepThis is all done using Cascading to define the workflow.
  24. 24. #CASSANDRA13Workflow Issues*Currently manual operation-Ultimately needs a daemon to trigger (time, users, models)*Runs in separate cluster-Lots of network activity to pull data from Cassandra cluster-With DSE we could run on same cluster*Fun with AWS security groups
  25. 25. #CASSANDRA13Solr SearchPoking at the data
  26. 26. #CASSANDRA13Solr Search*Model results include key terms for classification result-"feel angry" (0.732)*Now you want to check actual usage of these termsMaybe actual text was "I dont feel angry when my wifi connection drops".
  27. 27. #CASSANDRA13Poking at the Data*Hadoop turns petabytes intopie-charts*How do you verify results?*Search works really well hereMaybe before youd use a spreadsheet printout to argue.But that would be Satans Spreadsheet with billions of rows.
  28. 28. #CASSANDRA13Solr Search*Want "narrow" table for search-Solr dynamic fields are usually not a great idea-Limit to 1024 dynamic fields per document*So well replicate some of our Activity CF data into a new CF*Dont be afraid of making copies of data
  29. 29. #CASSANDRA13The "Search" Column Family*Row key is derived from Activity CF UUID + target column name*One column ("data") has content from that row + column in Activity CFrow key "data""uuid1_213_FB "I feel tired""uuid1" 213_FB_data 213_FB_id"I feel tired" "FB post #32"Activity Column FamilySearch Column Family
  30. 30. #CASSANDRA13Solr Schema*Very simple (which is how we like it)*Direct one-to-one mapping with Cassandra columns*Hits have key field, which contains UUID/Timestamp/Service<fields><field name="key" type="string" indexed="true" stored="true" /><field name="data" type="text" indexed="true" stored="true" /></fields>So once we have a hit, we can access information in activity table if needed.
  31. 31. #CASSANDRA13Combined Cluster*One Cassandra Cluster can allocate nodes for Hadoop & Search
  32. 32. #CASSANDRA13SecurityLocking things down
  33. 33. #CASSANDRA13The Most Important Detail*We dont have any personal medical data!!!*We dont have any personal medical data!!!*We dont have any personal medical data!!!As soon as youve got personal medical data, its a whole new ballgame.At least an order of magnitude more work to make it really secure.Likely that you couldnt use AWS cloudWe still care about security, because were collecting social media activity that isnt necessarily public.
  34. 34. #CASSANDRA13Three Aspects of Security*Server-level-ssh via restricted private key*API-level-validate requests using signature-secure SHA1 hash*Services-level-Restrict open ports using security groupsSo even if you knew which server was running OpsCenter, you couldnt just start poking around.Access to Cassandra is only via t1.micro servers, which are in same security groupt1.micro servers only open up ssh and port needed for external API request[include picture?]
  35. 35. #CASSANDRA13SummaryBringing it all home
  36. 36. #CASSANDRA13*You can effectively use Cassandra as:A repository for social media dataThe data source for workflowsA search index, via Solr integrationKey Points...
  37. 37. #CASSANDRA13*It is possible to do more with big data than optimize ad yieldsAnd the Meta-Point