资源简介
《贝叶斯思维:统计建模的Python学习法》(Think Bayes)的高清电子书和代码
代码片段和文件信息
“““This file contains code for use with “Think Stats“
by Allen B. Downey available from greenteapress.com
Copyright 2010 Allen B. Downey
License: GNU GPLv3 http://www.gnu.org/licenses/gpl.html
“““
import math
import sys
import survey
import thinkstats
class Respondents(survey.Table):
“““Represents the respondent table.“““
def ReadRecords(self data_dir=‘.‘ n=None):
filename = self.GetFilename()
self.ReadFile(data_dir
filename
self.GetFields()
survey.Respondent
n)
self.Recode()
def GetFilename(self):
“““Get the name of the data file.
This function can be overridden by child classes.
The BRFSS data is available from thinkstats.com/CDBRFS08.ASC.gz
“““
return ‘CDBRFS08.ASC.gz‘
def GetFields(self):
“““Returns a tuple specifying the fields to extract.
BRFSS codebook
http://www.cdc.gov/brfss/technical_infodata/surveydata/2008.htm
The elements of the tuple are field start end case.
field is the name of the variable
start and end are the indices as specified in the NSFG docs
case is a callable that converts the result to int float etc.
“““
return [
(‘age‘ 101 102 int)
(‘weight2‘ 119 122 int)
(‘wtyrago‘ 127 130 int)
(‘wtkg2‘ 1254 1258 int)
(‘htm3‘ 1251 1253 int)
(‘sex‘ 143 143 int)
]
def Recode(self):
“““Recode variables that need cleaning.“““
def CleanWeight(weight):
if weight in [7777 9999]:
return ‘NA‘
elif weight < 1000:
return weight / 2.2
elif 9000 < weight < 9999:
return weight - 9000
else:
return weight
for rec in self.records:
# recode wtkg2
if rec.wtkg2 in [‘NA‘ 99999]:
rec.wtkg2 = ‘NA‘
else:
rec.wtkg2 /= 100.0
# recode wtyrago
rec.weight2 = CleanWeight(rec.weight2)
rec.wtyrago = CleanWeight(rec.wtyrago)
# recode htm3
if rec.htm3 == 999:
rec.htm3 = ‘NA‘
# recode age
if rec.age in [7 9]:
rec.age = ‘NA‘
def SummarizeHeight(self):
“““Print summary statistics for male and female height.“““
# make a dictionary that maps from gender code to list of heights
d = {1:[] 2:[] ‘all‘:[]}
[d[r.sex].append(r.htm3) for r in self.records if r.htm3 != ‘NA‘]
[d[‘all‘].append(r.htm3) for r in self.records if r.htm3 != ‘NA‘]
print ‘Height (cm):‘
print ‘key n mean var sigma cv‘
for key t in d.iteritems():
mu var = thinkstats.TrimmedM
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2374789 2018-01-02 23:12 think bayes.pdf
目录 0 2016-02-23 03:21 ThinkBayes-master\
文件 303 2016-02-23 03:21 ThinkBayes-master\.gitignore
目录 0 2016-02-23 03:21 ThinkBayes-master\book\
文件 4440 2016-02-23 03:21 ThinkBayes-master\book\back.png
文件 330287 2016-02-23 03:21 ThinkBayes-master\book\book.tex
目录 0 2016-02-23 03:21 ThinkBayes-master\book\figs\
文件 25355 2016-02-23 03:21 ThinkBayes-master\book\figs\dungeons1.eps
文件 12370 2016-02-23 03:21 ThinkBayes-master\book\figs\dungeons1.pdf
文件 21019 2016-02-23 03:21 ThinkBayes-master\book\figs\dungeons2.eps
文件 11148 2016-02-23 03:21 ThinkBayes-master\book\figs\dungeons2.pdf
文件 24262 2016-02-23 03:21 ThinkBayes-master\book\figs\dungeons3.eps
文件 10770 2016-02-23 03:21 ThinkBayes-master\book\figs\dungeons3.pdf
文件 20589 2016-02-23 03:21 ThinkBayes-master\book\figs\euro1.eps
文件 10363 2016-02-23 03:21 ThinkBayes-master\book\figs\euro1.pdf
文件 23991 2016-02-23 03:21 ThinkBayes-master\book\figs\euro2.eps
文件 11829 2016-02-23 03:21 ThinkBayes-master\book\figs\euro2.pdf
文件 23968 2016-02-23 03:21 ThinkBayes-master\book\figs\euro3.eps
文件 11636 2016-02-23 03:21 ThinkBayes-master\book\figs\euro3.pdf
文件 29326 2016-02-23 03:21 ThinkBayes-master\book\figs\hockey0.eps
文件 13851 2016-02-23 03:21 ThinkBayes-master\book\figs\hockey0.pdf
文件 29881 2016-02-23 03:21 ThinkBayes-master\book\figs\hockey1.eps
文件 15267 2016-02-23 03:21 ThinkBayes-master\book\figs\hockey1.pdf
文件 20027 2016-02-23 03:21 ThinkBayes-master\book\figs\hockey2.eps
文件 10655 2016-02-23 03:21 ThinkBayes-master\book\figs\hockey2.pdf
文件 23879 2016-02-23 03:21 ThinkBayes-master\book\figs\hockey3.eps
文件 12557 2016-02-23 03:21 ThinkBayes-master\book\figs\hockey3.pdf
文件 27643 2016-02-23 03:21 ThinkBayes-master\book\figs\jaynes1.eps
文件 14127 2016-02-23 03:21 ThinkBayes-master\book\figs\jaynes1.pdf
文件 23929 2016-02-23 03:21 ThinkBayes-master\book\figs\jaynes2.eps
文件 12614 2016-02-23 03:21 ThinkBayes-master\book\figs\jaynes2.pdf
............此处省略201个文件信息
相关资源
- opencv_python-3.3.0-cp35-cp35m-win_amd64.whl
- Python程序设计_车万翔译_课后全部答案
- opencv_python-4.1.0.25-cp37-cp37m-win_amd64.wh
- Python-利用TensorFlow中的深度学习进行图
- python深度学习pdf+源码案例
- simplecv实用机器视觉+OpenCV-Python-Totur
- Python3.7 免安装版
- 冲顶大会/芝士超人/花椒直播...答题助
- Serial assistant.rar
- Python金融大数据分析 完整.pdf版
- 《Python3程序开发指南 Programming in Py
- Introduction to Machine Learning with Python_正
- PYTHON数据可视化编程实战PDF
- python3.4+pywin32 32位
- 深入浅出Python(中文版)
- 阿里云大学马哥python资料.zip
- opencv_python-4.1.2-cp37-cp37m-win_amd64.whl
- Selenium 2自动化测试实战 基于Python语言
- python实现飞机大战
- opencv-python 3.4.3.18
- python开发键盘钢琴源代码及打包程序
- tensorflow-1.10.0-cp27-cp27m-win_amd64.whl
- 黑马程序员Python入门教程讲义及源码
- opencv_python-3.4.2-cp36-cp36m-win_amd64.whl
- Python核心编程(第三版) mobi
- Python深度学习和源代码
- python-3.7.3-amd64.exe 安装包
- 《Python编程 从入门到实践》中文pdf高
- python 2.7-64位_numpy+mkl
- pypy windows 最新版 v5.8.0
评论
共有 条评论