import numpy as np
from sklearn import tree
from sklearn.tree import export_graphviz
import graphviz

X = np.array([[0],[1],[2],[3]])  
y = np.array([2,3,4,5])

model = tree.DecisionTreeRegressor()
model.fit(X, y)
predictions = model.predict(X)

print(model.feature_importances_)

for index in range(len(predictions)):
  print('Actual: ', y[index], 'Predicted: ', predictions[index])

export_graphviz(model, out_file='DecisionTree.dot')

with open('DecisionTree.dot') as f:
  dot_graph = f.read()
g = graphviz.Source(dot_graph)
g.render()    
print('PDF created')