遇到的问题和解决办法:决策树-基于california_housing数据集

%matplotlib inline
import matplotlib.pyplot as plt
import pandas as pd
from sklearn.datasets.california_housing import fetch_california_housing#在sklearn.datasets自生的数据集下预测房价影响因素

housing = fetch_california_housing()
print(housing.DESCR)#查看数据描述

在jupyter notebook上执行完后报错:ModuleNotFoundError: No module named 'sklearn.datasets.california_housing’
遇到的问题和解决办法:决策树-基于california_housing数据集_第1张图片
解决办法:把代码:

from sklearn.datasets.california_housing import fetch_california_housing

改为以下代码:

from sklearn.datasets import fetch_california_housing  
import pydotplus
graph = pydotplus.graph_from_dot_data(dot_data)
graph.get_nodes()[7].set_fillcolor("#FFF2DD")
from IPython.display import Image
Image(graph.create_png())

在执行这个代码时出现:InvocationException: GraphViz’s executables not found
解决办法:在代码中加入下面代码:

import os
os.environ["PATH"] += os.pathsep + 'E:/Program Files/Graphviz/bin'  #注意修改你的路径

你可能感兴趣的:(python,决策树,机器学习,人工智能)