[Python | matplotlib] 간단 한 작도: 산 점도, 막대 그래프, 주파수 분포 직사 도

1107 단어 가시 화Python
홈 페이지 대 법 이 좋다.https://matplotlib.org/index.html
결정 트 리 (회귀) 결과 작도 의 예:http://scikit-learn.org/stable/auto_examples/tree/plot_tree_regression.html#sphx-glr-auto-examples-tree-plot-tree-regression-py
자신 이 사용 하 는:
import matplotlib.pyplot as plt
def draw(y,yy,title,path):   
    print(title)
    
    index = np.arange(0,len(y),1)
    
    plt.scatter(index,y,color='cornflowerblue',label='true')#   
    plt.plot(index,yy,color='yellowgreen',label='predict')#  
    
    plt.xlabel('index')
    plt.ylabel('cost')
    plt.title(title)#     
    plt.legend()#    
    plt.savefig(path+title+'.png')
    plt.show()
    
    rate = []
    fig, ax = plt.subplots()
    for i in range(0,len(x)):
        rate.append((yy[i]-y[i])/y[i])
    rate.sort()
    plt.bar(index,rate)#   
    plt.title(title+' Error')
    plt.savefig(path+title+'_error.png')
    plt.show()
    
    plt.title(title+' Error hist')
    plt.hist(rate)#       
    plt.savefig(path+title+'_errorHist.png')
    plt.show()

좋은 웹페이지 즐겨찾기