Пример #1
0
    def traverseplot(Xin,Yin,Field,name):
        string,nodeind,leaf,label=TraverseTree(regTree,Xin,Field)
        nband=Yin.shape[1]
        k=0
        for j in leaf:
            Ytemp=Yin[nodeind[j],:]
            Xtemp=Xin[nodeind[j],:]
            Yptemp=regTreeModel.predict(Xtemp)

            fitmodel=fitModelList[k]
            if predind.ndim==1:
                Ypnewtemp=fitmodel.predict(Xtemp[:,predind.astype(int)])
            else:
                Ypnewtemp=fitmodel.predict(Xtemp[:,predind[k,:].astype(int)])

            rmse,rmse_band=RMSECal(Yptemp,Ytemp)
            rmsenew,rmse_bandnew=RMSECal(Ypnewtemp,Ytemp)

            n=nband
            f, axarr = plt.subplots(int(np.ceil(n/2)), 2,figsize=(10,12))
            for i in range(n):
                pj=int(np.ceil(i/2))
                pi=int(i%2)
                axarr[pj, pi].plot(Yptemp[:,i],Ytemp[:,i],'.')
                axarr[pj, pi].plot(Ypnewtemp[:,i],Ytemp[:,i],'.r')
                axarr[pj, pi].set_title('cluster %s,\n cc=%.3f -> %.3f, r=%.3f -> %.3f'\
                                        %(i,np.corrcoef(Yptemp[:,i],Ytemp[:,i])[0,1],np.corrcoef(Ypnewtemp[:,i],Ytemp[:,i])[0,1],
                                          rmse_band[i],rmse_bandnew[i]))
                plotFun.plot121line(axarr[pj, pi])
            f.tight_layout()
            f.suptitle(string[j],fontsize=8)
            f.subplots_adjust(top=0.9)
            plt.savefig(savedir+name+"_node%i"%j)
            plt.close()
            k=k+1
Пример #2
0
def Regression_plot(Yp, Ytest, doplot):
    rmse, rmse_band = RMSECal(Yp, Ytest)
    if doplot == 1:  # box plot for all bands
        nband = Yp.shape[1]
        plt.figure()
        plt.boxplot(Yp - Ytest)
        #plt.title("Pred - Truth, total rmse %.3f"%np.mean(rmse_band))
    elif doplot == 2:
        nband = Yp.shape[1]
        n = nband
        f, axarr = plt.subplots(int(np.ceil(n / 2)), 2)
        f.tight_layout()
        f.subplots_adjust(top=0.9)
        #plt.suptitle('Silhouette Coefficient=%s'%score)
        for i in range(n):
            pj = int(np.ceil(i / 2))
            pi = int(i % 2)
            axarr[pj, pi].plot(Ytest[:, i], Yp[:, i], '.')
            axarr[pj, pi].set_title('cluster %s,\n corrcoef=%.3f, rmse=%.3f'\
                                    %(i,np.corrcoef(Ytest[:,i],Yp[:,i])[0,1],rmse_band[i]))
            plotFun.plot121line(axarr[pj, pi])
        f.tight_layout()
Пример #3
0
def Regression_plot(Yp,Ytest,doplot):
    rmse,rmse_band=RMSECal(Yp,Ytest)
    if doplot==1:   # box plot for all bands
        nband = Yp.shape[1]
        plt.figure()
        plt.boxplot(Yp-Ytest)
        #plt.title("Pred - Truth, total rmse %.3f"%np.mean(rmse_band))
    elif doplot==2:
        nband = Yp.shape[1]
        n=nband
        f, axarr = plt.subplots(int(np.ceil(n/2)), 2)
        f.tight_layout()
        f.subplots_adjust(top=0.9)
        #plt.suptitle('Silhouette Coefficient=%s'%score)
        for i in range(n):
            pj=int(np.ceil(i/2))
            pi=int(i%2)
            axarr[pj, pi].plot(Ytest[:,i],Yp[:,i],'.')
            axarr[pj, pi].set_title('cluster %s,\n corrcoef=%.3f, rmse=%.3f'\
                                    %(i,np.corrcoef(Ytest[:,i],Yp[:,i])[0,1],rmse_band[i]))
            plotFun.plot121line(axarr[pj, pi])
        f.tight_layout()
Пример #4
0
    def traverseplot(Xin, Yin, Field, name):
        string, nodeind, leaf, label = TraverseTree(regTree, Xin, Field)
        nband = Yin.shape[1]
        k = 0
        for j in leaf:
            Ytemp = Yin[nodeind[j], :]
            Xtemp = Xin[nodeind[j], :]
            Yptemp = regTreeModel.predict(Xtemp)

            fitmodel = fitModelList[k]
            if predind.ndim == 1:
                Ypnewtemp = fitmodel.predict(Xtemp[:, predind.astype(int)])
            else:
                Ypnewtemp = fitmodel.predict(Xtemp[:,
                                                   predind[k, :].astype(int)])

            rmse, rmse_band = RMSECal(Yptemp, Ytemp)
            rmsenew, rmse_bandnew = RMSECal(Ypnewtemp, Ytemp)

            n = nband
            f, axarr = plt.subplots(int(np.ceil(n / 2)), 2, figsize=(10, 12))
            for i in range(n):
                pj = int(np.ceil(i / 2))
                pi = int(i % 2)
                axarr[pj, pi].plot(Yptemp[:, i], Ytemp[:, i], '.')
                axarr[pj, pi].plot(Ypnewtemp[:, i], Ytemp[:, i], '.r')
                axarr[pj, pi].set_title('cluster %s,\n cc=%.3f -> %.3f, r=%.3f -> %.3f'\
                                        %(i,np.corrcoef(Yptemp[:,i],Ytemp[:,i])[0,1],np.corrcoef(Ypnewtemp[:,i],Ytemp[:,i])[0,1],
                                          rmse_band[i],rmse_bandnew[i]))
                plotFun.plot121line(axarr[pj, pi])
            f.tight_layout()
            f.suptitle(string[j], fontsize=8)
            f.subplots_adjust(top=0.9)
            plt.savefig(savedir + name + "_node%i" % j)
            plt.close()
            k = k + 1