Revelando los secretos de twitter, Festival de Software Libre 2014
-
Upload
abel-alejandro-coronado-iruegas -
Category
Technology
-
view
557 -
download
0
description
Transcript of Revelando los secretos de twitter, Festival de Software Libre 2014
![Page 1: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/1.jpg)
Revelando los Secretos de Twitter en México.
31 de Octubre de 2014
![Page 2: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/2.jpg)
abel.coronado @ inegi.org.mx
![Page 3: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/3.jpg)
![Page 4: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/4.jpg)
@abxda
![Page 5: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/5.jpg)
Objetivo
Inspirarlos para que experimenten con Big Data
![Page 7: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/7.jpg)
Ciencia de Datos en Acción (2011)
www.inegi.org.mx/est/contenidos/Proyectos/estratificador/
@abxda
![Page 8: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/8.jpg)
Tecnologías Involucradas (2011)
{ JSON }
D3.js Librería JavaScript para creación de los gráficos vectoriales interactivos.
Librería JavaScript facilita la incorporación del patrón MVC en aplicaciones web de una sola página.Diseño de estructura de la página y habilitación responsiva via Twitter Bootstrap.
JSON formato de intercambio de datos.
Motor de análisis estadístico, habilitador de la inteligencia estadística.
@abxda
![Page 9: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/9.jpg)
Ciencia de Datos en Acción (2011)
![Page 10: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/10.jpg)
Ciencia de Datos en Acción (2011)
@abxda
![Page 11: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/11.jpg)
¿Qué es Big Data?2013
@abxda
![Page 12: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/12.jpg)
Spark y MLBase
import org.apache.spark.mllib.clustering._
val manzanas = sc.textFile("/Users/abxda/…/datos.csv")val subconjunto = manzanas.map(manzana => extractColumn(manzana))points_nacional.cachevar modelo = KMeans.train(subconjunto, k=5, maxIterations=10)val out = new PrintWriter("/Users/abxda/…/salida.csv")subconjunto.collect.foreach(x => out.println(modelo.predict(x)))out.close()
8 seg
@abxda
¿Qué es Big Data?2013
![Page 13: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/13.jpg)
¿Qué es Big Data?
http://datascience.berkeley.edu/what-is-big-data/ @abxda
![Page 14: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/14.jpg)
¿Qué es Big Data?
http://datascience.berkeley.edu/what-is-big-data/ @abxda
![Page 15: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/15.jpg)
¿Qué es Big Data?
http://datascience.berkeley.edu/what-is-big-data/ @abxda
![Page 16: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/16.jpg)
¿Qué es Big Data?
http://datascience.berkeley.edu/what-is-big-data/ @abxda
![Page 17: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/17.jpg)
¿Qué es Big Data?
http://datascience.berkeley.edu/what-is-big-data/ @abxda
![Page 18: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/18.jpg)
Volumen
http://commons.wikimedia.org/wiki/Elephas#mediaviewer/File:Berlin_Landesvertretung_Niedersachsen_Elefant.jpg @abxda
![Page 19: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/19.jpg)
Velocidad
http://upload.wikimedia.org/wikipedia/commons/0/0f/Kinemetrics_seismograph.jpg
@abxda
![Page 20: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/20.jpg)
Variedad
http://upload.wikimedia.org/wikipedia/commons/f/f6/Popular_Social_Networks%2C_Gavin_Llewellyn%2C_CC.jpg
@abxda
![Page 21: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/21.jpg)
Tomar decisiones, actuar y crear valor
http://upload.wikimedia.org/wikipedia/commons/5/5b/Samurai_award.jpg
![Page 22: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/22.jpg)
http://drewconway.com/zia/2013/3/26/the-data-science-venn-diagram
Experto encomputación ydesarrollo avanzados
Experto enestadísticamatemática
Experto enel dominio de
datos
CIENCIADE
DATOS
Zonapeligrosa!
Investigacióntradicional
Machinelearning
Ciencia de Datos
@abxda
![Page 23: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/23.jpg)
https://twitter.com/josh_wills/status/198093512149958656
![Page 24: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/24.jpg)
http://www.r-bloggers.com/data-science-toolbox-survey-results-surprise-r-and-python-win/
Recolectar
Explorar, Visualizar
Limpiar
Transformar
Modelar
Validar
Comunicar
?
Ciencia de Datos
Imaginar /Cuestionar /Comprender
@abxda
![Page 25: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/25.jpg)
Científico de Datos vs Ingeniero de
Datos
@abxda
Data Products Handle 3 V’s
![Page 26: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/26.jpg)
¿qué?
¿quién?
¿dónde?
¿cuántos?¿por qué?
Análisis de Datos
Velocidad
Variedad
Estadística Machine Learning
Estratificaciones
Análisis de Regresión
Muestreo
Mucho más…
Análisis de Redes (Grafos)
Minería de Datos
Ciencia de Datos y Big Data
Computo en Paralelo
Datos Crudoshdfs://
Ciencia de Datos (Transforma/Modela)
Cómputo Concurrente y Paralelo
Información(Significado)
Tomar Decisione
sActuar
Volumen
AlmacenamientoDistribuido
Internet de las Cosas
Internet de las Personas
Internet de las Ideas
Internet de Todo
@abxda
![Page 27: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/27.jpg)
Internet de Todo
@abxda@hbcolectivo
![Page 28: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/28.jpg)
Big Data en las Oficinas Nacionales de Estadística
http://www1.unece.org/stat/platform/download/attachments/58492100/Big+Data+HLG+Final.docx?version=1&modificationDate=1362939424184 @abxda
![Page 29: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/29.jpg)
• It is clear that during the next two years there is a need to identify a few pilot projects that will serve as proof of concept.
• Statistical organisations are, therefore, encouraged to address formally Big data issues in their annual and multi-annual work programmes by undertaking research and pilot projects in selected areas and by allocating appropriate resources for that purpose.
Big Data en las Oficinas Nacionales de Estadística
@abxda
![Page 30: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/30.jpg)
• 'new' exploration and analysis methods are required: Visualization methods, Text mining, and High Performance Computing.
• To use Big data, statisticians are needed with a different mind-set and new skills. The processing of more and more data for official statistics requires statistically aware people with an analytical mind-set, an affinity for IT (e.g. programming skills) @abxda
Big Data en las Oficinas Nacionales de Estadística
![Page 31: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/31.jpg)
Twitter como fuente de Big Data
@abxda@hbcolectivo
![Page 32: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/32.jpg)
¿Cuántos caracteres?
@abxda
![Page 33: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/33.jpg)
140 ???
@abxda
![Page 34: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/34.jpg)
Todo listo para la presentación de #BigData en el @FSLmx .
1482
Json: Formato de Intercambio
![Page 35: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/35.jpg)
Nuestra huella en las Redes Sociales
@abxda
![Page 36: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/36.jpg)
Todos los tuits están disponibles para su recolección en tiempo
real.
@abxda
![Page 37: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/37.jpg)
Incluso permite consultas geográficas
@abxda
![Page 38: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/38.jpg)
¿Dónde recolectar?
@abxda
![Page 39: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/39.jpg)
http://www.elasticsearch.org/
@abxda
![Page 40: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/40.jpg)
¿Por qué ElasticSearch?
@abxda
![Page 41: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/41.jpg)
Switch Puertos (a) 10.200.2.xPuertos (b)10.1.1.X
Hydra 2 – [10.1.1.X | 10.200.X.X]
Hydra1 – Master 10.1.1.X
Acceso a Internet [Recolecta información Redes
Sociales]
< ESCALABILIDAD HORIZONTAL >
¿Por qué ElasticSearch?
@abxda
![Page 42: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/42.jpg)
Hydra
@abxda
![Page 43: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/43.jpg)
Hydra
@abxda
![Page 44: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/44.jpg)
Twitter Riverhttps://github.com/elasticsearch/elasticsearch-river-twitter
curl -XPUT localhost:9200/_river/my_twitter_river/_meta -d' { "type" : "twitter", "twitter" : { "oauth" : { "consumer_key" :”XXXxxXXxXxX", "consumer_secret" : "XXXxxXXxXxXXXXxxXXxXxXXXXxxXXxXxX", "access_token" : "XXXxxXXxXxXXXXxxXXxXxXXXXxxXXxXxX", "access_token_secret" : "XXXxxXXxXxXXXXxxXXxXxX" }, "filter" : { "locations" :"-118.40764955,14.53209836,-86.71040527,32.71865357" } } } '
@abxda
![Page 45: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/45.jpg)
La recolección 2014
@abxda
![Page 46: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/46.jpg)
Extractor
es = Elasticsearch(['10.200.2.41:9200'])rs = es.search(index=['my_twitter_river'], scroll=duracion, search_type='scan', size=int(noTuits), body={ "query": { "range" : { "created_at" : { "gte": fechaInicio, "lte": fechaFin } }}})
@abxda
![Page 47: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/47.jpg)
CSV
@abxda
![Page 48: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/48.jpg)
Se extraen los puntos del CSV
$cat tweets_feb_sep_ord_loc.csv | awk -F',' '{print $3 "," $4}'
20.281523,-100.80940720.281523,-100.80940720.281667,-100.80931120.281479,-100.80939420.281526,-100.80937720.281422,-100.80942820.281478,-100.80940620.281495,-100.80937120.281521,-100.8093725.767972,-103.27489025.768021,-103.27490025.768059,-103.27495525.768019,-103.27490025.768098,-103.274992
@abxda
![Page 50: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/50.jpg)
Resultado de la recolección
80M Tuits
@abxda
![Page 51: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/51.jpg)
Un acercamiento
![Page 52: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/52.jpg)
@abxda
Red Nacional de Caminosy
![Page 53: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/53.jpg)
Hadoop Distributed File Systemhdfs://
@abxda
![Page 54: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/54.jpg)
Hadoop / Apache Spark
@abxda
ó
![Page 55: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/55.jpg)
¿Por qué Apache Spark?
http://spark.apache.org/
@abxdahttp://www.slideshare.net/pacoid/how-spark-fits-into-the-big-data-landscape
![Page 56: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/56.jpg)
¿Por qué Apache Spark?
http://databricks.com/blog/2014/10/10/spark-petabyte-sort.html
@abxda
![Page 57: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/57.jpg)
¿Por qué Apache Spark?
http://databricks.com/blog/2014/10/10/spark-petabyte-sort.html
@abxda
![Page 58: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/58.jpg)
¿Por qué Apache Spark?
http://databricks.com/blog/2014/10/10/spark-petabyte-sort.html @abxda
![Page 59: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/59.jpg)
¿Por qué Apache Spark?
http://databricks.com/blog/2014/10/10/spark-petabyte-sort.html @abxda
![Page 60: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/60.jpg)
¿Por qué Apache Spark?
@abxda
![Page 61: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/61.jpg)
Scala = Object + Functional Programming
https://twitter.com/deanwampler/status/458032648552603648
![Page 62: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/62.jpg)
http://www.slideshare.net/deanwampler/spark-the-next-top-compute-model-39976454
¿Por qué Apache Spark?Tuesday, September 30, 14 Why is Spark so good (and Java MapReduce so bad)? Because fundamentally, data analytics is Mathematics and programming tools inspired by Mathematics - like Functional Programming - are ideal tools for working with data. This is why Spark code is so concise, yet powerful. This is why it is a great platform for performance optimizations. This is why Spark is a great platform for higher-level tools, like SQL, graphs, etc. Interest in FP started growing ~10 years ago as a tool to attack concurrency. I believe that data is now driving FP adoption even faster. I know many Java shops that switched to Scala when they adopted tools like Spark and Scalding (https://github.com/twitter/scalding).
![Page 63: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/63.jpg)
Recorte Geográfico object SimpleApp { def main(args: Array[String]){ …
val csvPath = "hdfs://m01/user/acoronado/mov/2014-02_al_2014-09-23.csv" val csv = sc.textFile(csvPath) csv.cache() val clipPoints = csv.map({line: String => val Array(usuario, lat, lon, date) = line.split(",").map(_.trim) val geometryFactory = JTSFactoryFinder.getGeometryFactory(); val reader = new WKTReader(geometryFactory); val point = reader.read("POINT ("+lon+" "+ lat + ")" ) val envelope = point.getEnvelopeInternal val internal = geoDataMun.get(envelope) val (cve_est, cve_mun) = internal match { case l => { val existe = l.find( f => f match { case (g:Geometry,e:String,m:String) => g.intersects(point)
case _ => false} ) existe match { case Some(t) => t match { case (g:Geometry,e:String,m:String) => (e,m) case _ => ("0","0")} case None => ("0", "0") } } case _ => ("0", "0") } val time = … line+","+time+","+cve_est+","+cve_mun }) clipPoints.coalesce(5,true).saveAsTextFile("hdfs://m01/user/acoronado/mov/resultados_movilidad_parts.csv") } }
@abxda
![Page 64: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/64.jpg)
Más de 700,000 tuiteros dentro del territorioMexicano.
cat tweets_feb_sep.csv | awk -F',' '{print $1}'|sort| uniq | wc -l
@abxda
![Page 65: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/65.jpg)
Calcular total de tuits por Hora
val hours = csv.map({line:String =>
val campos = line.split(",").map(_.trim) val d1 = new Date(campos(8).toLong) val format = new SimpleDateFormat("dd-MM-yyyy,HH")
(format.format(d1),1)}).reduceByKey((a,b) => a+b)
val csvPath ="hdfs://master/user/acoronado/tweets_feb_sep.csv"
val csv = sc.textFile(csvPath)
csv.cache
hours.coalesce(1).saveAsTextFile("hdfs://…/days_hours_string.csv")
@abxda
![Page 66: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/66.jpg)
Map-Reduce
https://twitter.com/francesc/status/507942534388011008 @abxda
![Page 67: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/67.jpg)
@abxda
![Page 68: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/68.jpg)
Generar la Gráfica
@abxda
![Page 69: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/69.jpg)
A lo largo del tiempo
@abxda
![Page 70: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/70.jpg)
¿Qué pasó entre el 12 de Junio y el 13 de Julio?
@abxda
![Page 71: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/71.jpg)
Pregúntale a Twitter
?@abxda
![Page 72: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/72.jpg)
Busca tuits en la fecha especifica
object Main extends App {val fecha1 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").parse("2014-06-12T00:00:00")val fecha2 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").parse("2014-07-13T23:59:59")
scala.io.Source.fromFile(”/abxda/BigData/tweets_feb_sep_ord_loc.csv").getLines().grouped(250000).flatMap { y=>
y.par.filter({line: String => val campos = line.split(",").map(_.trim)
val time = new Date(campos(8).toLong) time.after(fecha1) && time.before(fecha2)
}) }.foreach({ x: String =>
println(x.toString) })
}
@abxda
![Page 73: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/73.jpg)
Cómputo paraleloy.par.filter
![Page 74: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/74.jpg)
Encuentra Hashtags
# coding=utf-8import codecsimport recnt = 0with codecs.open('/abxda/BigData/Periodo.csv','r','utf-8') as f: for line in f: try: csv = line.split(',') text = csv[7] hashtags=re.findall(u"#([áéíóúÁÉÍÓÚñÑA-Za-z0-9_]+)",text,re.U) for ht in hashtags: print '#'+ht except Exception: pass
@abxda
![Page 75: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/75.jpg)
Prepara archivo para Wordle
cat hashtagsMundial.txt | sort | uniq -c | sort -n | awk -F' ' '{print $2 ":" $1}' > wordleMun.txt
#NED:8313#MundialBrasil2014:8777#VamosMexico:8947#BRA:10098#CallMeCam:14531#ARG:15663#Brasil2014:16428#GER:18030#MEX:34035
http://www.wordle.net/
@abxda
![Page 76: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/76.jpg)
¿Qué pasó entre el 12 de junio y el 13 de julio?
http://www.wordle.net/ @abxda
![Page 77: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/77.jpg)
¿Qué pasó el 23 de junio?
@abxda
![Page 78: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/78.jpg)
¿Qué pasó el 29 de junio?
@abxda
![Page 79: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/79.jpg)
¿Con qué tuiteamos?
@abxda
![Page 80: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/80.jpg)
¿A qué hora tuiteamos?
0:00 1:00 2:00 3:00 4:00 5:00 6:00 7:00 8:00 9:00 10:00 11:00 12:00 13:00 14:00 15:00 16:00 17:00 18:00 19:00 20:00 21:00 22:00 23:00
@abxda
![Page 81: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/81.jpg)
¿Qué tuiteamos?
@abxda
![Page 82: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/82.jpg)
¿Cómo nos desplazamos mientras
tuiteamos?
@abxda
![Page 83: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/83.jpg)
Gráfica de Movilidad
library(circlize)testados = read.table("/abxda/TransladosConDFMexMUNICIPAL.csv", sep=";", header=TRUE, stringsAsFactors = FALSE, quote = "" )
m = table(testados$estadoorigen, testados$estadodestino)states = union(rownames(m), colnames(m))circos.clear()par(mar = c(1, 1, 1, 1))chordDiagram(m, directional = TRUE, transparency = 0.3,annotationTrack = "grid", annotationTrackHeight = 0.01, preAllocateTracks = 1)
for(si in get.all.sector.index()) { xlim = get.cell.meta.data("xlim", sector.index = si, track.index = 1) ylim = get.cell.meta.data("ylim", sector.index = si, track.index = 1) circos.text(mean(xlim), ylim[1], si, facing = "clockwise", adj = c(0, 0.5), niceFacing = TRUE, cex = 0.9, col = "black", sector.index = si, track.index = 1)}
http://cran.r-project.org/web/packages/circlize/vignettes/circlize.pdf @abxda
![Page 84: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/84.jpg)
@abxda
![Page 85: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/85.jpg)
R
https://twitter.com/abxda/status/527937889624027136 @abxda
![Page 86: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/86.jpg)
Paquetes de R
http://www.jottr.org/2014/10/milestone-6000-packages-on-cran.html @abxda
![Page 87: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/87.jpg)
Paquetes de R
![Page 88: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/88.jpg)
Municipios donde más se tuitea.
@abxda
![Page 89: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/89.jpg)
BIENESTAR SUBJETIVO
Cuando se habla de Bienestar se trata de determinar si una persona cuenta con determinados satisfactores y si puede ejercer capacidades fundamentales del ser humano.
Significa que el bienestar no es sólo una mera propiedad o conjunto de propiedades que un analista o un experto puede atribuir a objetos de medición, sino también una condición o estado experimentado por sujetos quienes algo tienen qué decir al respecto.
¿SUBJETIVO?
@abxda
![Page 90: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/90.jpg)
ANTECEDENTESConferencia Latinoamericana para la Medición del Bienestar y la Promoción del Progreso de las SociedadesCd. de México del 11 al 13 de mayo de 2011
BIARE Bienestar Autorreportado
@abxda
![Page 91: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/91.jpg)
Twitter-Bienestar Subjetivo.
http://cienciadedatos.inegi.org.mx/pioanalisis
Para generar nuestro conjunto de entrenamiento se desarrolló una aplicación para calificar el sentimiento de los tuits en positivo, negativo o neutro, y clasificarlos en varios temas.
@abxda
@hbcolectivo @ricardoaolvera
![Page 92: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/92.jpg)
CONOCIENDO A PIO
@hbcolectivo @ricardoaolvera
@abxda
![Page 93: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/93.jpg)
Tecnologías Involucradas
{ JSON }
D3.js Librería JavaScript para creación de los gráficos vectoriales interactivos.
Librería JavaScript facilita la incorporación del patrón MVC en aplicaciones web de una sola página.
Diseño de estructura de la página y habilitación responsiva via Twitter Bootstrap.
JSON formato de intercambio de datos.
Web Api 2 / Interface REST
@abxda
![Page 94: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/94.jpg)
Tecnologías Involucradas
{ JSON }
D3.js Librería JavaScript para creación de los gráficos vectoriales interactivos.
Librería JavaScript facilita la incorporación del patrón MVC en aplicaciones web de una sola página.
Diseño de estructura de la página y habilitación responsiva via Twitter Bootstrap.
JSON formato de intercambio de datos.
Web Api 2 / Interface REST
http://www.mono-project.com/ @abxda
![Page 95: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/95.jpg)
Arquitectura MVCen el Navegador
https://angularjs.org/
@abxda
![Page 96: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/96.jpg)
RESPONSIVE DESIGN
@abxda@hbcolectivo
![Page 97: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/97.jpg)
http://getbootstrap.com/
@abxda
![Page 99: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/99.jpg)
@hbcolectivo @ricardoaolvera @abxda
![Page 100: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/100.jpg)
http://cienciadedatos.inegi.org.mx/pioanalisis
@hbcolectivo @ricardoaolvera
@abxda
![Page 101: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/101.jpg)
RESULTADOS
@hbcolectivo @ricardoaolvera
@abxda
![Page 102: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/102.jpg)
Twitter-Bienestar Subjetivo.
• Estructura del tuit• Disponibilidad• aleatorización • filtros
georreferenciados
Estudio en otros países
“Análisis de sentimiento” Universidad de Pensilvania
“Mood of the Nation” de los Británicos
“Big Data and Official Statistics” de los Holandeses
“Taller de Análisis de Sentimiento 2013” de la SEPLN
Métodos de clasificación
Naive Bayes, Support Vector Machines (SVM)
KNN
Word Count
Listas de Palabras y diccionarios utilizados en los ejercicios de análisis de sentimientos
Spanish Emotion Lexicon (SEL)KNN
AFINN
WordNet
ANEW
Fuente de datos
@abxda
![Page 103: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/103.jpg)
Estudios de movilidad. Exploración para el desarrollo de una metodología de análisis para medir la movilidad transfronteriza con los tuits georreferenciados.
Actividad de los tuiteros en la fronteraAzul =tuiteros de origen EUA
Rojo=tuiteros de origen MX.
Actividad solamente de tuiteros MX
@abxda
![Page 104: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/104.jpg)
Actividad solamente de tuiteros MX
@abxda
![Page 105: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/105.jpg)
@abxda
![Page 106: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/106.jpg)
Herramientas
@abxda
D3.js
Spark - MLib
Mahaut
![Page 107: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/107.jpg)
Los Retos:
Infraestructura y Personal
Experto encomputación ydesarrollo avanzados(Functional Programming)
Experto enestadísticamatemática
Experto enel dominio de
datos
CIENCIADE
DATOS
Zonapeligrosa!
Investigacióntradicional
Machinelearning
@abxda
![Page 108: Revelando los secretos de twitter, Festival de Software Libre 2014](https://reader035.fdocumento.com/reader035/viewer/2022062419/558b3424d8b42a49648b46ac/html5/thumbnails/108.jpg)
La tarea• Programación funcionalo Scalao Akka
• Estadísticao Probabilidad y Estadísticao Muestreoo Machine Learningo R
• Almacenes de Datos NoSQLo Cassandrao MongoDBo Hbaseo ElasticSearch
• Plataformas Big Data o Hadoopo Spark
• Visualización de Datoso D3.js
@abxda