Construindo Soluções
 Científicas com Big
 Data & MapReduce
      Marcel Caraciolo
      @marcelcaraciolo
Quem é Marcel ?
Sergipano, porém recifense.
Mestre em Ciência da Computação

Co-founder Pingmind & PyCursos
Cientista-Chefe do Atepassar.com

Evangelista Python, programador e admirador das “ciências ocultas”
providas pela Inteligência Artificial

Escritor de blog:
http://www.mobideia.com & http://aimotion.blogspot.com
Antes da Computação Da
Computação Distribuída
Depois da Computação Da
 Computação Distribuída
Big Data, muitos dados.
         !"#$%"$#&'(')")(     !"#$%&'(%$)*%+%),-+.),#$$)
                              *#/(#*)01.#2%03)




                  *$+,(!"#$%"$#&'(')")(

                            !4'1-%$)*%+%5)6$'70)5)1$-18)0+9#%25)
                            :%1.-(#)7#(#9%+#*5);2$)#+1<3)
!"#$%&'(')*"+$#"''
                        !"#$%*(.-.%'7/,(
                !"#$%$&'(        500%6&'216%./7%!.281&%0#.(1%

,"-./%('-0"&12%3/&124.(1% <$8(=.&.( )*+,"-.%(/%"01(
         !"#$%&'"()%*+%                                ;-(5*5"+'(/"5607-8(
                              91:.-/*1(9-.%'7/,(
         9211/%7.&.%(1/&21%         <#.6)%!1-'2=%
                                                    :'(3.#%AB!%
                               :'#37%6&.&1%723;1%
                                                    ,>!?@%
                    2"-&*3&(.4.+*(/"5607-8(
!"#$%&'()#*+$
$
,-.#(''/$
$
     $011$*2))2'3$-.45#$67#&7$-7$'8$9-&."$:;<:=$
     $<$23$>$?3@#&3#@$67#&7$"-5#$-$,-.#(''/$
     $-..'63@$
     $$
     $9'&#$@"-3$>;$(2))2'3$A2#.#7$'8$.'3@#3@$BC#($
     $)23/7=$3#C7$7@'&2#7=$()'D$A'7@7=$3'@#7=$A"'@'$
     $-)(6*7=$#@.EF$7"-&#G$#-."$*'3@"E$
$
     $H')G7$>;%I$'8$G-@-$8'&$-3-)J727=$-GG7$<:$!I$'8$
     $.'*A&#77#G$G-@-$G-2)J$
"<&!B',:+&*C!

!"#$%&'!
!
     !())!*$++$,-!./&'/0!12)!*$++$,-!34$+5!6#&&6/!
     !789!:$++$,-!/&4';<!=.&'$&/!4!345!
     !>!"?!3464!@,'!4-4+5/$/!A&-&'46&3!34$+5!
     !!
"<&!B',:+&*C!

!"#$%&'!
!
     !())!*$++$,-!./&'/0!12)!*$++$,-!34$+5!6#&&6/!
     !789!:$++$,-!/&4';<!=.&'$&/!4!345!
     !>!"?!3464!@,'!4-4+5/$/!A&-&'46&3!34$+5!
     !!
>,$!F(-G7$4H!

!"#$%&''&(!
!
     !)*+!#,-.'&/0!.'$('1!!2++!#,-.'&/0!3#$4'!
     !5$6-44$/0!3#$4'!0&378!9-(!!*+++!.'$('!
     !):!;<!0&#&!9-(!&/&78'3'!=$/$(&#$0!0&378!
     !!


  >(&03?-/&7!0&#&!'#-(&=$1!#$6,/3@.$'!A!&/&78'3'!
  #--7'!B.'#!0-!/-#!C-(D!&#!#,$'$!'6&7$'!E!
  !
!"#$%&'&$%"()*+",*+$-./0$




              $
            12)       .,12()$$




                                  .&
          .&




                                    12)
                                      $
                  .&3"'4$ .)1,5"'4$
Hadoop
!"#$%&'%(#)**+%,%


 !"#$%&"#'()*'(+(%"(&"#'(,-.%/#-/0,#'12,'
 "(,3#'4-("#'*%4/,%&0/#*'-#$."'5,2-#44%)3'
 2)'(')#/62,7'21'-2882*%/9'.(,*6(,#:'
!"#$%&'()"'*&+&*'",)-&$('
              !"#$%%!&'((#)&#&*!+)(,-%.

                  .//'$)0(,123(),4'

5('%#4')0&')6'(%&'4(,)07&4('&$)'484(&94':1(%'*#,7&'0)')6'432'",)-&$(4'

       ;#%))'%#4')0&')6'(%&'2177&4('104(#**#<)0'=#>))"'
       ?300107'@///4')6'4&,+&,4')0'=#>))"'
!"#$%&'()*+),)


   !"##$%&'"()'*'+,-'.&/01&'*'23$'4,5%&6'
   '
         '78193:&1:08&'5&93;/'"##$%&<='
   '''''
         '    ')&,819'>;$3;&'


        -&'./0&)01)2.(00$)$&03'4/)
!"#$%&"#"$'$()&*$+"$,&-../$0"#-$1.2$

    3+456.%+&7$-&*&$&8&79"+"$
    :#;*$<+8+84=$/&>#28"$"#&2%)$
    ?&%)+8#$7.4$&8&79"+"$
    @#.A"/&%+B&7$&8&79"+"$
    :2#8-$C8&79"+"$
    @#8.<#$C8&79"+"$
    D204$D+"%.E#29$
    F2&0-$&8-$%.</7+&8%#$<&8&4#<#8*$
    G+-#.$&8-$+<&4#$&8&79"+"$
!"#$%&'&$()*##+$,$-#./$-0&1$

2$34)5#.637$$
2$8)9':##;$$
2$<##/-'$$
2$=>?$$
2$@0&.'A$
2$B)&1CD4$$
2$E'F$G#H;$I04'&$$
2$G)"##J$$
2$IF0K'H$
2$B0.;'*$0.$$
$$
$
!"#$$%&'($)*)+',&-&


                         <;;=%%(%:&


      /?+@%&                A;B5%&                  C25::&


       12+34#&                96:;&             0>;;(&


                 !56%&                       758&


               !"#$%&                 '#()%*+,%-!./0&
!"#$$%&#'()*'+,-$.&/&
!"#$%&'(&




                                    !""#




            $%&'()*+&,#-&.&/&010#
!"#$%&'()&&
                      !""#




              !"#$$%&#'()*'+,)-#&./-&(0()-1&
!"#$$%&'$(%$)*)+,&-&

!89:&&&&
5"%&6*#71*&
.$/&+0"12*0&
3",2&30"12*0&
4"(*&4$#*&
MapReduce




http://labs.google.com/papers/mapreduce.html
Exemplo de MapReduce
  from mrjob.job import MRJob
  import re

  WORD_RE = re.compile(r"[w']+")

  class MRWordFreqCount(MRJob):

      def mapper(self, _, line):
          for word in WORD_RE.findall(line):
              yield (word.lower(), 1)

      def reducer(self, word, counts):
          yield (word, sum(counts))

  if __name__ == '__main__':
      MRWordFreqCount().run()
Projeto MrJob
      Criado pela Equipe de Engenharia do Yelp

             Totalmente Open-Source

                 Todo em Python

      Utiliza Map-Reduce para Processamento

Permite rodar tanto no Amazon EMR como no Hadoop
Objetivos do MrJobs
 Se você quer aprender MapReduce, ele é para você

Se você tem um problema cavalar e precisa de muito
processamento e não está afim de mexer em Hadoop

Se você já tem um cluster Hadoop e quer rodar scripts
                       Python

 Se você quer migrar seu código Python do Hadoop
                    para o EMR

Se você não quer escrever Python (Impossível!), não é
                     para você!
Passos importantes


 sudo easy_install mrjob
Vamos a uma demo...




Texto da posse de Obama em 2009.
Desempenho MapReduce
Mais informações




http://packages.python.org/mrjob/

  https://github.com/Yelp/mrjob
Distributed Computing with mrJob
                                         https://github.com/Yelp/mrjob

Elsayed et al: Pairwise Document Similarity in Large Collections with MapReduce
Distributed Computing with mrJob
                                         https://github.com/Yelp/mrjob

Elsayed et al: Pairwise Document Similarity in Large Collections with MapReduce
Atepassar Recommendations
                 http://atepassar.com




Problema: Como recomendar novos amigos ?
Atepassar Recommendations
        http://atepassar.com
Atepassar Recommendations
                                      http://atepassar.com




marcel;jonas,maria,jose,amanda                  "marcel" [["carol", 2], ["fabio", 1], ["fabiola", 1], ["patricia", 1], ["paula", 1]]
maria;carol,fabiola,amanda,marcel               "maria" [["jose", 2], ["patricia", 2], ["jonas", 1], ["paula", 1]]
amanda;paula,patricia,maria,marcel              "patricia" [["maria", 2], ["jose", 1], ["marcel", 1], ["paula", 1]]
carol;maria,jose,patricia                       "paula" [["jonas", 1], ["marcel", 1], ["maria", 1], ["patricia", 1]]
fabiola;maria                                   "amanda" [["carol", 2], ["fabio", 1], ["fabiola", 1], ["jonas", 1], ["jose", 1]]
paula;fabio,amanda                              "carol" [["amanda", 2], ["marcel", 2], ["fabiola", 1]]
patricia;amanda,carol                           "fabio" [["amanda", 1], ["marcel", 1]]
jose;marcel,carol                               "fabiola" [["amanda", 1], ["carol", 1], ["marcel", 1]]
jonas;marcel,fabio                              "jonas" [["amanda", 1], ["jose", 1], ["maria", 1], ["paula", 1]]
fabio;jonas,paula                               "jose" [["maria", 2], ["amanda", 1], ["jonas", 1], ["patricia", 1]]
carla




   $python friends_recommender.py - r emr --num-ec2-instances 5 facebook_data.csv > output.dat
Atepassar Recommendations
                                                    http://atepassar.com




marcel;jonas,maria,jose,amanda                                    "marcel" [["carol", 2], ["fabio", 1], ["fabiola", 1], ["patricia", 1], ["paula", 1]]
maria;carol,fabiola,amanda,marcel                                 "maria" [["jose", 2], ["patricia", 2], ["jonas", 1], ["paula", 1]]
amanda;paula,patricia,maria,marcel                                "patricia" [["maria", 2], ["jose", 1], ["marcel", 1], ["paula", 1]]
carol;maria,jose,patricia
fabiola;maria
                                     marcel;jonas,maria,jose,amanda 1], ["patricia", 1]]
                                                    "paula" [["jonas", 1], ["marcel", 1], ["maria",
                                                    "amanda" [["carol", 2], ["fabio", 1], ["fabiola", 1], ["jonas", 1], ["jose", 1]]
paula;fabio,amanda                   carol;maria,jose,patricia ["marcel", 2], ["fabiola", 1]]
                                                    "carol" [["amanda", 2],
patricia;amanda,carol
jose;marcel,carol
                                     fabio;jonas,paula [["amanda", 1], ["marcel", 1]]
                                                    "fabio"
                                                    "fabiola" [["amanda", 1], ["carol", 1], ["marcel", 1]]
jonas;marcel,fabio                   ...            "jonas" [["amanda", 1], ["jose", 1], ["maria", 1], ["paula", 1]]
fabio;jonas,paula                                                 "jose" [["maria", 2], ["amanda", 1], ["jonas", 1], ["patricia", 1]]
carla




   $python friends_recommender.py - r emr --num-ec2-instances 5 facebook_data.csv > output.dat
Atepassar Recommendations
                  http://atepassar.com




       fsim(u,i) = w1 f1(u,i) + w2 f2(u,i) + b,

https://gist.github.com/3970945#file_atepassar_recommender.py
Atepassar Recommendations
                      http://atepassar.com


Celery - para agendamento dos jobs coletores e
                  executores.
mrJob - para mapreduce e acesso ao Hadoop
MongoDb - para armazenamento das recomendações
Boto - acesso aos files do S3.
Benchmarks

                                   Pure Python          Python w/ Scipy MapReduce
       Dataset
                                     w/ dicts             and Numpy     (100 nodes small)

   MovieLens
                                     ~28 hrs                ~12hrs           ~= 5 hrs
     100k
http://www.grouplens.org/node/73


                                   Pure python - Crab           Crab Scipy Numpy
                                   Crab w/ MapReduce
Benchmarks

                                        Pure Python          Python w/ Scipy MapReduce
            Dataset
                                          w/ dicts             and Numpy     (100 nodes small)

        MovieLens
                                          ~28 hrs                ~12hrs              ~= 5 hrs
          100k
     http://www.grouplens.org/node/73


                                        Pure python - Crab           Crab Scipy Numpy
                                        Crab w/ MapReduce



Time ellapsed ( Top-N similar items)



                                              0         7.5         15        22.5       30
Benchmarks

                                        Pure Python          Python w/ Scipy MapReduce
            Dataset
                                          w/ dicts             and Numpy     (100 nodes small)

        MovieLens
                                          ~28 hrs                ~12hrs              ~= 5 hrs
          100k
     http://www.grouplens.org/node/73


                                        Pure python - Crab           Crab Scipy Numpy
                                        Crab w/ MapReduce



Time ellapsed ( Top-N similar items)



                                              0         7.5         15        22.5       30
Benchmarks

                                        Pure Python          Python w/ Scipy MapReduce
            Dataset
                                          w/ dicts             and Numpy     (100 nodes small)

        MovieLens
                                          ~28 hrs                ~12hrs              ~= 5 hrs
          100k
     http://www.grouplens.org/node/73


                                        Pure python - Crab           Crab Scipy Numpy
                                        Crab w/ MapReduce



Time ellapsed ( Top-N similar items)



                                              0         7.5         15        22.5       30
Benchmarks

                                        Pure Python          Python w/ Scipy MapReduce
            Dataset
                                          w/ dicts             and Numpy     (100 nodes small)

        MovieLens
                                          ~28 hrs                ~12hrs              ~= 5 hrs
          100k
     http://www.grouplens.org/node/73


                                        Pure python - Crab           Crab Scipy Numpy
                                        Crab w/ MapReduce



Time ellapsed ( Top-N similar items)



                                              0         7.5         15        22.5       30
A melhor parte!
Projetos interessantes


             Pandas: a data analysis library for Python,
     poised to give R a run for its money… http://pandas.pydata.org/



Estrutura de dados para manipulação rápida
   - slicing
   - indexing
   - subseting

Handling missing data
Agregações, Séries Temporais
Projetos interessantes

              http://discoproject.org/
Outro framework para computação distribuída com
Python com MapReduce.

Criado pelo Instituto Nokia.

Backend dele é escrito em Erlang (funcional,
concorrente e bem escalável!)

Não utiliza o FileSystem mais usado HDFS e sim um
novo padrão por eles (DDFS).
Projetos interessantes
Python & MongoDb
     http://api.mongodb.org/python/2.0/examples/
                   map_reduce.html
 MongoDb - Banco de Dados Não relacional (NoSQL)
 Possui suporte nativo built-in para fazer MapReduce.
 Escrever o código em JS e não é muito legível e fica preso ao
 Mongo ...
                 >>> reduce = Code("function (key, values) {"
                 ...               " var total = 0;"
                 ...               " for (var i = 0; i < values.length; i++) {"
                 ...               "    total += values[i];"
                 ...               " }"
                 ...               " return total;"
                 ...               "}")
Projetos interessantes
Dumbo

https://github.com/klbostee/dumbo/wiki/Short-tutorial

Uma das primeiras bibliotecas em cima do
MapReduce e Python.
Complicado para começar e está desatualizada :(
Projetos interessantes


  http://pydoop.sourceforge.net/docs/index.html


Um wrapper em Python em cima do Hadoop
para computação distribuída.

Legal, mas dá um trabalho para configurar.
Projetos interessantes

https://developers.google.com/appengine/docs/python/
                    dataprocessing/


 Mapreduce com Python na Google AppEngine

 Ainda experimental e fica “preso” à plataforma
 AppEngine.
Projetos interessantes


       http://scikit-learn.org/stable/
Algoritmos de aprendizagem de máquina

Supervisionados & Não supervisionados

Pré-processamento, extração de dados

Avaliação de classificadores, Pipeline,
seleção de atributos.
Projetos interessantes


               http://nltk.org/
Processamento de linguagem natural

Várias ferramentas para tokenização,
pos tagging, named entity recognition,
classificadores, etc.

Vários corpus disponíveis!
Projetos interessantes


                    http://nltk.org/
Processamento de linguagem natural
                              Fiquem de olho...
Várias Pipeline for distributed Natural Language Processing, made in Python
       ferramentas para tokenização,
                  https://github.com/NAMD/pypln
pos tagging, named entity recognition,
classificadores, etc.

Vários corpus disponíveis!
Projetos interessantes
      Our Project’s Home Page




http://muricoca.github.com/crab
Future Releases
Planned Release 0.13
                  New home for python-recsys:
               https://github.com/python-recsys/crab

         New commiters: vinnigracindo, ocelma, fcurella


Planned Release 0.14
 Support to Item-Based Recommenders using MapReduce with MrJob
Join us!

1. Read our Wiki Page
    https://github.com/muricoca/crab/wiki/Developer-Resources

2. Check out our current sprints and open issues
    https://github.com/muricoca/crab/issues

3. Forks, Pull Requests mandatory
4. Join us at irc.freenode.net #muricoca or at our
                     discussion list
                  http://groups.google.com/group/scikit-crab
Vários outros ...
  Numpy
               milk             NetworkX


  Orange
                 Matplotlib

Scipy                         StatsModels
             PyBrain
Livros recomendados
Livros recomendados

                                For free...




http://shop.oreilly.com/product/0636920022640.do?cmp=il-radar-ebooks-big-data-now-radar
Livros recomendados

 For free...


http://infolab.stanford.edu/~ullman/mmds/book.pdf
Artigos recomendados

  For free...
   http://aimotion.blogspot.com.br/2012/10/atepassar-
          recommendations-recommending.html


http://aimotion.blogspot.com.br/2012/08/introduction-to-
               recommendations-with.html
Artigos recomendados

  For free...
   http://aimotion.blogspot.com.br/2012/10/atepassar-
          recommendations-recommending.html

http://aimotion.blogspot.com.br/2012/08/introduction-to-
               recommendations-with.html

          https://github.com/marcelcaraciolo/recsys-mapreduce-mrjob
Construindo Soluções
 Científicas com Big
 Data & MapReduce
       Marcel Caraciolo
       @marcelcaraciolo
     marcel@atepassar.com

Construindo Soluções Científicas com Big Data & MapReduce

  • 1.
    Construindo Soluções Científicascom Big Data & MapReduce Marcel Caraciolo @marcelcaraciolo
  • 2.
    Quem é Marcel? Sergipano, porém recifense. Mestre em Ciência da Computação Co-founder Pingmind & PyCursos Cientista-Chefe do Atepassar.com Evangelista Python, programador e admirador das “ciências ocultas” providas pela Inteligência Artificial Escritor de blog: http://www.mobideia.com & http://aimotion.blogspot.com
  • 3.
    Antes da ComputaçãoDa Computação Distribuída
  • 4.
    Depois da ComputaçãoDa Computação Distribuída
  • 5.
    Big Data, muitosdados. !"#$%"$#&'(')")( !"#$%&'(%$)*%+%),-+.),#$$) *#/(#*)01.#2%03) *$+,(!"#$%"$#&'(')")( !4'1-%$)*%+%5)6$'70)5)1$-18)0+9#%25) :%1.-(#)7#(#9%+#*5);2$)#+1<3)
  • 6.
    !"#$%&'(')*"+$#"'' !"#$%*(.-.%'7/,( !"#$%$&'( 500%6&'216%./7%!.281&%0#.(1% ,"-./%('-0"&12%3/&124.(1% <$8(=.&.( )*+,"-.%(/%"01( !"#$%&'"()%*+% ;-(5*5"+'(/"5607-8( 91:.-/*1(9-.%'7/,( 9211/%7.&.%(1/&21% <#.6)%!1-'2=% :'(3.#%AB!% :'#37%6&.&1%723;1% ,>!?@% 2"-&*3&(.4.+*(/"5607-8(
  • 7.
    !"#$%&'()#*+$ $ ,-.#(''/$ $ $011$*2))2'3$-.45#$67#&7$-7$'8$9-&."$:;<:=$ $<$23$>$?3@#&3#@$67#&7$"-5#$-$,-.#(''/$ $-..'63@$ $$ $9'&#$@"-3$>;$(2))2'3$A2#.#7$'8$.'3@#3@$BC#($ $)23/7=$3#C7$7@'&2#7=$()'D$A'7@7=$3'@#7=$A"'@'$ $-)(6*7=$#@.EF$7"-&#G$#-."$*'3@"E$ $ $H')G7$>;%I$'8$G-@-$8'&$-3-)J727=$-GG7$<:$!I$'8$ $.'*A&#77#G$G-@-$G-2)J$
  • 8.
    "<&!B',:+&*C! !"#$%&'! ! !())!*$++$,-!./&'/0!12)!*$++$,-!34$+5!6#&&6/! !789!:$++$,-!/&4';<!=.&'$&/!4!345! !>!"?!3464!@,'!4-4+5/$/!A&-&'46&3!34$+5! !!
  • 9.
    "<&!B',:+&*C! !"#$%&'! ! !())!*$++$,-!./&'/0!12)!*$++$,-!34$+5!6#&&6/! !789!:$++$,-!/&4';<!=.&'$&/!4!345! !>!"?!3464!@,'!4-4+5/$/!A&-&'46&3!34$+5! !!
  • 10.
    >,$!F(-G7$4H! !"#$%&''&(! ! !)*+!#,-.'&/0!.'$('1!!2++!#,-.'&/0!3#$4'! !5$6-44$/0!3#$4'!0&378!9-(!!*+++!.'$('! !):!;<!0&#&!9-(!&/&78'3'!=$/$(&#$0!0&378! !! >(&03?-/&7!0&#&!'#-(&=$1!#$6,/3@.$'!A!&/&78'3'! #--7'!B.'#!0-!/-#!C-(D!&#!#,$'$!'6&7$'!E! !
  • 11.
    !"#$%&'&$%"()*+",*+$-./0$ $ 12) .,12()$$ .& .& 12) $ .&3"'4$ .)1,5"'4$
  • 12.
  • 13.
  • 14.
    !"#$%&'()"'*&+&*'",)-&$(' !"#$%%!&'((#)&#&*!+)(,-%. .//'$)0(,123(),4' 5('%#4')0&')6'(%&'4(,)07&4('&$)'484(&94':1(%'*#,7&'0)')6'432'",)-&$(4' ;#%))'%#4')0&')6'(%&'2177&4('104(#**#<)0'=#>))"' ?300107'@///4')6'4&,+&,4')0'=#>))"'
  • 15.
    !"#$%&'()*+),) !"##$%&'"()'*'+,-'.&/01&'*'23$'4,5%&6' ' '78193:&1:08&'5&93;/'"##$%&<=' ''''' ' ')&,819'>;$3;&' -&'./0&)01)2.(00$)$&03'4/)
  • 16.
    !"#$%&"#"$'$()&*$+"$,&-../$0"#-$1.2$ 3+456.%+&7$-&*&$&8&79"+"$ :#;*$<+8+84=$/&>#28"$"#&2%)$ ?&%)+8#$7.4$&8&79"+"$ @#.A"/&%+B&7$&8&79"+"$ :2#8-$C8&79"+"$ @#8.<#$C8&79"+"$ D204$D+"%.E#29$ F2&0-$&8-$%.</7+&8%#$<&8&4#<#8*$ G+-#.$&8-$+<&4#$&8&79"+"$
  • 17.
  • 18.
    !"#$$%&'($)*)+',&-& <;;=%%(%:& /?+@%& A;B5%& C25::& 12+34#& 96:;& 0>;;(& !56%& 758& !"#$%& '#()%*+,%-!./0&
  • 19.
  • 20.
    !"#$%&'(& !""# $%&'()*+&,#-&.&/&010#
  • 21.
    !"#$%&'()&& !""# !"#$$%&#'()*'+,)-#&./-&(0()-1&
  • 22.
  • 23.
  • 24.
    Exemplo de MapReduce from mrjob.job import MRJob import re WORD_RE = re.compile(r"[w']+") class MRWordFreqCount(MRJob): def mapper(self, _, line): for word in WORD_RE.findall(line): yield (word.lower(), 1) def reducer(self, word, counts): yield (word, sum(counts)) if __name__ == '__main__': MRWordFreqCount().run()
  • 25.
    Projeto MrJob Criado pela Equipe de Engenharia do Yelp Totalmente Open-Source Todo em Python Utiliza Map-Reduce para Processamento Permite rodar tanto no Amazon EMR como no Hadoop
  • 26.
    Objetivos do MrJobs Se você quer aprender MapReduce, ele é para você Se você tem um problema cavalar e precisa de muito processamento e não está afim de mexer em Hadoop Se você já tem um cluster Hadoop e quer rodar scripts Python Se você quer migrar seu código Python do Hadoop para o EMR Se você não quer escrever Python (Impossível!), não é para você!
  • 27.
    Passos importantes sudoeasy_install mrjob
  • 28.
    Vamos a umademo... Texto da posse de Obama em 2009.
  • 29.
  • 30.
  • 31.
    Distributed Computing withmrJob https://github.com/Yelp/mrjob Elsayed et al: Pairwise Document Similarity in Large Collections with MapReduce
  • 32.
    Distributed Computing withmrJob https://github.com/Yelp/mrjob Elsayed et al: Pairwise Document Similarity in Large Collections with MapReduce
  • 33.
    Atepassar Recommendations http://atepassar.com Problema: Como recomendar novos amigos ?
  • 34.
    Atepassar Recommendations http://atepassar.com
  • 35.
    Atepassar Recommendations http://atepassar.com marcel;jonas,maria,jose,amanda "marcel" [["carol", 2], ["fabio", 1], ["fabiola", 1], ["patricia", 1], ["paula", 1]] maria;carol,fabiola,amanda,marcel "maria" [["jose", 2], ["patricia", 2], ["jonas", 1], ["paula", 1]] amanda;paula,patricia,maria,marcel "patricia" [["maria", 2], ["jose", 1], ["marcel", 1], ["paula", 1]] carol;maria,jose,patricia "paula" [["jonas", 1], ["marcel", 1], ["maria", 1], ["patricia", 1]] fabiola;maria "amanda" [["carol", 2], ["fabio", 1], ["fabiola", 1], ["jonas", 1], ["jose", 1]] paula;fabio,amanda "carol" [["amanda", 2], ["marcel", 2], ["fabiola", 1]] patricia;amanda,carol "fabio" [["amanda", 1], ["marcel", 1]] jose;marcel,carol "fabiola" [["amanda", 1], ["carol", 1], ["marcel", 1]] jonas;marcel,fabio "jonas" [["amanda", 1], ["jose", 1], ["maria", 1], ["paula", 1]] fabio;jonas,paula "jose" [["maria", 2], ["amanda", 1], ["jonas", 1], ["patricia", 1]] carla $python friends_recommender.py - r emr --num-ec2-instances 5 facebook_data.csv > output.dat
  • 36.
    Atepassar Recommendations http://atepassar.com marcel;jonas,maria,jose,amanda "marcel" [["carol", 2], ["fabio", 1], ["fabiola", 1], ["patricia", 1], ["paula", 1]] maria;carol,fabiola,amanda,marcel "maria" [["jose", 2], ["patricia", 2], ["jonas", 1], ["paula", 1]] amanda;paula,patricia,maria,marcel "patricia" [["maria", 2], ["jose", 1], ["marcel", 1], ["paula", 1]] carol;maria,jose,patricia fabiola;maria marcel;jonas,maria,jose,amanda 1], ["patricia", 1]] "paula" [["jonas", 1], ["marcel", 1], ["maria", "amanda" [["carol", 2], ["fabio", 1], ["fabiola", 1], ["jonas", 1], ["jose", 1]] paula;fabio,amanda carol;maria,jose,patricia ["marcel", 2], ["fabiola", 1]] "carol" [["amanda", 2], patricia;amanda,carol jose;marcel,carol fabio;jonas,paula [["amanda", 1], ["marcel", 1]] "fabio" "fabiola" [["amanda", 1], ["carol", 1], ["marcel", 1]] jonas;marcel,fabio ... "jonas" [["amanda", 1], ["jose", 1], ["maria", 1], ["paula", 1]] fabio;jonas,paula "jose" [["maria", 2], ["amanda", 1], ["jonas", 1], ["patricia", 1]] carla $python friends_recommender.py - r emr --num-ec2-instances 5 facebook_data.csv > output.dat
  • 37.
    Atepassar Recommendations http://atepassar.com fsim(u,i) = w1 f1(u,i) + w2 f2(u,i) + b, https://gist.github.com/3970945#file_atepassar_recommender.py
  • 38.
    Atepassar Recommendations http://atepassar.com Celery - para agendamento dos jobs coletores e executores. mrJob - para mapreduce e acesso ao Hadoop MongoDb - para armazenamento das recomendações Boto - acesso aos files do S3.
  • 39.
    Benchmarks Pure Python Python w/ Scipy MapReduce Dataset w/ dicts and Numpy (100 nodes small) MovieLens ~28 hrs ~12hrs ~= 5 hrs 100k http://www.grouplens.org/node/73 Pure python - Crab Crab Scipy Numpy Crab w/ MapReduce
  • 40.
    Benchmarks Pure Python Python w/ Scipy MapReduce Dataset w/ dicts and Numpy (100 nodes small) MovieLens ~28 hrs ~12hrs ~= 5 hrs 100k http://www.grouplens.org/node/73 Pure python - Crab Crab Scipy Numpy Crab w/ MapReduce Time ellapsed ( Top-N similar items) 0 7.5 15 22.5 30
  • 41.
    Benchmarks Pure Python Python w/ Scipy MapReduce Dataset w/ dicts and Numpy (100 nodes small) MovieLens ~28 hrs ~12hrs ~= 5 hrs 100k http://www.grouplens.org/node/73 Pure python - Crab Crab Scipy Numpy Crab w/ MapReduce Time ellapsed ( Top-N similar items) 0 7.5 15 22.5 30
  • 42.
    Benchmarks Pure Python Python w/ Scipy MapReduce Dataset w/ dicts and Numpy (100 nodes small) MovieLens ~28 hrs ~12hrs ~= 5 hrs 100k http://www.grouplens.org/node/73 Pure python - Crab Crab Scipy Numpy Crab w/ MapReduce Time ellapsed ( Top-N similar items) 0 7.5 15 22.5 30
  • 43.
    Benchmarks Pure Python Python w/ Scipy MapReduce Dataset w/ dicts and Numpy (100 nodes small) MovieLens ~28 hrs ~12hrs ~= 5 hrs 100k http://www.grouplens.org/node/73 Pure python - Crab Crab Scipy Numpy Crab w/ MapReduce Time ellapsed ( Top-N similar items) 0 7.5 15 22.5 30
  • 44.
  • 45.
    Projetos interessantes Pandas: a data analysis library for Python, poised to give R a run for its money… http://pandas.pydata.org/ Estrutura de dados para manipulação rápida - slicing - indexing - subseting Handling missing data Agregações, Séries Temporais
  • 46.
    Projetos interessantes http://discoproject.org/ Outro framework para computação distribuída com Python com MapReduce. Criado pelo Instituto Nokia. Backend dele é escrito em Erlang (funcional, concorrente e bem escalável!) Não utiliza o FileSystem mais usado HDFS e sim um novo padrão por eles (DDFS).
  • 47.
    Projetos interessantes Python &MongoDb http://api.mongodb.org/python/2.0/examples/ map_reduce.html MongoDb - Banco de Dados Não relacional (NoSQL) Possui suporte nativo built-in para fazer MapReduce. Escrever o código em JS e não é muito legível e fica preso ao Mongo ... >>> reduce = Code("function (key, values) {" ... " var total = 0;" ... " for (var i = 0; i < values.length; i++) {" ... " total += values[i];" ... " }" ... " return total;" ... "}")
  • 48.
    Projetos interessantes Dumbo https://github.com/klbostee/dumbo/wiki/Short-tutorial Uma dasprimeiras bibliotecas em cima do MapReduce e Python. Complicado para começar e está desatualizada :(
  • 49.
    Projetos interessantes http://pydoop.sourceforge.net/docs/index.html Um wrapper em Python em cima do Hadoop para computação distribuída. Legal, mas dá um trabalho para configurar.
  • 50.
    Projetos interessantes https://developers.google.com/appengine/docs/python/ dataprocessing/ Mapreduce com Python na Google AppEngine Ainda experimental e fica “preso” à plataforma AppEngine.
  • 51.
    Projetos interessantes http://scikit-learn.org/stable/ Algoritmos de aprendizagem de máquina Supervisionados & Não supervisionados Pré-processamento, extração de dados Avaliação de classificadores, Pipeline, seleção de atributos.
  • 52.
    Projetos interessantes http://nltk.org/ Processamento de linguagem natural Várias ferramentas para tokenização, pos tagging, named entity recognition, classificadores, etc. Vários corpus disponíveis!
  • 53.
    Projetos interessantes http://nltk.org/ Processamento de linguagem natural Fiquem de olho... Várias Pipeline for distributed Natural Language Processing, made in Python ferramentas para tokenização, https://github.com/NAMD/pypln pos tagging, named entity recognition, classificadores, etc. Vários corpus disponíveis!
  • 54.
    Projetos interessantes Our Project’s Home Page http://muricoca.github.com/crab
  • 55.
    Future Releases Planned Release0.13 New home for python-recsys: https://github.com/python-recsys/crab New commiters: vinnigracindo, ocelma, fcurella Planned Release 0.14 Support to Item-Based Recommenders using MapReduce with MrJob
  • 56.
    Join us! 1. Readour Wiki Page https://github.com/muricoca/crab/wiki/Developer-Resources 2. Check out our current sprints and open issues https://github.com/muricoca/crab/issues 3. Forks, Pull Requests mandatory 4. Join us at irc.freenode.net #muricoca or at our discussion list http://groups.google.com/group/scikit-crab
  • 57.
    Vários outros ... Numpy milk NetworkX Orange Matplotlib Scipy StatsModels PyBrain
  • 58.
  • 59.
    Livros recomendados For free... http://shop.oreilly.com/product/0636920022640.do?cmp=il-radar-ebooks-big-data-now-radar
  • 60.
    Livros recomendados Forfree... http://infolab.stanford.edu/~ullman/mmds/book.pdf
  • 61.
    Artigos recomendados For free... http://aimotion.blogspot.com.br/2012/10/atepassar- recommendations-recommending.html http://aimotion.blogspot.com.br/2012/08/introduction-to- recommendations-with.html
  • 62.
    Artigos recomendados For free... http://aimotion.blogspot.com.br/2012/10/atepassar- recommendations-recommending.html http://aimotion.blogspot.com.br/2012/08/introduction-to- recommendations-with.html https://github.com/marcelcaraciolo/recsys-mapreduce-mrjob
  • 63.
    Construindo Soluções Científicascom Big Data & MapReduce Marcel Caraciolo @marcelcaraciolo marcel@atepassar.com