如何解读决策树的图像
如下代码所得图像
library(rpart)
library(rpart.plot)
data(swiss)
set.seed(123)
indices <- sample(1:nrow(swiss), nrow(swiss) * 0.8)
train_data <- swiss[indices, ]
test_data <- swiss[-indices, ]
model <- rpart(Fertility ~ ., data = train_data, method = "class")
rpart.plot(model, extra = 1, under = TRUE, fallen.leaves = TRUE, box.palette = "Blues",
branch.lty = 1, shadow.col = "gray", main = "决策树")
predictions <- predict(model, test_data, type = "class")
accuracy <- sum(predictions == test_data$Fertility) / nrow(test_data)
print(paste("准确率:", accuracy))
代数重数:相同特征值的个数。
几何重数:特征子空间的维数为几何重数,因为空间是几何里的概念,rank(λI−A)=n−αrank(λI-A)=n-αrank(λI−A)=n−α中的ααα值,几何重数 ≤ 代数重数。
在几何重数 = 代数重数时,A可以变换为对角阵,但两者不相同时,A只可以变换为约当阵,这里就需要使用广义特征向量。