久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    1. <legend id='YppJj'><style id='YppJj'><dir id='YppJj'><q id='YppJj'></q></dir></style></legend>

      <tfoot id='YppJj'></tfoot>
      • <bdo id='YppJj'></bdo><ul id='YppJj'></ul>
      <i id='YppJj'><tr id='YppJj'><dt id='YppJj'><q id='YppJj'><span id='YppJj'><b id='YppJj'><form id='YppJj'><ins id='YppJj'></ins><ul id='YppJj'></ul><sub id='YppJj'></sub></form><legend id='YppJj'></legend><bdo id='YppJj'><pre id='YppJj'><center id='YppJj'></center></pre></bdo></b><th id='YppJj'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='YppJj'><tfoot id='YppJj'></tfoot><dl id='YppJj'><fieldset id='YppJj'></fieldset></dl></div>

      <small id='YppJj'></small><noframes id='YppJj'>

    2. 帶 MRJob 的多個輸入

      Multiple Inputs with MRJob(帶 MRJob 的多個輸入)
      1. <tfoot id='xB3z6'></tfoot>
            <tbody id='xB3z6'></tbody>

            <bdo id='xB3z6'></bdo><ul id='xB3z6'></ul>
            • <legend id='xB3z6'><style id='xB3z6'><dir id='xB3z6'><q id='xB3z6'></q></dir></style></legend>
              <i id='xB3z6'><tr id='xB3z6'><dt id='xB3z6'><q id='xB3z6'><span id='xB3z6'><b id='xB3z6'><form id='xB3z6'><ins id='xB3z6'></ins><ul id='xB3z6'></ul><sub id='xB3z6'></sub></form><legend id='xB3z6'></legend><bdo id='xB3z6'><pre id='xB3z6'><center id='xB3z6'></center></pre></bdo></b><th id='xB3z6'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='xB3z6'><tfoot id='xB3z6'></tfoot><dl id='xB3z6'><fieldset id='xB3z6'></fieldset></dl></div>

                <small id='xB3z6'></small><noframes id='xB3z6'>

              • 本文介紹了帶 MRJob 的多個輸入的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我正在嘗試學習將 Yelp 的 Python API 用于 MapReduce,MRJob.他們簡單的單詞計數器示例很有意義,但我很好奇如何處理涉及多個輸入的應用程序.例如,不是簡單地計算文檔中的單詞,而是將向量乘以矩陣.我想出了這個解決方案,它可以工作,但感覺很傻:

                I'm trying to learn to use Yelp's Python API for MapReduce, MRJob. Their simple word counter example makes sense, but I'm curious how one would handle an application involving multiple inputs. For instance, rather than simply counting the words in a document, multiplying a vector by a matrix. I came up with this solution, which functions, but feels silly:

                class MatrixVectMultiplyTast(MRJob):
                    def multiply(self,key,line):
                            line = map(float,line.split(" "))
                            v,col = line[-1],line[:-1]
                
                            for i in xrange(len(col)):
                                    yield i,col[i]*v
                
                    def sum(self,i,occurrences):
                            yield i,sum(occurrences)
                
                    def steps(self):
                            return [self.mr (self.multiply,self.sum),]
                
                if __name__=="__main__":
                    MatrixVectMultiplyTast.run()
                

                這段代碼是運行 ./matrix.py <input.txt 之所以起作用,是因為矩陣按列存儲在 input.txt 中,相應的向量值位于行尾.

                This code is run ./matrix.py < input.txt and the reason it works is that the matrix stored in input.txt by columns, with the corresponding vector value at the end of the line.

                所以,下面的矩陣和向量:

                So, the following matrix and vector:

                表示為 input.txt 為:

                are represented as input.txt as:

                簡而言之,我將如何將矩陣和向量更自然地存儲在單獨的文件中并將它們都傳遞到 MRJob 中?

                In short, how would I go about storing the matrix and vector more naturally in separate files and passing them both into MRJob?

                推薦答案

                如果您需要針對另一個(或相同的 row_i、row_j)數據集處理原始數據,您可以:

                If you're in need of processing your raw data against another (or same row_i, row_j) data set, you can either:

                1) 創建一個 S3 存儲桶來存儲數據的副本.將此副本的位置傳遞給您的任務類,例如下面代碼中的 self.options.bucket 和 self.options.my_datafile_copy_location .警告:不幸的是,似乎整個文件必須在處理之前下載"到任務機器.如果連接失敗或加載時間過長,此作業可能會失敗.這是一些執行此操作的 Python/MRJob 代碼.

                1) Create an S3 bucket to store a copy of your data. Pass the location of this copy to your task class, e.g. self.options.bucket and self.options.my_datafile_copy_location in the code below. Caveat: Unfortunately, it seems that the whole file must get "downloaded" to the task machines before getting processed. If the connections falters or takes too long to load, this job may fail. Here is some Python/MRJob code to do this.

                把它放在你的映射器函數中:

                Put this in your mapper function:

                d1 = line1.split('	', 1)
                v1, col1 = d1[0], d1[1]
                conn = boto.connect_s3(aws_access_key_id=<AWS_ACCESS_KEY_ID>, aws_secret_access_key=<AWS_SECRET_ACCESS_KEY>)
                bucket = conn.get_bucket(self.options.bucket)  # bucket = conn.get_bucket(MY_UNIQUE_BUCKET_NAME_AS_STRING)
                data_copy = bucket.get_key(self.options.my_datafile_copy_location).get_contents_as_string().rstrip()
                ### CAVEAT: Needs to get the whole file before processing the rest.
                for line2 in data_copy.split('
                '):
                    d2 = line2.split('	', 1)
                    v2, col2 = d2[0], d2[1]
                    ## Now, insert code to do any operations between v1 and v2 (or c1 and c2) here:
                    yield <your output key, value pairs>
                conn.close()
                

                2) 創建一個 SimpleDB 域,并將所有數據存儲在其中.在這里閱讀 boto 和 SimpleDB:http://code.google.com/p/boto/wiki/SimpleDbIntro

                2) Create a SimpleDB domain, and store all of your data in there. Read here on boto and SimpleDB: http://code.google.com/p/boto/wiki/SimpleDbIntro

                您的映射器代碼如下所示:

                Your mapper code would look like this:

                dline = dline.strip()
                d0 = dline.split('	', 1)
                v1, c1 = d0[0], d0[1]
                sdb = boto.connect_sdb(aws_access_key_id=<AWS_ACCESS_KEY>, aws_secret_access_key=<AWS_SECRET_ACCESS_KEY>)
                domain = sdb.get_domain(MY_DOMAIN_STRING_NAME)
                for item in domain:
                    v2, c2 = item.name, item['column']
                    ## Now, insert code to do any operations between v1 and v2 (or c1 and c2) here:
                    yield <your output key, value pairs>
                sdb.close()
                

                如果您有大量數據,第二個選項可能會執行得更好,因為它可以對每一行數據而不是一次全部數據進行請求.請記住,SimpleDB 值的長度最多只能為 1024 個字符,因此如果您的數據值長于此,您可能需要通過某種方法進行壓縮/解壓縮.

                This second option may perform better if you have very large amounts of data, since it can make the requests for each row of data rather than the whole amount at once. Keep in mind that SimpleDB values can only be a maximum of 1024 characters long, so you may need to compress/decompress via some method if your data values are longer than that.

                這篇關于帶 MRJob 的多個輸入的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                python: Two modules and classes with the same name under different packages(python:不同包下同名的兩個模塊和類)
                Configuring Python to use additional locations for site-packages(配置 Python 以使用站點包的其他位置)
                How to structure python packages without repeating top level name for import(如何在不重復導入頂級名稱的情況下構造python包)
                Install python packages on OpenShift(在 OpenShift 上安裝 python 包)
                How to refresh sys.path?(如何刷新 sys.path?)
                Distribute a Python package with a compiled dynamic shared library(分發帶有已編譯動態共享庫的 Python 包)
                  <i id='wZrtS'><tr id='wZrtS'><dt id='wZrtS'><q id='wZrtS'><span id='wZrtS'><b id='wZrtS'><form id='wZrtS'><ins id='wZrtS'></ins><ul id='wZrtS'></ul><sub id='wZrtS'></sub></form><legend id='wZrtS'></legend><bdo id='wZrtS'><pre id='wZrtS'><center id='wZrtS'></center></pre></bdo></b><th id='wZrtS'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='wZrtS'><tfoot id='wZrtS'></tfoot><dl id='wZrtS'><fieldset id='wZrtS'></fieldset></dl></div>

                1. <small id='wZrtS'></small><noframes id='wZrtS'>

                      <tbody id='wZrtS'></tbody>
                      <bdo id='wZrtS'></bdo><ul id='wZrtS'></ul>
                      <tfoot id='wZrtS'></tfoot>
                    • <legend id='wZrtS'><style id='wZrtS'><dir id='wZrtS'><q id='wZrtS'></q></dir></style></legend>
                        • 主站蜘蛛池模板: 国产农村妇女毛片精品久久麻豆 | 天堂免费| 欧美成人视屏 | 大伊人久久| 色久五月 | 国产精品久久久久久久7电影 | 精品国产亚洲一区二区三区大结局 | 中文字幕一区二区三区在线乱码 | 在线观看亚洲专区 | 日韩免费在线观看视频 | 久久久久久亚洲精品不卡 | 欧美视频免费在线观看 | 91久久精品国产91久久 | 国产精品久久久久久久久久久免费看 | 91资源在线 | www.蜜桃av| 一级黄色片一级黄色片 | 国产一二三视频在线观看 | 手机看片1 | a久久 | 欧美美女爱爱视频 | 亚洲一区二区在线免费观看 | 天天插天天操 | 日韩成人在线电影 | 全免一级毛片 | 国产在线观看一区二区 | 国产一区精品 | 国产欧美精品一区二区 | 综合一区 | 免费午夜视频 | 久久国产免费看 | 欧美一级片在线播放 | 久久91 | www国产亚洲精品久久网站 | 欧美一区二区三区视频 | 国产午夜精品一区二区三区嫩草 | 久久久久久久久蜜桃 | 久久国产成人 | 国产成人亚洲精品 | 日韩激情视频一区 | 99久久婷婷国产综合精品 |