Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/330.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
设置我的决策树python 将熊猫作为pd导入 将numpy作为np导入 从sklearn导入树 从sklearn.tree导入DecisionTreeClassifier 从sklearn.model\u选择导入列车\u测试\u拆分 从matplotlib导入pyplot作为plt 导入seaborn作为sns 从sklearn.tree导入导出_graphviz 进口graphviz 导入pydotplus 输入io 从scipy导入杂项 %matplotlib内联 data=pd.read\u csv(r''C:\Users\Pwego\Desktop\spotifyclassification2\data.csv') 列车,测试=列车,测试,拆分(数据,测试尺寸=0.15) 打印(“训练大小:{};测试大小:{};”。格式(len(训练),len(测试))) pos_tempo=data[data['target']==1]['tempo'] 负节奏=数据[数据['target']==0]['tempo'] pos_danceability=data[data['target']==1]['danceability'] 负可跳舞性=数据[数据['target']==0]['danceability'] 位置持续时间=数据[数据['target']==1]['duration\u ms'] 负持续时间=数据[数据['target']==0]['duration\u ms'] 位置能量=数据[数据['target']==1]['energy'] 负能量=数据[数据['target']==0]['energy'] pos_instrumentalness=data[data['target']==1]['instrumentalness'] 负仪器性=数据[数据['target']==0]['instrumentalness'] pos_key=data[data['target']==1]['key'] 负键=数据[数据['target']==0]['key'] pos_liveness=data[data['target']==1]['liveness'] 负活性=数据[数据['target']==0]['liveness'] 位置响度=数据[数据['target']==1]['loudness'] 负响度=数据[数据['target']==0]['loudness'] pos_mode=data[data['target']==1]['mode'] 负模式=数据[数据['target']==0]['mode'] 词性=数据[数据['target']==1]['speechness'] 无语=数据[数据['target']==0]['speechness'] 位置时间签名=数据[数据['target']==1]['time\u签名'] 负时间签名=数据[数据['target']==0]['time\u签名'] pos_价=数据[数据['target']==1]['valence'] 负价=数据[数据['target']==0]['valence'] 图=plt.图(图尺寸=(12,8)) plt.title(“歌曲节奏喜欢/不喜欢分布”) pos_tempo.hist(alpha=0.7,bins=30,label='positive',color=“green”) 负节奏历史(alpha=0.7,bin=30,标签为负,颜色为红色) plt.图例(loc=“右上”) 图2=plt.图(图尺寸=(15,15)) #跳舞 ax3=图2.添加子批次(331) ax3.set_xlabel('dancebility') ax3.set_ylabel('count') ax3.设置标题(“类似于歌曲舞蹈的分布”) 位置可跳性历史(α=0.5,箱子=30) 负可跳性历史(α=0.5,箱=30) ax4=图2.添加子批次(331) ax4.set_xlabel('duration') ax4.set_ylabel('count') ax4.设置歌曲标题(“类似歌曲持续时间的发行”) pos_duration.hist(alpha=0.5,bin=30) 负持续时间历史(α=0.5,箱数=30) ax5=图2.添加子批次(332) ax5.设置标签(“能量”) ax5.set_ylabel('count') ax5.集_标题(“类似于歌曲的能量分布”) 位置能量历史(α=0.5,料仓=30) 负能量历史(α=0.5,箱=30) ax6=图2.添加子批次(333) ax6.set_xlabel(‘工具性’) ax6.set_ylabel('count') ax6.设置标题(“类似乐器的歌曲分布”) 位置仪器性历史(α=0.5,箱柜=30) 负仪器性历史(α=0.5,箱数=30) ax7=图2.添加子批次(334) ax7.set_xlabel('键') ax7.set_ylabel('count') ax7.设置标题(“类似于发行版的歌曲键”) 位置键历史(alpha=0.5,bins=30) 负键历史(alpha=0.5,bins=30) ax8=图2.添加子批次(335) ax8.set_xlabel('liveness') ax8.set_ylabel('count') ax8.集_标题(“类似歌曲活力的发行”) pos_liveness.hist(alpha=0.5,bin=30) 负活性。历史(α=0.5,箱=30) ax9=图2.添加子批次(336) ax9.设置标签(“响度”) ax9.set_ylabel('count') ax9.设置标题(“类似于歌曲响度的分布”) 位置响度历史(α=0.5,箱柜=30) 负响度历史(α=0.5,箱柜=30) ax10=图2.添加子批次(337) ax10.set_xlabel('mode') ax10.set_ylabel('count') ax10.设置标题(“类似歌曲模式的发行”) 位置模式历史(alpha=0.5,箱子=30) 负模式历史(alpha=0.5,bins=30) ax11=图2.添加子批次(338) ax11.set_xlabel('speechness') ax11.set_ylabel('count') ax11.设置标题(“像歌曲一样的口语分布”) pos_speechness.hist(alpha=0.5,bin=30) 无语性。历史(阿尔法=0.5,宾斯=30) ax12=图2.添加子批次(339) ax12.set_xlabel('time_signature') ax12.set_ylabel('count') ax12.设置标题(“歌曲时间签名超过发行”) pos\u time\u signature.hist(alpha=0.5,bin=30) 负时间签名.hist(alpha=0.5,bin=30) ax13=图2.添加子批次(339) ax13.set_xlabel('价') ax13.set_ylabel('count') ax13.设置标题(“歌曲配价高于发行价”) pos_价历史(α=0.5,料仓=30) 负价历史(α=0.5,区间=30) c=决策树分类器(最小样本分割=100) 特征=[“可舞动性”、“响度”、“配价”、“能量”、“乐器性”、“声学性”、“k”] X_列车=列车[特征] y_train=列车['target'] X_测试=测试[特征] y_测试=测试[“目标”] def显示_树(树、特征、路径): f=io.StringIO() 导出图形(树,输出文件=f,要素名称=features) pydotplus.graph_from_dot_data(f.getvalue()).write_png(path) img=scipy.misc.inread(路径) plt.rcParams[“figure.figsize”]=(20,20) 项目imgshow(img) 显示_树(dt,特征,'tree1.png') --------------------------------------------------------------------------- AttributeError回溯(最近一次呼叫上次) 在() ---->1显示_树(dt,特征,'tree1.png') 在显示树中(树、要素、路径) 3导出图形(树,输出文件=f,特征名称=features) 4 pydotplus.graph_from_dot_data(f.getvalue()).write_png(path) ---->5 img=scipy.misc.inread(路径) 6 plt.rcParams[“figure.figsize”]=(20,20) 7 plt.imgshow(img) AttributeError:模块“scipy.misc”没有属性“inread”_Python_Pandas_Scipy_Decision Tree_Pydot - Fatal编程技术网

设置我的决策树python 将熊猫作为pd导入 将numpy作为np导入 从sklearn导入树 从sklearn.tree导入DecisionTreeClassifier 从sklearn.model\u选择导入列车\u测试\u拆分 从matplotlib导入pyplot作为plt 导入seaborn作为sns 从sklearn.tree导入导出_graphviz 进口graphviz 导入pydotplus 输入io 从scipy导入杂项 %matplotlib内联 data=pd.read\u csv(r''C:\Users\Pwego\Desktop\spotifyclassification2\data.csv') 列车,测试=列车,测试,拆分(数据,测试尺寸=0.15) 打印(“训练大小:{};测试大小:{};”。格式(len(训练),len(测试))) pos_tempo=data[data['target']==1]['tempo'] 负节奏=数据[数据['target']==0]['tempo'] pos_danceability=data[data['target']==1]['danceability'] 负可跳舞性=数据[数据['target']==0]['danceability'] 位置持续时间=数据[数据['target']==1]['duration\u ms'] 负持续时间=数据[数据['target']==0]['duration\u ms'] 位置能量=数据[数据['target']==1]['energy'] 负能量=数据[数据['target']==0]['energy'] pos_instrumentalness=data[data['target']==1]['instrumentalness'] 负仪器性=数据[数据['target']==0]['instrumentalness'] pos_key=data[data['target']==1]['key'] 负键=数据[数据['target']==0]['key'] pos_liveness=data[data['target']==1]['liveness'] 负活性=数据[数据['target']==0]['liveness'] 位置响度=数据[数据['target']==1]['loudness'] 负响度=数据[数据['target']==0]['loudness'] pos_mode=data[data['target']==1]['mode'] 负模式=数据[数据['target']==0]['mode'] 词性=数据[数据['target']==1]['speechness'] 无语=数据[数据['target']==0]['speechness'] 位置时间签名=数据[数据['target']==1]['time\u签名'] 负时间签名=数据[数据['target']==0]['time\u签名'] pos_价=数据[数据['target']==1]['valence'] 负价=数据[数据['target']==0]['valence'] 图=plt.图(图尺寸=(12,8)) plt.title(“歌曲节奏喜欢/不喜欢分布”) pos_tempo.hist(alpha=0.7,bins=30,label='positive',color=“green”) 负节奏历史(alpha=0.7,bin=30,标签为负,颜色为红色) plt.图例(loc=“右上”) 图2=plt.图(图尺寸=(15,15)) #跳舞 ax3=图2.添加子批次(331) ax3.set_xlabel('dancebility') ax3.set_ylabel('count') ax3.设置标题(“类似于歌曲舞蹈的分布”) 位置可跳性历史(α=0.5,箱子=30) 负可跳性历史(α=0.5,箱=30) ax4=图2.添加子批次(331) ax4.set_xlabel('duration') ax4.set_ylabel('count') ax4.设置歌曲标题(“类似歌曲持续时间的发行”) pos_duration.hist(alpha=0.5,bin=30) 负持续时间历史(α=0.5,箱数=30) ax5=图2.添加子批次(332) ax5.设置标签(“能量”) ax5.set_ylabel('count') ax5.集_标题(“类似于歌曲的能量分布”) 位置能量历史(α=0.5,料仓=30) 负能量历史(α=0.5,箱=30) ax6=图2.添加子批次(333) ax6.set_xlabel(‘工具性’) ax6.set_ylabel('count') ax6.设置标题(“类似乐器的歌曲分布”) 位置仪器性历史(α=0.5,箱柜=30) 负仪器性历史(α=0.5,箱数=30) ax7=图2.添加子批次(334) ax7.set_xlabel('键') ax7.set_ylabel('count') ax7.设置标题(“类似于发行版的歌曲键”) 位置键历史(alpha=0.5,bins=30) 负键历史(alpha=0.5,bins=30) ax8=图2.添加子批次(335) ax8.set_xlabel('liveness') ax8.set_ylabel('count') ax8.集_标题(“类似歌曲活力的发行”) pos_liveness.hist(alpha=0.5,bin=30) 负活性。历史(α=0.5,箱=30) ax9=图2.添加子批次(336) ax9.设置标签(“响度”) ax9.set_ylabel('count') ax9.设置标题(“类似于歌曲响度的分布”) 位置响度历史(α=0.5,箱柜=30) 负响度历史(α=0.5,箱柜=30) ax10=图2.添加子批次(337) ax10.set_xlabel('mode') ax10.set_ylabel('count') ax10.设置标题(“类似歌曲模式的发行”) 位置模式历史(alpha=0.5,箱子=30) 负模式历史(alpha=0.5,bins=30) ax11=图2.添加子批次(338) ax11.set_xlabel('speechness') ax11.set_ylabel('count') ax11.设置标题(“像歌曲一样的口语分布”) pos_speechness.hist(alpha=0.5,bin=30) 无语性。历史(阿尔法=0.5,宾斯=30) ax12=图2.添加子批次(339) ax12.set_xlabel('time_signature') ax12.set_ylabel('count') ax12.设置标题(“歌曲时间签名超过发行”) pos\u time\u signature.hist(alpha=0.5,bin=30) 负时间签名.hist(alpha=0.5,bin=30) ax13=图2.添加子批次(339) ax13.set_xlabel('价') ax13.set_ylabel('count') ax13.设置标题(“歌曲配价高于发行价”) pos_价历史(α=0.5,料仓=30) 负价历史(α=0.5,区间=30) c=决策树分类器(最小样本分割=100) 特征=[“可舞动性”、“响度”、“配价”、“能量”、“乐器性”、“声学性”、“k”] X_列车=列车[特征] y_train=列车['target'] X_测试=测试[特征] y_测试=测试[“目标”] def显示_树(树、特征、路径): f=io.StringIO() 导出图形(树,输出文件=f,要素名称=features) pydotplus.graph_from_dot_data(f.getvalue()).write_png(path) img=scipy.misc.inread(路径) plt.rcParams[“figure.figsize”]=(20,20) 项目imgshow(img) 显示_树(dt,特征,'tree1.png') --------------------------------------------------------------------------- AttributeError回溯(最近一次呼叫上次) 在() ---->1显示_树(dt,特征,'tree1.png') 在显示树中(树、要素、路径) 3导出图形(树,输出文件=f,特征名称=features) 4 pydotplus.graph_from_dot_data(f.getvalue()).write_png(path) ---->5 img=scipy.misc.inread(路径) 6 plt.rcParams[“figure.figsize”]=(20,20) 7 plt.imgshow(img) AttributeError:模块“scipy.misc”没有属性“inread”

设置我的决策树python 将熊猫作为pd导入 将numpy作为np导入 从sklearn导入树 从sklearn.tree导入DecisionTreeClassifier 从sklearn.model\u选择导入列车\u测试\u拆分 从matplotlib导入pyplot作为plt 导入seaborn作为sns 从sklearn.tree导入导出_graphviz 进口graphviz 导入pydotplus 输入io 从scipy导入杂项 %matplotlib内联 data=pd.read\u csv(r''C:\Users\Pwego\Desktop\spotifyclassification2\data.csv') 列车,测试=列车,测试,拆分(数据,测试尺寸=0.15) 打印(“训练大小:{};测试大小:{};”。格式(len(训练),len(测试))) pos_tempo=data[data['target']==1]['tempo'] 负节奏=数据[数据['target']==0]['tempo'] pos_danceability=data[data['target']==1]['danceability'] 负可跳舞性=数据[数据['target']==0]['danceability'] 位置持续时间=数据[数据['target']==1]['duration\u ms'] 负持续时间=数据[数据['target']==0]['duration\u ms'] 位置能量=数据[数据['target']==1]['energy'] 负能量=数据[数据['target']==0]['energy'] pos_instrumentalness=data[data['target']==1]['instrumentalness'] 负仪器性=数据[数据['target']==0]['instrumentalness'] pos_key=data[data['target']==1]['key'] 负键=数据[数据['target']==0]['key'] pos_liveness=data[data['target']==1]['liveness'] 负活性=数据[数据['target']==0]['liveness'] 位置响度=数据[数据['target']==1]['loudness'] 负响度=数据[数据['target']==0]['loudness'] pos_mode=data[data['target']==1]['mode'] 负模式=数据[数据['target']==0]['mode'] 词性=数据[数据['target']==1]['speechness'] 无语=数据[数据['target']==0]['speechness'] 位置时间签名=数据[数据['target']==1]['time\u签名'] 负时间签名=数据[数据['target']==0]['time\u签名'] pos_价=数据[数据['target']==1]['valence'] 负价=数据[数据['target']==0]['valence'] 图=plt.图(图尺寸=(12,8)) plt.title(“歌曲节奏喜欢/不喜欢分布”) pos_tempo.hist(alpha=0.7,bins=30,label='positive',color=“green”) 负节奏历史(alpha=0.7,bin=30,标签为负,颜色为红色) plt.图例(loc=“右上”) 图2=plt.图(图尺寸=(15,15)) #跳舞 ax3=图2.添加子批次(331) ax3.set_xlabel('dancebility') ax3.set_ylabel('count') ax3.设置标题(“类似于歌曲舞蹈的分布”) 位置可跳性历史(α=0.5,箱子=30) 负可跳性历史(α=0.5,箱=30) ax4=图2.添加子批次(331) ax4.set_xlabel('duration') ax4.set_ylabel('count') ax4.设置歌曲标题(“类似歌曲持续时间的发行”) pos_duration.hist(alpha=0.5,bin=30) 负持续时间历史(α=0.5,箱数=30) ax5=图2.添加子批次(332) ax5.设置标签(“能量”) ax5.set_ylabel('count') ax5.集_标题(“类似于歌曲的能量分布”) 位置能量历史(α=0.5,料仓=30) 负能量历史(α=0.5,箱=30) ax6=图2.添加子批次(333) ax6.set_xlabel(‘工具性’) ax6.set_ylabel('count') ax6.设置标题(“类似乐器的歌曲分布”) 位置仪器性历史(α=0.5,箱柜=30) 负仪器性历史(α=0.5,箱数=30) ax7=图2.添加子批次(334) ax7.set_xlabel('键') ax7.set_ylabel('count') ax7.设置标题(“类似于发行版的歌曲键”) 位置键历史(alpha=0.5,bins=30) 负键历史(alpha=0.5,bins=30) ax8=图2.添加子批次(335) ax8.set_xlabel('liveness') ax8.set_ylabel('count') ax8.集_标题(“类似歌曲活力的发行”) pos_liveness.hist(alpha=0.5,bin=30) 负活性。历史(α=0.5,箱=30) ax9=图2.添加子批次(336) ax9.设置标签(“响度”) ax9.set_ylabel('count') ax9.设置标题(“类似于歌曲响度的分布”) 位置响度历史(α=0.5,箱柜=30) 负响度历史(α=0.5,箱柜=30) ax10=图2.添加子批次(337) ax10.set_xlabel('mode') ax10.set_ylabel('count') ax10.设置标题(“类似歌曲模式的发行”) 位置模式历史(alpha=0.5,箱子=30) 负模式历史(alpha=0.5,bins=30) ax11=图2.添加子批次(338) ax11.set_xlabel('speechness') ax11.set_ylabel('count') ax11.设置标题(“像歌曲一样的口语分布”) pos_speechness.hist(alpha=0.5,bin=30) 无语性。历史(阿尔法=0.5,宾斯=30) ax12=图2.添加子批次(339) ax12.set_xlabel('time_signature') ax12.set_ylabel('count') ax12.设置标题(“歌曲时间签名超过发行”) pos\u time\u signature.hist(alpha=0.5,bin=30) 负时间签名.hist(alpha=0.5,bin=30) ax13=图2.添加子批次(339) ax13.set_xlabel('价') ax13.set_ylabel('count') ax13.设置标题(“歌曲配价高于发行价”) pos_价历史(α=0.5,料仓=30) 负价历史(α=0.5,区间=30) c=决策树分类器(最小样本分割=100) 特征=[“可舞动性”、“响度”、“配价”、“能量”、“乐器性”、“声学性”、“k”] X_列车=列车[特征] y_train=列车['target'] X_测试=测试[特征] y_测试=测试[“目标”] def显示_树(树、特征、路径): f=io.StringIO() 导出图形(树,输出文件=f,要素名称=features) pydotplus.graph_from_dot_data(f.getvalue()).write_png(path) img=scipy.misc.inread(路径) plt.rcParams[“figure.figsize”]=(20,20) 项目imgshow(img) 显示_树(dt,特征,'tree1.png') --------------------------------------------------------------------------- AttributeError回溯(最近一次呼叫上次) 在() ---->1显示_树(dt,特征,'tree1.png') 在显示树中(树、要素、路径) 3导出图形(树,输出文件=f,特征名称=features) 4 pydotplus.graph_from_dot_data(f.getvalue()).write_png(path) ---->5 img=scipy.misc.inread(路径) 6 plt.rcParams[“figure.figsize”]=(20,20) 7 plt.imgshow(img) AttributeError:模块“scipy.misc”没有属性“inread”,python,pandas,scipy,decision-tree,pydot,Python,Pandas,Scipy,Decision Tree,Pydot,所以我尝试为Spotify数据集创建这个决策树,并尝试了多种方法来安装这些库 我经常犯这样的错误有人能帮我吗 我正在使用这个python教程 如果有人有更多的机器学习资源,请发送给我 我认为这是一个简单的问题 import pandas as pd import numpy as np from sklearn import tree from sklearn.tree import DecisionTreeClassifier from sklearn.model_selection im

所以我尝试为Spotify数据集创建这个决策树,并尝试了多种方法来安装这些库

我经常犯这样的错误有人能帮我吗

我正在使用这个python教程

如果有人有更多的机器学习资源,请发送给我

我认为这是一个简单的问题
import pandas as pd
import numpy as np

from sklearn import tree
from sklearn.tree import DecisionTreeClassifier
from sklearn.model_selection import train_test_split

from matplotlib import pyplot as plt
import seaborn as sns

from sklearn.tree import export_graphviz

import graphviz
import pydotplus
import io
from scipy import misc

%matplotlib inline

data = pd.read_csv(r'''C:\Users\Pwego\Desktop\spotifyclassification2\data.csv''')

train, test = train_test_split(data, test_size = 0.15)

print("Training size: {}; Test size: {};".format(len(train), len(test)))

pos_tempo = data[data['target'] == 1]['tempo']
neg_tempo = data[data['target'] == 0]['tempo']

pos_danceability = data[data['target'] == 1]['danceability']
neg_danceability = data[data['target'] == 0]['danceability']

pos_duration = data[data['target'] == 1]['duration_ms']
neg_duration = data[data['target'] == 0]['duration_ms']

pos_energy = data[data['target'] == 1]['energy']
neg_energy = data[data['target'] == 0]['energy']

pos_instrumentalness = data[data['target'] == 1]['instrumentalness']
neg_instrumentalness = data[data['target'] == 0]['instrumentalness']

pos_key = data[data['target'] == 1]['key']
neg_key = data[data['target'] == 0]['key']

pos_liveness = data[data['target'] == 1]['liveness']
neg_liveness = data[data['target'] == 0]['liveness']

pos_loudness = data[data['target'] == 1]['loudness']
neg_loudness = data[data['target'] == 0]['loudness']

pos_mode = data[data['target'] == 1]['mode']
neg_mode = data[data['target'] == 0]['mode']

pos_speechiness = data[data['target'] == 1]['speechiness']
neg_speechiness = data[data['target'] == 0]['speechiness']

pos_time_signature = data[data['target'] == 1]['time_signature']
neg_time_signature = data[data['target'] == 0]['time_signature']

pos_valence = data[data['target'] == 1]['valence']
neg_valence = data[data['target'] == 0]['valence']








fig = plt.figure(figsize =(12, 8))
plt.title("Song Tempo Like / Dislike Distribution")
pos_tempo.hist(alpha = 0.7, bins = 30, label='positive', color ="green")
neg_tempo.hist(alpha = 0.7, bins = 30, label='negative', color ='red')
plt.legend(loc = "upper right")

fig2 = plt.figure(figsize=(15,15))

#Danceabiliy
ax3 = fig2.add_subplot(331)
ax3.set_xlabel('dancebility')
ax3.set_ylabel('count')
ax3.set_title("Song Dancebility Like Distribution")
pos_danceability.hist(alpha=0.5, bins=30)
neg_danceability.hist(alpha=0.5, bins=30)

ax4 = fig2.add_subplot(331)
ax4.set_xlabel('duration')
ax4.set_ylabel('count')
ax4.set_title("Song Duration Like Distribution")
pos_duration.hist(alpha=0.5, bins=30)
neg_duration.hist(alpha=0.5, bins=30)

ax5 = fig2.add_subplot(332)
ax5.set_xlabel('energy')
ax5.set_ylabel('count')
ax5.set_title("Song Energy Like Distribution")
pos_energy.hist(alpha=0.5, bins=30)
neg_energy.hist(alpha=0.5, bins=30)

ax6 = fig2.add_subplot(333)
ax6.set_xlabel('instrumentalness')
ax6.set_ylabel('count')
ax6.set_title("Song Instrumentalness Like Distribution")
pos_instrumentalness.hist(alpha=0.5, bins=30)
neg_instrumentalness.hist(alpha=0.5, bins=30)

ax7 = fig2.add_subplot(334)
ax7.set_xlabel('key')
ax7.set_ylabel('count')
ax7.set_title("Song Keys Like Distribution")
pos_key.hist(alpha=0.5, bins=30)
neg_key.hist(alpha=0.5, bins=30)

ax8= fig2.add_subplot(335)
ax8.set_xlabel('liveness')
ax8.set_ylabel('count')
ax8.set_title("Song Liveness Like Distribution")
pos_liveness.hist(alpha=0.5, bins=30)
neg_liveness.hist(alpha=0.5, bins=30)

ax9 = fig2.add_subplot(336)
ax9.set_xlabel('loudness')
ax9.set_ylabel('count')
ax9.set_title("Song Loudness Like Distribution")
pos_loudness.hist(alpha=0.5, bins=30)
neg_loudness.hist(alpha=0.5, bins=30)

ax10 = fig2.add_subplot(337)
ax10.set_xlabel('mode')
ax10.set_ylabel('count')
ax10.set_title("Song Mode Like Distribution")
pos_mode.hist(alpha=0.5, bins=30)
neg_mode.hist(alpha=0.5, bins=30)

ax11 = fig2.add_subplot(338)
ax11.set_xlabel('speechiness')
ax11.set_ylabel('count')
ax11.set_title("Song Speechiness Like Distribution")
pos_speechiness.hist(alpha=0.5, bins=30)
neg_speechiness.hist(alpha=0.5, bins=30)

ax12 = fig2.add_subplot(339)
ax12.set_xlabel('time_signature')
ax12.set_ylabel('count')
ax12.set_title("Song Time Signature over Distribution")
pos_time_signature.hist(alpha=0.5, bins=30)
neg_time_signature.hist(alpha=0.5, bins=30)

ax13 = fig2.add_subplot(339)
ax13.set_xlabel('valence')
ax13.set_ylabel('count')
ax13.set_title("Song Valence over Distribution")
pos_valence.hist(alpha=0.5, bins=30)
neg_valence.hist(alpha=0.5, bins=30)

c = DecisionTreeClassifier(min_samples_split=100)

features = ["danceability","loudness","valence","energy","instrumentalness","acousticness","k"]

X_train = train[features]
y_train = train['target']

X_test = test[features]
y_test = test['target']

def show_tree(tree, features, path):
    f = io.StringIO()
    export_graphviz(tree, out_file=f, feature_names=features)
    pydotplus.graph_from_dot_data(f.getvalue()).write_png(path)
    img = scipy.misc.inread(path)
    plt.rcParams["figure.figsize"] = (20, 20)
    plt.imgshow(img)

show_tree(dt, features, 'tree1.png')

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-30-72a100e0eeec> in <module>()
----> 1 show_tree(dt, features, 'tree1.png')

<ipython-input-21-9c398f00bf98> in show_tree(tree, features, path)
      3     export_graphviz(tree, out_file=f, feature_names=features)
      4     pydotplus.graph_from_dot_data(f.getvalue()).write_png(path)
----> 5     img = scipy.misc.inread(path)
      6     plt.rcParams["figure.figsize"] = (20, 20)
      7     plt.imgshow(img)

AttributeError: module 'scipy.misc' has no attribute 'inread'