• 大小: 9.95MB
    文件类型: .zip
    金币: 2
    下载: 0 次
    发布日期: 2024-01-25
  • 语言: Python
  • 标签: python  代码  

资源简介

Learning Data Mining With Python book 代码及实例数据

资源截图

代码片段和文件信息

import os
import re
from mrjob.job import MRJob
from mrjob.step import MRStep

word_search_re = re.compile(r“[\w‘]+“)


class ExtractPosts(MRJob):

    post_start = False
    post = []

    def mapper(self key line):
        filename = os.environ[“map_input_file“]
        gender = filename.split(“.“)[1]
        try:
            docnum = int(filename[0])
        except:
            docnum = 8
        if filename.startswith(“51“):
            # remove leading and trailing whitespace
            line = line.strip()
            if line == ““:
                self.post_start = True
            elif line == “
“:
                self.post_start = False
                yield gender repr(“\n“.join(self.post))
                self.post = []
            elif self.post_start:
                self.post.append(line)



if __name__ == ‘__main__‘:
    ExtractPosts.run()

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2016-04-23 11:22  LearningDataMiningWithPython-master\
     文件         764  2016-04-23 11:22  LearningDataMiningWithPython-master\.gitignore
     文件        1112  2016-04-23 11:22  LearningDataMiningWithPython-master\INSTALL.md
     目录           0  2016-04-23 11:22  LearningDataMiningWithPython-master\LearningDataMiningBook\
     目录           0  2016-04-23 11:22  LearningDataMiningWithPython-master\LearningDataMiningBook\Chapter 1\
     文件        1000  2016-04-23 11:22  LearningDataMiningWithPython-master\LearningDataMiningBook\Chapter 1\affinity_dataset.txt
     文件       16777  2016-04-23 11:22  LearningDataMiningWithPython-master\LearningDataMiningBook\Chapter 1\ch1_affinity.ipynb
     文件        3670  2016-04-23 11:22  LearningDataMiningWithPython-master\LearningDataMiningBook\Chapter 1\ch1_affinity_create.ipynb
     文件       13847  2016-04-23 11:22  LearningDataMiningWithPython-master\LearningDataMiningBook\Chapter 1\ch1_oner_application.ipynb
     目录           0  2016-04-23 11:22  LearningDataMiningWithPython-master\LearningDataMiningBook\Chapter 10\
     文件       78925  2016-04-23 11:22  LearningDataMiningWithPython-master\LearningDataMiningBook\Chapter 10\Chapter 10 Clusterer.ipynb
     目录           0  2016-04-23 11:22  LearningDataMiningWithPython-master\LearningDataMiningBook\Chapter 11\
     文件       59206  2016-04-23 11:22  LearningDataMiningWithPython-master\LearningDataMiningBook\Chapter 11\Chapter 11 (CIFAR).ipynb
     文件       62409  2016-04-23 11:22  LearningDataMiningWithPython-master\LearningDataMiningBook\Chapter 11\Chapter 11 (Theano and Lasagne).ipynb
     目录           0  2016-04-23 11:22  LearningDataMiningWithPython-master\LearningDataMiningBook\Chapter 12\
     文件       38759  2016-04-23 11:22  LearningDataMiningWithPython-master\LearningDataMiningBook\Chapter 12\CH12 MapReduce Basics.ipynb
     文件       10578  2016-04-23 11:22  LearningDataMiningWithPython-master\LearningDataMiningBook\Chapter 12\Chapter 12 (NB Predict).ipynb
     文件        1730  2016-04-23 11:22  LearningDataMiningWithPython-master\LearningDataMiningBook\Chapter 12\Chapter 12 (Test load).ipynb
     文件         882  2016-04-23 11:22  LearningDataMiningWithPython-master\LearningDataMiningBook\Chapter 12\extract_posts.py
     文件        1986  2016-04-23 11:22  LearningDataMiningWithPython-master\LearningDataMiningBook\Chapter 12\nb_predict.py
     文件        2021  2016-04-23 11:22  LearningDataMiningWithPython-master\LearningDataMiningBook\Chapter 12\nb_train.py
     目录           0  2016-04-23 11:22  LearningDataMiningWithPython-master\LearningDataMiningBook\Chapter 2\
     文件      143291  2016-04-23 11:22  LearningDataMiningWithPython-master\LearningDataMiningBook\Chapter 2\Ionosphere Nearest Neighbour.ipynb
     目录           0  2016-04-23 11:22  LearningDataMiningWithPython-master\LearningDataMiningBook\Chapter 3\
     文件       45385  2016-04-23 11:22  LearningDataMiningWithPython-master\LearningDataMiningBook\Chapter 3\Basketball Results.ipynb
     目录           0  2016-04-23 11:22  LearningDataMiningWithPython-master\LearningDataMiningBook\Chapter 4\
     文件       46259  2016-04-23 11:22  LearningDataMiningWithPython-master\LearningDataMiningBook\Chapter 4\ch4 Affinity Analysis.ipynb
     目录           0  2016-04-23 11:22  LearningDataMiningWithPython-master\LearningDataMiningBook\Chapter 5\
     文件        1034  2016-04-23 11:22  LearningDataMiningWithPython-master\LearningDataMiningBook\Chapter 5\adult_tests.py
     文件       13293  2016-04-23 11:22  LearningDataMiningWithPython-master\LearningDataMiningBook\Chapter 5\ch5_adult.ipynb
     文件       29985  2016-04-23 11:22  LearningDataMiningWithPython-master\LearningDataMiningBook\Chapter 5\ch5_advertisements.ipynb
............此处省略18个文件信息

评论

共有 条评论