
Python 学习之Data analysis
ywjun的学习笔记
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Monty Hall Problem
import sys import random as rnd #strategy=sys.argv[1]# must be 'stick','choose',or 'switch' def Solve(strategy): wins = 0 for trail in range(100): #The price is always in envelop 0..原创 2013-03-14 20:46:06 · 1233 阅读 · 0 评论 -
Principal Components Analysis(主成分分析法)R中的prcomp
Principal Components Analysis(主成分分析法) Description Performs a principal components analysis on the given data matrix and returns the results as an object of class prcomp.(对给定的数据矩阵执行PCA分析,通过prcomp的一个对原创 2013-03-20 21:40:27 · 12754 阅读 · 0 评论 -
Nearest-Neighbor Classifier紧邻算法分类器(一)
#数据来自UCI Machine Learning知识库的Iris数据集 #紧邻算法,通过计算测试集与训练集上诉特征之间的距离,分类,《Data Analysis with open Source Tools》中没有产生上述图的程序,所以,也模拟了下上述图形,但是暂#时没有平滑效果 from numpy import * import matplotlib.pylab as pl t原创 2013-03-23 12:15:32 · 3386 阅读 · 0 评论 -
Kmedoids
import Pycluster as pc import numpy as np import sys import matplotlib.pylab as pl #Def our distance function :maximum norm def dist(a,b): return max(abs(a-b)) #Read data filename and desired numb原创 2013-03-19 15:51:07 · 3089 阅读 · 1 评论 -
Python K-means使用
import Pycluster as pc import numpy as np import sys import matplotlib.pylab as pl # Read data filename and desired number of clusters from command line filename, n = sys.argv[1], int( sys.argv[2] )原创 2013-03-19 09:07:40 · 7188 阅读 · 0 评论 -
紧邻算法分类器之模拟图(实现模拟)(三)
pl.legend()函数是显示图例,值得注意的是,plot函数,是通过点在坐标中出现的位置直线,如x=(1,4,3),y=(1,5,2),则先连接(1,1)和(4,5),然后连接(3,2)这样会出现杂乱无章的图形,所以,在通过数据库选出坐标后,通过属性从小到大排序,是横坐标的顺序是从小到大的。 显示结果如下: 书上的图: 两图仍有区别,如果要产生下图的形状,要使用函数模原创 2013-03-23 12:38:59 · 995 阅读 · 0 评论 -
紧邻算法分类器之模拟图(二)
首先将数据将文本中的数据导入数据库,因为,对数据库的操作比较熟悉,对以后的数据统计也比较的方便,是通过,计算不同点出现的次数为纵坐标,以特征值为很坐标, 数据仍然是(一)中的数据,值得注意的是:数据库操作后,一定需要语句conn.commit() ,否则会出现,执行后,数据库中没有存储的现象,操作数据库需要pymssql库 具体程序: import pymssql from numpy原创 2013-03-23 12:23:06 · 1082 阅读 · 0 评论 -
贝叶斯分类器(续近邻分类器)
#A Naive Bayesian Classifier total ={} #类训练实例,存储对应类的出现的次数 histo ={} #存储对应类中的对应特征的值得频率 train = open("D:\\iris.trn",'r') for line in train: f = line.rstrip().split(',') label = f.pop(原创 2013-03-25 10:32:20 · 1432 阅读 · 0 评论