当前位置:首页>python>Python 零基础100天—Day86 Scikit-learn 入门

Python 零基础100天—Day86 Scikit-learn 入门

  • 2026-08-21 19:31:33
Python 零基础100天—Day86 Scikit-learn 入门

🐍 Python Day86:Scikit-learn 入门 — 第一个机器学习模型

🕐 预计用时:3-4 小时 | 🎯 目标:掌握线性回归、逻辑回归的使用方法,理解模型评估指标


📖 今日目录

  1. Scikit-learn 是什么?
  2. 安装与环境准备
  3. 数据集加载
  4. 线性回归
  5. 逻辑回归
  6. 模型评估指标
  7. 数据预处理
  8. 实战:波士顿房价预测
  9. 今日练习
  10. 今日小结

1. Scikit-learn 是什么?

Scikit-learn(简称 sklearn)是 Python 最流行的机器学习库,提供了大量现成的算法和工具。如果说昨天我们学了"什么是机器学习",今天就是亲手让机器学起来

你可以把它想象成一个机器学习超市——货架上摆满了各种算法(线性回归、决策树、SVM...),你只需要把数据"喂"进去,它就能帮你训练出一个模型。

特性
说明
简单易用
统一的 API 设计,fit/predict 两步搞定
算法丰富
分类、回归、聚类、降维一应俱全
文档完善
官方文档质量极高,示例丰富
依赖 NumPy
底层用 NumPy 实现,速度快
不适合深度学习
深度学习请用 TensorFlow/PyTorch

💡 核心思想:Scikit-learn 的所有模型都遵循相同的套路——创建模型 → fit(X, y) 训练 → predict(X) 预测。学会一个,就等于学会了一百个。


2. 安装与环境准备

# 安装 scikit-learn
pip install scikit-learn

# 通常还需要这些
pip install numpy pandas matplotlib

# 验证安装
python -c "import sklearn; print(sklearn.__version__)"

导入常用模块:

# 数据集
from sklearn import datasets

# 模型
from sklearn.linear_model import LinearRegression, LogisticRegression

# 数据拆分
from sklearn.model_selection import train_test_split

# 评估指标
from sklearn.metrics import accuracy_score, mean_squared_error, classification_report

# 预处理
from sklearn.preprocessing import StandardScaler, MinMaxScaler

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

3. 数据集加载

Scikit-learn 自带了很多经典数据集,方便我们练习:

# 加载鸢尾花数据集(分类任务经典)
iris = datasets.load_iris()
print(type(iris))  # Bunch(类似字典)

# 查看有哪些内容
print(iris.keys())
# dict_keys(['data', 'target', 'target_names', 'DESCR', 'feature_names'])

# 特征矩阵(150个样本,4个特征)
print(iris.data.shape)  # (150, 4)

# 标签
print(iris.target.shape)  # (150,)
print(iris.target_names)  # ['setosa' 'versicolor' 'virginica']

# 特征名
print(iris.feature_names)
# ['sepal length (cm)', 'sepal width (cm)', 'petal length (cm)', 'petal width (cm)']

用 Pandas 看得更清楚:

df = pd.DataFrame(iris.data, columns=iris.feature_names)
df['species'] = iris.target
print(df.head())
   sepal length (cm)  sepal width (cm)  petal length (cm)  petal width (cm)  species
0                5.1               3.5                1.4               0.2        0
1                4.9               3.0                1.4               0.2        0
2                4.7               3.2                1.3               0.2        0
3                4.6               3.1                1.5               0.2        0
4                5.0               3.6                1.4               0.2        0

常用数据集一览:

数据集
类型
样本数
特征数
用途
iris
分类
150
4
鸢尾花分类
digits
分类
1797
64
手写数字识别
wine
分类
178
13
红酒分类
breast_cancer
分类
569
30
乳腺癌诊断
boston
回归
506
13
房价预测
diabetes
回归
442
10
糖尿病进展预测

⚠️ 注意:sklearn 1.2+ 版本已移除 datasets.load_boston(),可以用 fetch_openml(name='boston') 替代,或者用我们自己构造的数据。


4. 线性回归

4.1 什么是线性回归?

线性回归是最基础的机器学习算法。它做的事情很简单:找到一条直线(或平面),让数据点尽量靠近它

生活中的例子:

  • 学习时间 → 考试成绩(学得越久,分越高)
  • 房子面积 → 房价(面积越大,越贵)
  • 广告投入 → 销售额

数学公式:y = w₁x₁ + w₂x₂ + ... + b

其中 w 是权重(斜率),b 是偏置(截距)。

4.2 动手做线性回归

# 生成模拟数据:学习时间 → 考试成绩
np.random.seed(42)
X = np.random.rand(100, 1) * 10  # 学习时间 0~10 小时
y = 2.5 * X.squeeze() + 5 + np.random.randn(100) * 2  # 成绩 = 2.5*时间 + 5 + 噪声

# 拆分训练集和测试集
X_train, X_test, y_train, y_test = train_test_split(
    X, y, test_size=0.2, random_state=42
)

print(f"训练集: {X_train.shape[0]} 个样本")
print(f"测试集: {X_test.shape[0]} 个样本")

# 创建模型并训练
model = LinearRegression()
model.fit(X_train, y_train)

# 查看学到的参数
print(f"权重 w = {model.coef_[0]:.2f}")  # 应该接近 2.5
print(f"偏置 b = {model.intercept_:.2f}")  # 应该接近 5

# 预测
y_pred = model.predict(X_test)

# 对比前5个
for i in range(5):
    print(f"实际: {y_test[i]:.1f}  预测: {y_pred[i]:.1f}  误差: {abs(y_test[i]-y_pred[i]):.1f}")

4.3 可视化结果

plt.figure(figsize=(10, 6))
plt.scatter(X_train, y_train, alpha=0.5, label='训练数据', color='
#07c160')
plt.scatter(X_test, y_test, alpha=0.5, label='测试数据', color='#1890ff')

# 画回归线
X_line = np.linspace(0, 10, 100).reshape(-1, 1)
y_line = model.predict(X_line)
plt.plot(X_line, y_line, 'r-', linewidth=2, label=f'回归线: y={model.coef_[0]:.2f}x+{model.intercept_:.2f}')

plt.xlabel('学习时间 (小时)')
plt.ylabel('考试成绩')
plt.title('线性回归:学习时间 vs 考试成绩')
plt.legend()
plt.grid(True, alpha=0.3)
plt.tight_layout()
plt.savefig('linear_regression.png', dpi=150)
plt.show()

4.4 多特征线性回归

# 用糖尿病数据集(10个特征)
diabetes = datasets.load_diabetes()
X, y = diabetes.data, diabetes.target

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

model = LinearRegression()
model.fit(X_train, y_train)

# 每个特征的权重
for name, coef in zip(diabetes.feature_names, model.coef_):
    print(f"  {name}: {coef:.2f}")

print(f"\n训练集 R² = {model.score(X_train, y_train):.4f}")
print(f"测试集 R² = {model.score(X_test, y_test):.4f}")

📊 R² 分数(决定系数):R² 越接近 1,说明模型解释数据的能力越强。R²=0.6 意味着模型解释了 60% 的数据变化。一般来说:R² > 0.7 算不错,R² > 0.9 算优秀。


5. 逻辑回归

5.1 什么是逻辑回归?

虽然名字里有"回归",但逻辑回归其实是一个分类算法。它解决的是"是或否"的问题:

  • 这封邮件是不是垃圾邮件?(是/否)
  • 这个肿瘤是良性还是恶性?(二分类)
  • 这张图片是猫还是狗?(二分类)

它的工作原理:把线性回归的结果通过 Sigmoid 函数压缩到 0~1 之间,变成概率。

# Sigmoid 函数可视化
def sigmoid(z):
    return 1 / (1 + np.exp(-z))

z = np.linspace(-10, 10, 100)
plt.figure(figsize=(8, 4))
plt.plot(z, sigmoid(z), 'b-', linewidth=2)
plt.axhline(y=0.5, color='r', linestyle='--', alpha=0.5, label='决策边界 (0.5)')
plt.xlabel('z')
plt.ylabel('σ(z)')
plt.title('Sigmoid 函数')
plt.legend()
plt.grid(True, alpha=0.3)
plt.show()

5.2 动手做逻辑回归

# 用鸢尾花数据集做二分类(只取前两类)
iris = datasets.load_iris()
X = iris.data[:100]  # 只取前100个(两类)
y = iris.target[:100]  # 0=setosa, 1=versicolor

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# 创建逻辑回归模型
model = LogisticRegression(max_iter=200)
model.fit(X_train, y_train)

# 预测
y_pred = model.predict(X_test)
y_prob = model.predict_proba(X_test)  # 概率

# 查看前5个预测结果
for i in range(5):
    actual = 'setosa' if y_test[i] == 0 else 'versicolor'
    predicted = 'setosa' if y_pred[i] == 0 else 'versicolor'
    prob = y_prob[i].max()
    print(f"实际: {actual:>10s}  预测: {predicted:>10s}  置信度: {prob:.2%}")

5.3 多分类逻辑回归

# 用全部3类鸢尾花
X = iris.data
y = iris.target

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# sklearn 1.5+ 已弃用 multi_class 参数,默认使用 multinomial 策略
model = LogisticRegression(max_iter=1000)
model.fit(X_train, y_train)

y_pred = model.predict(X_test)

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

6. 模型评估指标

训练完模型,怎么知道它好不好用?需要评估指标来打分。

6.1 回归任务的评估指标

指标
含义
越小越好?
MSE (均方误差)
预测值与实际值差的平方的平均
✅ 越小越好
RMSE (均方根误差)
MSE 开根号,和原始数据同单位
✅ 越小越好
MAE (平均绝对误差)
预测值与实际值差的绝对值的平均
✅ 越小越好
R² (决定系数)
模型解释了多少数据变化
❌ 越接近 1 越好
# 回归评估示例
from sklearn.metrics import mean_squared_error, mean_absolute_error, r2_score

# 假设真实值和预测值
y_true = [100, 200, 300, 400, 500]
y_pred = [110, 190, 310, 380, 520]

mse = mean_squared_error(y_true, y_pred)
rmse = np.sqrt(mse)
mae = mean_absolute_error(y_true, y_pred)
r2 = r2_score(y_true, y_pred)

print(f"MSE  = {mse:.2f}")
print(f"RMSE = {rmse:.2f}")
print(f"MAE  = {mae:.2f}")
print(f"R²   = {r2:.4f}")

6.2 分类任务的评估指标

分类任务的评估更有趣。先理解四个基础概念:

预测为正
预测为负
实际为正
✅ 真正例 TP
❌ 假负例 FN(漏报)
实际为负
❌ 假正例 FP(误报)
✅ 真负例 TN

由此衍生出三个重要指标:

指标
公式
通俗理解
准确率 (Accuracy)
(TP+TN) / 全部
整体猜对的比例
精确率 (Precision)
TP / (TP+FP)
说"是"的时候,有多少真的是
召回率 (Recall)
TP / (TP+FN)
真正的"是",找到了多少

🎯 精确率 vs 召回率:
精确率:宁可漏掉,也不误报(垃圾邮件过滤——误杀正常邮件很糟糕)
召回率:宁可误报,也不漏掉(癌症筛查——漏掉一个患者很危险)
- 两者通常是跷跷板关系,需要根据场景取舍。

from sklearn.metrics import confusion_matrix, classification_report

# 混淆矩阵
cm = confusion_matrix(y_test, y_pred)
print("混淆矩阵:")
print(cm)

# 完整报告
print("\n分类报告:")
print(classification_report(y_test, y_pred, target_names=['类别A', '类别B']))

6.3 F1 分数

F1 分数是精确率和召回率的调和平均,兼顾两者:

from sklearn.metrics import f1_score

f1 = f1_score(y_test, y_pred, average='weighted')
print(f"F1 分数: {f1:.4f}")

F1 的取值范围 0~1,越高越好。一般标准:

  • F1 > 0.9:优秀
  • F1 > 0.7:良好
  • F1 > 0.5:及格
  • F1 < 0.5:需要改进

7. 数据预处理

真实世界的数据"脏乱差",需要先清洗和处理:

7.1 特征缩放

from sklearn.preprocessing import StandardScaler, MinMaxScaler

# 标准化:均值=0,标准差=1(最常用)
scaler = StandardScaler()
X_scaled = scaler.fit_transform(X_train)

# 归一化:缩放到 [0, 1]
scaler = MinMaxScaler()
X_normalized = scaler.fit_transform(X_train)

print("原始数据前3行:")
print(X_train[:3])
print("\n标准化后:")
print(X_scaled[:3])

⚠️ 为什么要做特征缩放?如果一个特征范围是 0~1,另一个是 0~10000,大的那个会主导模型训练。缩放后,所有特征"站在同一起跑线"。

注意:要用 fit_transform() 处理训练集,用 transform() 处理测试集,避免数据泄露。

7.2 缺失值处理

from sklearn.impute import SimpleImputer

# 用均值填充缺失值
imputer = SimpleImputer(strategy='mean')
X_filled = imputer.fit_transform(X)

# 其他策略: 'median'(中位数), 'most_frequent'(众数), 'constant'(常数)

7.3 编码分类特征

from sklearn.preprocessing import LabelEncoder, OneHotEncoder

# 标签编码:分类 → 数字
le = LabelEncoder()
y_encoded = le.fit_transform(['猫', '狗', '猫', '鸟'])
print(y_encoded)  # [1 0 1 2]  (按 Unicode 排序:狗=0, 猫=1, 鸟=2)

# 独热编码:分类 → 二进制向量
# sklearn 1.2+ 用 sparse_output=False;旧版本用 sparse=False
ohe = OneHotEncoder(sparse_output=False)
categories = [['男'], ['女'], ['男']]
print(ohe.fit_transform(categories))
# [[0. 1.]   ← 男
#  [1. 0.]   ← 女
#  [0. 1.]]  ← 男

8. 实战:房价预测(模拟数据)

把今天学到的所有知识串起来,完成一个完整的机器学习项目:

import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from sklearn.preprocessing import StandardScaler
from sklearn.metrics import mean_squared_error, r2_score
import matplotlib.pyplot as plt

# ========== 1. 生成模拟房价数据 ==========
np.random.seed(42)
n_samples = 500

# 特征:面积、卧室数、楼层、年龄
area = np.random.uniform(50, 200, n_samples)        # 面积(平方米)
rooms = np.random.randint(1, 6, n_samples)           # 卧室数
floor_num = np.random.randint(1, 30, n_samples)      # 楼层
age = np.random.uniform(0, 30, n_samples)            # 房龄(年)

# 目标:房价(万元),假设公式
price = (area * 1.5 + rooms * 20 - age * 0.5 + floor_num * 0.3
         + np.random.randn(n_samples) * 15)

# 组装 DataFrame
df = pd.DataFrame({
    '面积': area,
    '卧室数': rooms,
    '楼层': floor_num,
    '房龄': age,
    '房价': price
})

print("数据概况:")
print(df.describe().round(2))

# ========== 2. 数据准备 ==========
X = df[['面积', '卧室数', '楼层', '房龄']]
y = df['房价']

# 拆分
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# 标准化
scaler = StandardScaler()
X_train_scaled = scaler.fit_transform(X_train)
X_test_scaled = scaler.transform(X_test)

# ========== 3. 训练模型 ==========
model = LinearRegression()
model.fit(X_train_scaled, y_train)

# 查看权重
print("\n特征权重:")
for name, coef in zip(X.columns, model.coef_):
    print(f"  {name}: {coef:+.2f}")
print(f"  偏置: {model.intercept_:.2f}")

# ========== 4. 评估模型 ==========
y_pred = model.predict(X_test_scaled)

rmse = np.sqrt(mean_squared_error(y_test, y_pred))
r2 = r2_score(y_test, y_pred)

print(f"\n评估结果:")
print(f"  RMSE = {rmse:.2f} 万元")
print(f"  R²   = {r2:.4f}")

# ========== 5. 可视化 ==========
fig, axes = plt.subplots(1, 2, figsize=(14, 5))

# 真实 vs 预测
axes[0].scatter(y_test, y_pred, alpha=0.5, color='#07c160')
axes[0].plot([y_test.min(), y_test.max()], [y_test.min(), y_test.max()], 'r--')
axes[0].set_xlabel('真实房价')
axes[0].set_ylabel('预测房价')
axes[0].set_title(f'真实 vs 预测 (R²={r2:.4f})')

# 残差分布
residuals = y_test - y_pred
axes[1].hist(residuals, bins=30, color='#1890ff', alpha=0.7)
axes[1].axvline(x=0, color='r', linestyle='--')
axes[1].set_xlabel('残差')
axes[1].set_ylabel('频次')
axes[1].set_title('残差分布')

plt.tight_layout()
plt.savefig('house_price_prediction.png', dpi=150)
plt.show()

# ========== 6. 实际预测 ==========
print("\n新数据预测:")
new_houses = pd.DataFrame({
    '面积': [90, 120, 150],
    '卧室数': [2, 3, 4],
    '楼层': [15, 8, 22],
    '房龄': [5, 10, 2]
})
new_scaled = scaler.transform(new_houses)
predictions = model.predict(new_scaled)
for i, pred in enumerate(predictions):
    print(f"  房子{i+1}: {new_houses.iloc[i]['面积']}㎡ {int(new_houses.iloc[i]['卧室数'])}室 → 预测房价: {pred:.1f}万元")

9. 今日练习

练习 1:鸢尾花分类

用逻辑回归对鸢尾花数据集做三分类,打印分类报告。

练习 2:糖尿病预测

用线性回归预测糖尿病进展,计算 R² 和 RMSE。

练习 3:特征缩放对比

分别用标准化和不标准化训练逻辑回归模型,对比准确率变化。


10. 今日小结

知识点
核心内容
Scikit-learn
Python 最流行的 ML 库,fit/predict 统一接口
线性回归
拟合直线/平面,用于连续值预测
逻辑回归
分类算法,输出概率,sigmoid 函数
回归指标
MSE、RMSE、MAE、R²
分类指标
准确率、精确率、召回率、F1
数据预处理
StandardScaler、缺失值填充、编码
train_test_split
把数据拆成训练集和测试集

🎯 一句话总结:Scikit-learn 的核心套路就三步——准备数据 → fit 训练 → predict 预测。掌握这个流程,你就入门机器学习了!

🔮 明天预告:Day87 我们将学习更强大的分类算法(决策树、随机森林)和聚类算法(K-Means),以及交叉验证这个"考试技巧"。敬请期待!

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-08-21 21:20:15 HTTP/2.0 GET : https://f.mffb.com.cn/a/511626.html
  2. 运行时间 : 0.274847s [ 吞吐率:3.64req/s ] 内存消耗:4,673.20kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=1f6127d6c91cacd3e7691da0d27d3cc1
  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.000952s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.001578s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000734s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000697s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.001515s ]
  6. SELECT * FROM `set` [ RunTime:0.014801s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.001578s ]
  8. SELECT * FROM `article` WHERE `id` = 511626 LIMIT 1 [ RunTime:0.004492s ]
  9. UPDATE `article` SET `lasttime` = 1787318415 WHERE `id` = 511626 [ RunTime:0.021797s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.000819s ]
  11. SELECT * FROM `article` WHERE `id` < 511626 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.001164s ]
  12. SELECT * FROM `article` WHERE `id` > 511626 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.003722s ]
  13. SELECT * FROM `article` WHERE `id` < 511626 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.018079s ]
  14. SELECT * FROM `article` WHERE `id` < 511626 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.005787s ]
  15. SELECT * FROM `article` WHERE `id` < 511626 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.047850s ]
0.276379s