print(__doc__) # Import the necessary modules and libraries import numpy as np import time from sklearn.tree import DecisionTreeClassifier import matplotlib.pyplot as plt import math from sklearn.metrics import precision_recall_curve from sklearn.metrics import classification_report from sklearn import tree #set depth and node method for decision tree def depthAndNode(dataSet): n = np.shape(dataSet)[0] depth = 6 node = 1000 if n >= 1000000000: depth = 20 elif n >= 1000000 and n < 1000000000: depth = math.floor(math.log(n / 1000, 2)) elif n < 1000000: depth_1 = math.log(n / 250, 2) depth_2 = math.log(n / 1000, 2) depth_min = math.floor(min(depth_1, depth_2)) node = 250 if depth_min < 6: depth = 6
sklearn决策树 DecisionTreeClassifier建立模型, 导出模型, 读取
最新推荐文章于 2024-05-18 09:51:23 发布