zoukankan      html  css  js  c++  java
  • 第一章 学习Scipy 及一个小例子

    为方便,Numpy的所有命名空间都可以通过Scipy访问

    import numpy, scipy
    print scipy.version.full_version
    print scipy.dot is numpy.dot
    
    #0.13.0b1
    #True

    比较常用的scipy工具有stats(统计学工具包)、scipy.interpolate(插值,线性的,三次方的)、cluster(聚类)、signal(信号处理)

    数据读取,使用scipy下的genformtxt(),读取到数据有(743,2)743行2列

    # encoding=utf-8
    import scipy as sp
    data = sp.genfromtxt('web_traffic.tsv', delimiter='	')
    
    # 定义使用	作为分隔符
    print data[:10]
    print data.shape

    预处理和清洗数据

    将各维度分成两个向量

    # 清理无效数据
    x = x[~sp.isnan(y)]
    y = y[~sp.isnan(y)]
    
    # 散点坐标图
    plt.scatter(x, y)
    # x坐标
    plt.xlabel('Time')
    plt.ylabel('Hits/hour')
    # tick 标记号于
    plt.xticks([w*7*24 for w in range(10)],
               ['week %i'%w for w in range(10)])
    # 自动测量/规模 tight=紧
    plt.autoscale(tight=True)
    # 开启网格
    plt.grid()
    # 显示图表
    plt.show()

  • 相关阅读:
    ZIP压缩算法详细分析及解压实例解释
    nyoj 269 VF
    骨牌覆盖问题 KxM
    骨牌覆盖问题
    省赛总结...
    归并排序求逆序对
    「JLOI2014」松鼠的新家
    「JSOI2011」任务调度
    「JSOI2010」找零钱的洁癖
    「JSOI2011」棒棒糖
  • 原文地址:https://www.cnblogs.com/evoler/p/5405722.html
Copyright © 2011-2022 走看看