python代码不能正常运行(求指教)
from sklearn.datasets import load_iris
from sklearn.tree import DecisionTreeClassifier
from sklearn.model_selection import train_test_split
# 加载数据
iris = load_iris()
X, y = iris.data, iris.target
# 划分训练集和测试集
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
# 训练决策树模型
clf = DecisionTreeClassifier(max_depth=3)
clf.fit(X_train, y_train)
# 评估模型
print("测试集准确率:", clf.score(X_test, y_test)) # 输出示例: 测试集准确率: 1.0
以上代码在wps的py脚本中显示脚本运行失败。