返回处理程序(fd)IOError:读取PNG头时出错

2024-09-29 21:33:07 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图用Python中的现有代码https://github.com/mgckind/MLZ/blob/master/mlz/ml_codes/TPZ.py构建一个回归树。特别是代码中的Rtree()。在

This is the code我正在运行构建一个树,它调用TPZ程序。 当我调用T.plot_tree()时,我遇到的问题是绘制树。This is the error我试着运行程序时得到了。代码的作者说它是为linux环境而构建的。所以我在windows中安装了一个linux环境(使用/lxrun方法),但是作为一个编程的外行,我还没有真正解决这个问题。有人能帮我吗?在

如果信息不充分,很抱歉。如果您还有其他要求,请告诉我。在

谢谢!在

编辑:这是我使用的代码。我之前的问题是没有找到正确的道路。然后我在windows中安装了linux环境,并能够解决这个问题。但现在问题似乎出在读取PNG文件上。我安装python包Matplotlib的方式有问题吗?我希望这有帮助!在

   from numpy import *
   import time
   import os, sys

   path_src = os.path.abspath(os.path.join(os.getcwd(), '../../'))
   if not path_src in sys.path: sys.path.insert(1, path_src)

   from ml_codes import *
   start = time.time()
   X = loadtxt('Data/Query3.txt', usecols=(1,2,3,4,5,6,7), unpack=True).T
   Y = loadtxt('Data/Query3.txt', unpack=True, usecols=(8))

   d = {'u': {'ind': 0}, 'g': {'ind': 1}, 'r': {'ind': 2}, 'i': {'ind': 3}, 
   'z': {'ind': 4}, 'u-g': {'ind': 5},
   'g-r': {'ind': 6}}

    T = TPZ.Rtree(X, Y, minleaf=1,forest = 'yes', mstar=4, dict_dim = d)
    T.plot_tree()
    branches = T.leaves()
    att = T.leaves_dim()    
    print 'tree structure = ', branches
    print 'best split at each node = ', att

Tags: path代码importsrctree环境timeos

热门问题