Python+Matplotlib+PyQt4做的简单数据预测工具

本文介绍了一款基于Python 2.7、numpy、scipy、matplotlib和PyQt4开发的数据预测工具,用于软件测试中的bug趋势预测。通过曲线拟合方法,用户可输入历史bug数据,自定义初始参数,点击Plot按钮绘制预测曲线。此外,工具还支持计算达到特定问题百分比或天数所需的问题数。

需求:

      在软件测试的bug管理过程中,有时需要知道某一个版本在未来的bug走势(当然不是准确的,只是大概一个估计),如果我们已经有了最近一段时间内的bug统计情况(比如近一个月每天的bug数),可以通过曲线拟合的方式来进行简单的预测。根据这个需要,做了一个方便界面操作的小工具。

代码环境:

代码环境:python2.7 + numpy + scipy + matplotlib + PyQt4
(注意,相关库的版本和位数,要和所安装的python版本和位数保持一致,否则可能无法安装成功或安装之后无法正常使用)
如果python没有自带py2exe, 则还要另外下载py2exe进行安装,以便后面打包用。

代码(DefectPredict.py):

# -*-coding:UTF-8 -*-
__author__ = 'GraceDD'


from PyQt4 import QtGui
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg as NavigationToolbar
import matplotlib.pyplot as plt
import pylab as pl
from scipy.optimize import leastsq
from scipy.integrate import *
import warnings
import matplotlib.backends.backend_qt5agg
import math

pl.mpl.rcParams['font.sans-serif'] = ['SimHei']#指定默认字体  
pl.mpl.rcParams['axes.unicode_minus'] = False#解决保存图像是负号'-'显示为方块的问题 

class Window(QtGui.QWidget):
    param=[0,0,0]
    def __init__(self):
        super(Window, self).__init__()

        # a figure instance to plot on
        self.figure = plt.figure()

        # this is the Canvas Widget that displays the `figure`
        # it takes the `figure` instance as a parameter to __init__
        self.canvas = FigureCanvas(self.figure)

        # this is the Navigation widget
        # it takes the Canvas widget and a parent
        self.toolbar = NavigationToolbar(self.canvas, self)

        # Just some button connected to `plot` method
        self.button = QtGui.QPushButton('Plot')
        self.button.clicked.connect(self.plot)

        self.inLbl=QtGui.QLabel(u"输入",self)
        self.inEdit=QtGui.QLineEdit(self)

        self.modelLbl=QtGui.QLabel(u"函数模型:a*b^c^x",self)
        self.blankLbll=QtGui.QLabel("",self)

        self.oriALbl=QtGui.QLabel(u"初始参数a:",self)
        self.oriAEdit=QtGui.QLineEdit(self)
        self.oriBLbl=QtGui.QLabel(u"初始参数b:",self)
        self.oriBEdit=QtGui.QLineEdit(self)
        self.oriCLbl=QtGui.QLabel(u"初始参数c:",self)
        self.oriCEdit=QtGui.QLineEdit(self)

        self.resALbl=QtGui.QLabel(u"预测参数a:",self)
        self.resAEdit=QtGui.QLineEdit(self)
        self.resBLbl=QtGui.QLabel(u"预测参数b:",self)
        self.resBEdit=QtGui.QLineEdit(self)
        self.resCLbl=QtGui.QLabel(u"预测参数c:",self)
        self.resCEdit=QtGui.QL
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值