当前位置:首页>python>Python 零基础100天—Day87 分类与聚类

Python 零基础100天—Day87 分类与聚类

  • 2026-08-22 22:06:16
Python 零基础100天—Day87 分类与聚类

🐍 Python Day87:分类与聚类 — 决策树、随机森林、K-Means

🕐 预计用时:3-4 小时 | 🎯 目标:掌握三种核心算法 + 交叉验证


📖 今日目录

  1. 决策树
  2. 随机森林
  3. K-Means 聚类
  4. 交叉验证
  5. 算法对比实验
  6. 今日练习
  7. 今日小结

1. 决策树

1.1 什么是决策树?

决策树就像你每天做的选择题。比如今天穿什么衣服?

                    今天冷吗?
                   /          \
                 是            否
                /                \
          下雨吗?            穿短袖
          /      \
        是        否
       /            \
    穿外套+带伞    穿外套

机器学习中的决策树也一样——它通过一系列是/否问题,把数据逐步分类。每个"问题"就是一个节点,每个回答就是一条分支

1.2 动手做决策树

from sklearn.tree import DecisionTreeClassifier, export_text
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score, classification_report

# 加载数据
iris = load_iris()
X_train, X_test, y_train, y_test = train_test_split(
    iris.data, iris.target, test_size=0.2, random_state=42
)

# 创建决策树(限制最大深度为3,防止过拟合)
tree = DecisionTreeClassifier(max_depth=3, random_state=42)
tree.fit(X_train, y_train)

# 预测
y_pred = tree.predict(X_test)
print(f"准确率: {accuracy_score(y_test, y_pred):.2%}")

# 打印决策规则(文本版)
print("\n决策规则:")
print(export_text(tree, feature_names=iris.feature_names))
准确率: 100.00%

决策规则:
|--- petal length (cm) <= 2.45
|   |--- class: 0
|--- petal length (cm) >  2.45
|   |--- petal width (cm) <= 1.75
|   |   |--- petal length (cm) <= 4.95
|   |   |   |--- class: 1
|   |   |--- petal length (cm) >  4.95
|   |   |   |--- class: 2
|   |--- petal width (cm) >  1.75
|   |   |--- class: 2

1.3 特征重要性

# 哪个特征最重要?
importances = tree.feature_importances_
for name, imp in sorted(zip(iris.feature_names, importances), key=lambda x: -x[1]):
    bar = "█" * int(imp * 30)
    print(f"  {name:>20s}: {imp:.3f} {bar}")
  petal length (cm): 0.950 ████████████████████████████
   petal width (cm): 0.050 █
  sepal length (cm): 0.000
   sepal width (cm): 0.000

💡 决策树优点:可解释性极强——你可以直接看到模型是怎么做决策的,就像看一棵"问题树"。缺点是容易过拟合(死记硬背训练数据),通过限制 max_depth 可以缓解。

1.4 可视化决策树

from sklearn.tree import plot_tree

plt.figure(figsize=(16, 8))
plot_tree(tree,
          feature_names=iris.feature_names,
          class_names=iris.target_names,
          filled=True,       # 颜色填充
          rounded=True,      # 圆角框
          fontsize=11)
plt.title('鸢尾花分类决策树')
plt.tight_layout()
plt.savefig('decision_tree.png', dpi=150)
plt.show()

2. 随机森林

2.1 什么是随机森林?

一棵决策树容易犯错,那种一片森林呢?

随机森林的核心思想:三个臭皮匠,赛过诸葛亮。训练很多棵决策树,每棵树看不同的数据子集,最后投票决定结果。

对比
决策树
随机森林
数量
1 棵
很多棵(通常 100~500)
过拟合
容易
不容易(互相抵消)
准确率
一般
通常更高
速度
较慢(树多)
可解释性
较弱(黑盒)

2.2 动手做随机森林

from sklearn.ensemble import RandomForestClassifier

# 用乳腺癌数据集(569个样本,30个特征)
from sklearn.datasets import load_breast_cancer
data = load_breast_cancer()
X_train, X_test, y_train, y_test = train_test_split(
    data.data, data.target, test_size=0.2, random_state=42
)

# 创建随机森林(100棵树)
rf = RandomForestClassifier(n_estimators=100, random_state=42)
rf.fit(X_train, y_train)

y_pred = rf.predict(X_test)
print(f"准确率: {accuracy_score(y_test, y_pred):.2%}")
print(f"\n分类报告:")
print(classification_report(y_test, y_pred, target_names=data.target_names))

2.3 特征重要性排名

# 随机森林可以告诉你哪些特征最重要
importances = rf.feature_importances_
indices = np.argsort(importances)[::-1]

print("特征重要性排名:")
for i in range(10):  # 前10个
    print(f"  {i+1}. {data.feature_names[indices[i]]}: {importances[indices[i]]:.4f}")

# 可视化
plt.figure(figsize=(12, 6))
top_n = 15
plt.barh(range(top_n), importances[indices[:top_n]], color='
#07c160')
plt.yticks(range(top_n), [data.feature_names[i] for i in indices[:top_n]])
plt.xlabel('重要性')
plt.title('随机森林 - 特征重要性 Top 15')
plt.gca().invert_yaxis()
plt.tight_layout()
plt.savefig('feature_importance.png', dpi=150)
plt.show()

🔍 为什么随机森林更好?每棵树只看随机的一部分数据和特征,所以它们各自有"偏见"。但把它们的投票汇总起来,偏见就互相抵消了。这就是集成学习的力量。


3. K-Means 聚类

3.1 什么是聚类?

前面的算法都是监督学习——有标签(正确答案)。聚类是无监督学习——没有标签,让机器自己找规律。

K-Means 的思路很直觉:

  1. 你告诉它要分 K 组
  2. 它随机选 K 个"中心点"
  3. 每个数据点归到最近的中心点
  4. 重新计算每组的中心点
  5. 重复 3-4 直到不再变化

想象你有 1000 个客户的消费数据,你想把他们分成 3 类(高/中/低消费),但你不知道谁属于哪类——K-Means 帮你搞定。

3.2 动手做 K-Means

from sklearn.cluster import KMeans
from sklearn.datasets import make_blobs

# 生成模拟数据(3个簇)
X, y_true = make_blobs(n_samples=300, centers=3,
                       cluster_std=0.8, random_state=42)

# K-Means 聚类
kmeans = KMeans(n_clusters=3, random_state=42, n_init=10)
kmeans.fit(X)

# 聚类结果
y_pred = kmeans.labels_
centers = kmeans.cluster_centers_

print(f"聚类中心:")
for i, center in enumerate(centers):
    print(f"  簇{i+1}: ({center[0]:.2f}, {center[1]:.2f})")

# 可视化
plt.figure(figsize=(10, 6))
colors = ['#07c160', '#1890ff', '#ff4d4f']
for i in range(3):
    mask = y_pred == i
    plt.scatter(X[mask, 0], X[mask, 1], c=colors[i], alpha=0.5, label=f'簇 {i+1}')

# 画中心点
plt.scatter(centers[:, 0], centers[:, 1], c='black', marker='X', s=200, linewidths=2, label='中心点')
plt.xlabel('特征 1')
plt.ylabel('特征 2')
plt.title('K-Means 聚类结果')
plt.legend()
plt.grid(True, alpha=0.3)
plt.tight_layout()
plt.savefig('kmeans_clustering.png', dpi=150)
plt.show()

3.3 肘部法则:选多少个簇?

K-Means 需要你提前指定 K(簇的数量),但怎么知道该分几组?肘部法则来帮忙:

# 用鸢尾花数据集
iris = load_iris()
X = iris.data

# 测试不同的 K 值
inertias = []
K_range = range(1, 10)

for k in K_range:
    km = KMeans(n_clusters=k, random_state=42, n_init=10)
    km.fit(X)
    inertias.append(km.inertia_)

# 画肘部图
plt.figure(figsize=(8, 5))
plt.plot(K_range, inertias, 'bo-', linewidth=2)
plt.xlabel('K (簇的数量)')
plt.ylabel('惯性 (Inertia)')
plt.title('肘部法则')
plt.grid(True, alpha=0.3)

# 标注"肘部"
plt.annotate('肘部 (K=3)', xy=(3, inertias[2]),
             xytext=(5, inertias[0] * 0.7),
             arrowprops=dict(arrowstyle='->', color='red'),
             fontsize=12, color='red')
plt.tight_layout()
plt.savefig('elbow_method.png', dpi=150)
plt.show()

🎯 肘部法则:惯性(Inertia)衡量的是"数据点到中心的平均距离"。K 越大,惯性越小(分得更细)。当 K 增大到某个值后,惯性下降变缓——这个"拐点"就是最佳 K。图形看起来像胳膊肘,所以叫"肘部法则"。

3.4 聚类的实际应用

# 客户分群实战
np.random.seed(42)
n_customers = 200

# 特征:月消费金额、月访问次数
spending = np.concatenate([
    np.random.normal(500, 100, 80),   # 低消费
    np.random.normal(1500, 200, 70),  # 中消费
    np.random.normal(3000, 300, 50),  # 高消费
])
visits = np.concatenate([
    np.random.normal(3, 1, 80),
    np.random.normal(8, 2, 70),
    np.random.normal(15, 3, 50),
])
X_customers = np.column_stack([spending, visits])

# 聚类
kmeans = KMeans(n_clusters=3, random_state=42, n_init=10)
labels = kmeans.fit_predict(X_customers)

# 分析每组特征
for i in range(3):
    mask = labels == i
    avg_spending = X_customers[mask, 0].mean()
    avg_visits = X_customers[mask, 1].mean()
    count = mask.sum()
    print(f"簇 {i+1}: {count}人, 平均消费{avg_spending:.0f}元, 平均访问{avg_visits:.1f}次")

# 给每组命名
group_names = {}
for i in range(3):
    avg = X_customers[labels == i, 0].mean()
    if avg < 800:
        group_names[i] = "低价值客户"
    elif avg < 2000:
        group_names[i] = "中价值客户"
    else:
        group_names[i] = "高价值客户"

print("\n客户分群结果:")
for i, name in group_names.items():
    print(f"  簇{i+1} → {name}")

4. 交叉验证

4.1 为什么要交叉验证?

昨天我们用 train_test_split 把数据分成训练集和测试集。但这样有个问题:你只测了一次。如果你运气不好,测试集刚好特别简单或特别难呢?

交叉验证(Cross Validation)的解决方案:把数据切成 K 份,轮流用每一份当测试集,其余当训练集,最后取平均分。

数据分成5份:
第1轮: [测试] [训练] [训练] [训练] [训练] → 得分 0.95
第2轮: [训练] [测试] [训练] [训练] [训练] → 得分 0.92
第3轮: [训练] [训练] [测试] [训练] [训练] → 得分 0.97
第4轮: [训练] [训练] [训练] [测试] [训练] → 得分 0.93
第5轮: [训练] [训练] [训练] [训练] [测试] → 得分 0.96
平均: 0.946 ± 0.018

4.2 动手做交叉验证

from sklearn.model_selection import cross_val_score

# 鸢尾花数据集
iris = load_iris()
X, y = iris.data, iris.target

# 决策树 + 5折交叉验证
tree = DecisionTreeClassifier(max_depth=3, random_state=42)
scores = cross_val_score(tree, X, y, cv=5, scoring='accuracy')

print("5折交叉验证结果:")
for i, score in enumerate(scores):
    print(f"  第{i+1}折: {score:.4f}")
print(f"  平均: {scores.mean():.4f} ± {scores.std():.4f}")

# 随机森林 + 5折交叉验证
rf = RandomForestClassifier(n_estimators=100, random_state=42)
scores_rf = cross_val_score(rf, X, y, cv=5, scoring='accuracy')
print(f"\n随机森林: {scores_rf.mean():.4f} ± {scores_rf.std():.4f}")

4.3 用交叉验证选模型

from sklearn.tree import DecisionTreeClassifier
from sklearn.ensemble import RandomForestClassifier, GradientBoostingClassifier
from sklearn.svm import SVC
from sklearn.neighbors import KNeighborsClassifier

# 对比多种算法
models = {
    '决策树(depth=3)': DecisionTreeClassifier(max_depth=3, random_state=42),
    '决策树(depth=5)': DecisionTreeClassifier(max_depth=5, random_state=42),
    '随机森林(100)': RandomForestClassifier(n_estimators=100, random_state=42),
    'KNN(k=5)': KNeighborsClassifier(n_neighbors=5),
    'SVM': SVC(random_state=42),
}

print("算法对比 (5折交叉验证):")
print("-" * 50)
results = {}
for name, model in models.items():
    scores = cross_val_score(model, X, y, cv=5, scoring='accuracy')
    results[name] = scores.mean()
    print(f"  {name:>20s}: {scores.mean():.4f} ± {scores.std():.4f}")

best = max(results, key=results.get)
print(f"\n🏆 最佳模型: {best} ({results[best]:.4f})")

5. 算法对比实验

# 完整对比:在乳腺癌数据集上测试
from sklearn.datasets import load_breast_cancer
from sklearn.linear_model import LogisticRegression

data = load_breast_cancer()
X, y = data.data, data.target

models = {
    '逻辑回归': LogisticRegression(max_iter=10000),
    '决策树(depth=3)': DecisionTreeClassifier(max_depth=3),
    '决策树(depth=5)': DecisionTreeClassifier(max_depth=5),
    '随机森林(100)': RandomForestClassifier(n_estimators=100),
    'KNN(k=5)': KNeighborsClassifier(n_neighbors=5),
    'SVM': SVC(),
}

print("=" * 55)
print(f"{'模型':>20s} | {'准确率':>8s} | {'标准差':>8s}")
print("-" * 55)

for name, model in models.items():
    scores = cross_val_score(model, X, y, cv=5, scoring='accuracy')
    print(f"{name:>20s} | {scores.mean():>7.4f} | {scores.std():>7.4f}")

print("=" * 55)

⚠️ 没有"万能算法":不同数据集适合不同的算法。决策树可解释性强,随机森林性能稳定,SVM 在高维数据上表现好。实际项目中,要多试几种,用交叉验证选最好的。

注意:KNN 和 SVM 对特征量纲非常敏感,使用前务必做 StandardScaler 标准化,否则准确率会明显偏低。


6. 今日练习

练习 1:手写数字识别

用 datasets.load_digits() 数据集,分别训练决策树和随机森林,对比准确率。

练习 2:K-Means 客户分群

自己生成 200 个客户的消费数据(月消费 + 访问次数),用 K-Means 分成 4 群,分析每群特征。

练习 3:交叉验证选参数

用交叉验证测试随机森林不同的 n_estimators(10, 50, 100, 200),找出最佳值。


7. 今日小结

算法
类型
核心思想
适用场景
决策树
监督/分类
一系列是/否问题
需要可解释性
随机森林
监督/分类
多棵树投票
追求高准确率
K-Means
无监督/聚类
分 K 组,迭代优化
客户分群、数据探索
交叉验证
评估方法
K 折轮流测试
模型选择、参数调优

🎯 一句话总结:决策树是"一棵树的智慧",随机森林是"一群树的投票",K-Means 是"没有答案的分组",交叉验证是"多考几次取平均"。

🔮 明天预告:Day88 我们将运用所学知识完成一个完整的房价预测项目——从数据探索、特征工程到模型训练、评估、预测,走完一个机器学习项目的全流程!

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-08-23 04:06:50 HTTP/2.0 GET : https://f.mffb.com.cn/a/511879.html
  2. 运行时间 : 0.427619s [ 吞吐率:2.34req/s ] 内存消耗:4,625.11kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=32d35c3ee675f17c738fa4d717e885fc
  1. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/public/index.php ( 0.79 KB )
  2. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/autoload.php ( 0.17 KB )
  3. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_real.php ( 2.49 KB )
  4. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/platform_check.php ( 0.90 KB )
  5. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/ClassLoader.php ( 14.03 KB )
  6. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_static.php ( 4.90 KB )
  7. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper.php ( 8.34 KB )
  8. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/helper.php ( 2.19 KB )
  9. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/helper.php ( 1.47 KB )
  10. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/stubs/load_stubs.php ( 0.16 KB )
  11. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Exception.php ( 1.69 KB )
  12. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Facade.php ( 2.71 KB )
  13. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/deprecation-contracts/function.php ( 0.99 KB )
  14. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap.php ( 8.26 KB )
  15. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap80.php ( 9.78 KB )
  16. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/Resources/functions/dump.php ( 1.49 KB )
  17. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-dumper/src/helper.php ( 0.18 KB )
  18. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/VarDumper.php ( 4.30 KB )
  19. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/App.php ( 15.30 KB )
  20. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Container.php ( 15.76 KB )
  21. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/container/src/ContainerInterface.php ( 1.02 KB )
  22. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/provider.php ( 0.19 KB )
  23. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Http.php ( 6.04 KB )
  24. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Str.php ( 7.29 KB )
  25. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Env.php ( 4.68 KB )
  26. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/common.php ( 0.03 KB )
  27. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/helper.php ( 18.78 KB )
  28. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Config.php ( 5.54 KB )
  29. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/app.php ( 0.95 KB )
  30. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cache.php ( 0.78 KB )
  31. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/console.php ( 0.23 KB )
  32. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cookie.php ( 0.56 KB )
  33. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/database.php ( 2.48 KB )
  34. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Env.php ( 1.67 KB )
  35. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/filesystem.php ( 0.61 KB )
  36. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/lang.php ( 0.91 KB )
  37. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/log.php ( 1.35 KB )
  38. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/middleware.php ( 0.19 KB )
  39. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/route.php ( 1.89 KB )
  40. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/session.php ( 0.57 KB )
  41. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/trace.php ( 0.34 KB )
  42. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/view.php ( 0.82 KB )
  43. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/event.php ( 0.25 KB )
  44. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Event.php ( 7.67 KB )
  45. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/service.php ( 0.13 KB )
  46. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/AppService.php ( 0.26 KB )
  47. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Service.php ( 1.64 KB )
  48. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Lang.php ( 7.35 KB )
  49. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/lang/zh-cn.php ( 13.70 KB )
  50. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/Error.php ( 3.31 KB )
  51. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/RegisterService.php ( 1.33 KB )
  52. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/services.php ( 0.14 KB )
  53. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/PaginatorService.php ( 1.52 KB )
  54. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ValidateService.php ( 0.99 KB )
  55. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ModelService.php ( 2.04 KB )
  56. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Service.php ( 0.77 KB )
  57. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Middleware.php ( 6.72 KB )
  58. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/BootService.php ( 0.77 KB )
  59. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Paginator.php ( 11.86 KB )
  60. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/Validate.php ( 63.20 KB )
  61. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Model.php ( 23.55 KB )
  62. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Attribute.php ( 21.05 KB )
  63. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/AutoWriteData.php ( 4.21 KB )
  64. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Conversion.php ( 6.44 KB )
  65. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/DbConnect.php ( 5.16 KB )
  66. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/ModelEvent.php ( 2.33 KB )
  67. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/RelationShip.php ( 28.29 KB )
  68. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Arrayable.php ( 0.09 KB )
  69. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Jsonable.php ( 0.13 KB )
  70. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/contract/Modelable.php ( 0.09 KB )
  71. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Db.php ( 2.88 KB )
  72. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/DbManager.php ( 8.52 KB )
  73. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Log.php ( 6.28 KB )
  74. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Manager.php ( 3.92 KB )
  75. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerTrait.php ( 2.69 KB )
  76. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerInterface.php ( 2.71 KB )
  77. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cache.php ( 4.92 KB )
  78. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/simple-cache/src/CacheInterface.php ( 4.71 KB )
  79. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Arr.php ( 16.63 KB )
  80. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/driver/File.php ( 7.84 KB )
  81. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/Driver.php ( 9.03 KB )
  82. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php ( 1.99 KB )
  83. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/Request.php ( 0.09 KB )
  84. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Request.php ( 55.78 KB )
  85. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/middleware.php ( 0.25 KB )
  86. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Pipeline.php ( 2.61 KB )
  87. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/TraceDebug.php ( 3.40 KB )
  88. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/middleware/SessionInit.php ( 1.94 KB )
  89. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Session.php ( 1.80 KB )
  90. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/driver/File.php ( 6.27 KB )
  91. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php ( 0.87 KB )
  92. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/Store.php ( 7.12 KB )
  93. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Route.php ( 23.73 KB )
  94. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleName.php ( 5.75 KB )
  95. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Domain.php ( 2.53 KB )
  96. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleGroup.php ( 22.43 KB )
  97. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Rule.php ( 26.95 KB )
  98. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleItem.php ( 9.78 KB )
  99. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/route/app.php ( 1.72 KB )
  100. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Route.php ( 4.70 KB )
  101. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/dispatch/Controller.php ( 4.74 KB )
  102. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Dispatch.php ( 10.44 KB )
  103. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/controller/Index.php ( 4.81 KB )
  104. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/BaseController.php ( 2.05 KB )
  105. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/facade/Db.php ( 0.93 KB )
  106. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/connector/Mysql.php ( 5.44 KB )
  107. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/PDOConnection.php ( 52.47 KB )
  108. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Connection.php ( 8.39 KB )
  109. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/ConnectionInterface.php ( 4.57 KB )
  110. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/builder/Mysql.php ( 16.58 KB )
  111. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Builder.php ( 24.06 KB )
  112. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseBuilder.php ( 27.50 KB )
  113. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Query.php ( 15.71 KB )
  114. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseQuery.php ( 45.13 KB )
  115. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TimeFieldQuery.php ( 7.43 KB )
  116. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/AggregateQuery.php ( 3.26 KB )
  117. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ModelRelationQuery.php ( 20.07 KB )
  118. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ParamsBind.php ( 3.66 KB )
  119. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ResultOperation.php ( 7.01 KB )
  120. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/WhereQuery.php ( 19.37 KB )
  121. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/JoinAndViewQuery.php ( 7.11 KB )
  122. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php ( 2.63 KB )
  123. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/Transaction.php ( 2.77 KB )
  124. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/driver/File.php ( 5.96 KB )
  125. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/LogHandlerInterface.php ( 0.86 KB )
  126. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/Channel.php ( 3.89 KB )
  127. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/event/LogRecord.php ( 1.02 KB )
  128. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/Collection.php ( 16.47 KB )
  129. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/View.php ( 1.70 KB )
  130. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/View.php ( 4.39 KB )
  131. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Response.php ( 8.81 KB )
  132. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/response/View.php ( 3.29 KB )
  133. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cookie.php ( 6.06 KB )
  134. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-view/src/Think.php ( 8.38 KB )
  135. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php ( 1.60 KB )
  136. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/Template.php ( 46.61 KB )
  137. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/driver/File.php ( 2.41 KB )
  138. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/contract/DriverInterface.php ( 0.86 KB )
  139. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/runtime/temp/067d451b9a0c665040f3f1bdd3293d68.php ( 11.98 KB )
  140. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Html.php ( 4.42 KB )
  1. CONNECT:[ UseTime:0.000839s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.001280s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000835s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.018926s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.001420s ]
  6. SELECT * FROM `set` [ RunTime:0.000574s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.001431s ]
  8. SELECT * FROM `article` WHERE `id` = 511879 LIMIT 1 [ RunTime:0.040664s ]
  9. UPDATE `article` SET `lasttime` = 1787429210 WHERE `id` = 511879 [ RunTime:0.002298s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.000780s ]
  11. SELECT * FROM `article` WHERE `id` < 511879 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.061936s ]
  12. SELECT * FROM `article` WHERE `id` > 511879 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.031980s ]
  13. SELECT * FROM `article` WHERE `id` < 511879 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.011757s ]
  14. SELECT * FROM `article` WHERE `id` < 511879 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.024418s ]
  15. SELECT * FROM `article` WHERE `id` < 511879 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.052408s ]
0.431348s