第100+21步 ChatGPT学习:概率校准 Isotonic Regression

news2024/9/22 21:23:23

基于Python 3.9版本演示

一、写在前面

最近看了一篇在Lancet子刊《eClinicalMedicine》上发表的机器学习分类的文章:《Development of a novel dementia risk prediction model in the general population: A large, longitudinal, population-based machine-learning study》。

学到一种叫做“概率校准”的骚操作,顺手利用GPT系统学习学习。

文章中用的技术是:保序回归(Isotonic regression)。

二、保序回归(Isotonic regression)

保序回归(Isotonic Regression)是一种用于拟合数据的非参数回归技术,其目标是在满足单调性约束(即预测值随着输入值单调变化)的前提下,找到一个最佳拟合模型。保序回归在机器学习中的一个重要应用是对分类模型的概率进行校准,以提高预测概率的准确性。

在机器学习分类任务中,模型输出的概率往往需要进行校准以更准确地反映真实情况。校准后的概率更能代表事件实际发生的可能性,这对于后续决策过程非常重要。

保序回归在概率校准中的具体作用如下:

  1. 概率校准:分类模型(如逻辑回归、决策树等)输出的概率有时会偏离真实概率分布。通过保序回归,可以对这些概率进行校准,使得校准后的概率更接近真实情况。
  2. 实现方法:校准过程通常包括两个步骤:计算分类器在不同置信水平下的预测概率与实际标签的匹配程度。使用保序回归拟合这些概率与实际标签的关系,从而得到校准后的概率。
  3. 好处:保序回归的非参数特性使其可以适应多种数据分布,而无需对数据分布进行假设。此外,保序回归保证了输出概率的单调性,有助于提升校准效果。

在不平衡数据中,保序回归在概率校准方面也发挥着重要作用。由于不平衡数据集中的类别分布不均衡,分类模型可能倾向于预测多数类,这会导致输出概率的不准确性。保序回归可以帮助校准这些概率,提高模型在不平衡数据集上的表现。

三、保序回归(Isotonic regression)代码实现

下面,我编一个1比3的不太平衡的数据进行测试,对照组使用不进行校准的LR模型,实验组就是加入校准的LR模型,看看性能能够提高多少?

(1)不进行校准的LR模型(默认参数)

import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
dataset = pd.read_csv('8PSMjianmo.csv')
X = dataset.iloc[:, 1:20].values
Y = dataset.iloc[:, 0].values

from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, Y, test_size = 0.30, random_state = 666)
from sklearn.preprocessing import StandardScaler
sc = StandardScaler()
X_train = sc.fit_transform(X_train)
X_test = sc.transform(X_test)

from sklearn.linear_model import LogisticRegression
classifier = LogisticRegression(solver='lbfgs')
classifier.fit(X_train, y_train)

y_pred = classifier.predict(X_test)
y_testprba = classifier.predict_proba(X_test)[:,1] 

y_trainpred = classifier.predict(X_train)
y_trainprba = classifier.predict_proba(X_train)[:,1]

from sklearn.metrics import confusion_matrix
cm_test = confusion_matrix(y_test, y_pred)
cm_train = confusion_matrix(y_train, y_trainpred)
print(cm_train)
print(cm_test)


#绘画测试集混淆矩阵
classes = list(set(y_test))
classes.sort()
plt.imshow(cm_test, cmap=plt.cm.Blues)
indices = range(len(cm_test))
plt.xticks(indices, classes)
plt.yticks(indices, classes)
plt.colorbar()
plt.xlabel('guess')
plt.ylabel('fact')
for first_index in range(len(cm_test)):
    for second_index in range(len(cm_test[first_index])):
        plt.text(first_index, second_index, cm_test[first_index][second_index])
 
plt.show()  

#绘画训练集混淆矩阵
classes = list(set(y_train))
classes.sort()
plt.imshow(cm_train, cmap=plt.cm.Blues)
indices = range(len(cm_train))
plt.xticks(indices, classes)
plt.yticks(indices, classes)
plt.colorbar()
plt.xlabel('guess')
plt.ylabel('fact')
for first_index in range(len(cm_train)):
    for second_index in range(len(cm_train[first_index])):
        plt.text(first_index, second_index, cm_train[first_index][second_index])
 
plt.show() 
 
import math
from sklearn.metrics import confusion_matrix,roc_auc_score,auc,roc_curve
cm = confusion_matrix(y_test, y_pred)    
cm_train = confusion_matrix(y_train, y_trainpred)
# 计算并打印性能参数
def calculate_metrics(cm, y_true, y_pred_prob):
    a = cm[0, 0]
    b = cm[0, 1]
    c = cm[1, 0]
    d = cm[1, 1]
    acc = (a + d) / (a + b + c + d)
    error_rate = 1 - acc
    sen = d / (d + c)
    sep = a / (a + b)
    precision = d / (b + d)
    F1 = (2 * precision * sen) / (precision + sen)
    MCC = (d * a - b * c) / (np.sqrt((d + b) * (d + c) * (a + b) * (a + c)))
    auc_score = roc_auc_score(y_true, y_pred_prob)
    
    metrics = {
        "Accuracy": acc,
        "Error Rate": error_rate,
        "Sensitivity": sen,
        "Specificity": sep,
        "Precision": precision,
        "F1 Score": F1,
        "MCC": MCC,
        "AUC": auc_score
    }
    return metrics

metrics_test = calculate_metrics(cm_test, y_test, y_testprba)
metrics_train = calculate_metrics(cm_train, y_train, y_trainprba)

print("Performance Metrics (Test):")
for key, value in metrics_test.items():
    print(f"{key}: {value:.4f}")

print("\nPerformance Metrics (Train):")
for key, value in metrics_train.items():
print(f"{key}: {value:.4f}") 

结果输出:

记住这些个数字。

(2)进行校准的LR模型(默认参数)

import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.linear_model import LogisticRegression
from sklearn.isotonic import IsotonicRegression
from sklearn.metrics import confusion_matrix, brier_score_loss

# 读取数据
dataset = pd.read_csv('8PSMjianmo.csv')
X = dataset.iloc[:, 1:20].values
Y = dataset.iloc[:, 0].values

# 分割数据集
X_train, X_test, y_train, y_test = train_test_split(X, Y, test_size=0.30, random_state=666)

# 标准化数据
sc = StandardScaler()
X_train = sc.fit_transform(X_train)
X_test = sc.transform(X_test)

# 训练逻辑回归模型
classifier = LogisticRegression(solver='lbfgs')
classifier.fit(X_train, y_train)

# 获取训练集和测试集的预测概率
y_train_proba = classifier.predict_proba(X_train)[:, 1]
y_test_proba = classifier.predict_proba(X_test)[:, 1]

# 使用等渗回归进行概率校准
iso_reg = IsotonicRegression(out_of_bounds='clip')
iso_reg.fit(y_train_proba, y_train)

y_train_calibrated = iso_reg.transform(y_train_proba)
y_test_calibrated = iso_reg.transform(y_test_proba)

# 使用校准后的概率进行预测
y_train_pred_calibrated = (y_train_calibrated > 0.5).astype(int)
y_test_pred_calibrated = (y_test_calibrated > 0.5).astype(int)

# 计算混淆矩阵
cm_train = confusion_matrix(y_train, y_train_pred_calibrated)
cm_test = confusion_matrix(y_test, y_test_pred_calibrated)

# 打印结果
print("训练集混淆矩阵:")
print(cm_train)
print("测试集混淆矩阵:")
print(cm_test)

# 计算并打印Brier分数(用于衡量校准效果)
brier_score_train = brier_score_loss(y_train, y_train_calibrated)
brier_score_test = brier_score_loss(y_test, y_test_calibrated)
print("训练集Brier分数:", brier_score_train)
print("测试集Brier分数:", brier_score_test)

#绘画测试集混淆矩阵
classes = list(set(y_test))
classes.sort()
plt.imshow(cm_test, cmap=plt.cm.Blues)
indices = range(len(cm_test))
plt.xticks(indices, classes)
plt.yticks(indices, classes)
plt.colorbar()
plt.xlabel('guess')
plt.ylabel('fact')
for first_index in range(len(cm_test)):
    for second_index in range(len(cm_test[first_index])):
        plt.text(first_index, second_index, cm_test[first_index][second_index])
 
plt.show()  

#绘画训练集混淆矩阵
classes = list(set(y_train))
classes.sort()
plt.imshow(cm_train, cmap=plt.cm.Blues)
indices = range(len(cm_train))
plt.xticks(indices, classes)
plt.yticks(indices, classes)
plt.colorbar()
plt.xlabel('guess')
plt.ylabel('fact')
for first_index in range(len(cm_train)):
    for second_index in range(len(cm_train[first_index])):
        plt.text(first_index, second_index, cm_train[first_index][second_index])
 
plt.show() 
 
import math
from sklearn.metrics import confusion_matrix,roc_auc_score,auc,roc_curve
# 计算各项性能指标
def calculate_metrics(cm, y_true, y_proba):
    a = cm[0, 0]
    b = cm[0, 1]
    c = cm[1, 0]
    d = cm[1, 1]
    acc = (a + d) / (a + b + c + d)
    error_rate = 1 - acc
    sen = d / (d + c)
    sep = a / (a + b)
    precision = d / (b + d)
    F1 = (2 * precision * sen) / (precision + sen)
    MCC = (d * a - b * c) / (math.sqrt((d + b) * (d + c) * (a + b) * (a + c)))
    auc = roc_auc_score(y_true, y_proba)
    return acc, error_rate, sen, sep, precision, F1, MCC, auc

# 测试集指标
test_metrics = calculate_metrics(cm_test, y_test, y_test_calibrated)
# 训练集指标
train_metrics = calculate_metrics(cm_train, y_train, y_train_calibrated)

# 打印结果
print("训练集混淆矩阵:")
print(cm_train)
print("测试集混淆矩阵:")
print(cm_test)

print("训练集指标:")
print(f"准确率: {train_metrics[0]:.4f}, 错误率: {train_metrics[1]:.4f}, 敏感度: {train_metrics[2]:.4f}, 特异度: {train_metrics[3]:.4f}, 精确度: {train_metrics[4]:.4f}, F1分数: {train_metrics[5]:.4f}, MCC: {train_metrics[6]:.4f}, AUC: {train_metrics[7]:.4f}")

print("测试集指标:")
print(f"准确率: {test_metrics[0]:.4f}, 错误率: {test_metrics[1]:.4f}, 敏感度: {test_metrics[2]:.4f}, 特异度: {test_metrics[3]:.4f}, 精确度: {test_metrics[4]:.4f}, F1分数: {test_metrics[5]:.4f}, MCC: {test_metrics[6]:.4f}, AUC: {test_metrics[7]:.4f}")

看看结果:

总体来看,作用不是太大呢。训练集的AUC高了0.2,但是验证集的AUC又低了0.2,真能量守恒定律。

四、换个策略

参考那篇文章的策略:采用五折交叉验证来建立和评估模型,其中四折用于训练,一折用于评估,在训练集中,其中三折用于建立LR模型,另一折采用保序回归(Isotonic regression)进行概率校正,在训练集内部采用交叉验证对超参数进行调参。

代码:

import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from sklearn.model_selection import train_test_split, KFold, GridSearchCV
from sklearn.preprocessing import StandardScaler
from sklearn.linear_model import LogisticRegression
from sklearn.isotonic import IsotonicRegression
from sklearn.metrics import confusion_matrix, roc_auc_score, brier_score_loss, roc_curve

# 读取数据
dataset = pd.read_csv('8PSMjianmo.csv')
X = dataset.iloc[:, 1:20].values
Y = dataset.iloc[:, 0].values

# 分割数据集
X_train, X_test, y_train, y_test = train_test_split(X, Y, test_size=0.30, random_state=666)

# 标准化数据
sc = StandardScaler()
X_train = sc.fit_transform(X_train)
X_test = sc.transform(X_test)

# 计算并打印性能参数
def calculate_metrics(cm, y_true, y_proba):
    a = cm[0, 0]
    b = cm[0, 1]
    c = cm[1, 0]
    d = cm[1, 1]
    acc = (a + d) / (a + b + c + d)
    error_rate = 1 - acc
    sen = d / (d + c)
    sep = a / (a + b)
    precision = d / (b + d)
    F1 = (2 * precision * sen) / (precision + sen)
    MCC = (d * a - b * c) / (np.sqrt((d + b) * (d + c) * (a + b) * (a + c)))
    auc = roc_auc_score(y_true, y_proba)
    metrics = {
        "Accuracy": acc,
        "Error Rate": error_rate,
        "Sensitivity": sen,
        "Specificity": sep,
        "Precision": precision,
        "F1 Score": F1,
        "MCC": MCC,
        "AUC": auc
    }
    return metrics

# 五折交叉验证
kf = KFold(n_splits=5, shuffle=True, random_state=666)

test_metrics_list = []
train_metrics_list = []
best_params = None

for train_index, val_index in kf.split(X_train):
    X_train_fold, X_val_fold = X_train[train_index], X_train[val_index]
    y_train_fold, y_val_fold = y_train[train_index], y_train[val_index]

    # 再次划分训练集和验证集,用于等渗回归
    inner_kf = KFold(n_splits=4, shuffle=True, random_state=666)
    for inner_train_index, inner_calib_index in inner_kf.split(X_train_fold):
        X_inner_train, X_inner_calib = X_train_fold[inner_train_index], X_train_fold[inner_calib_index]
        y_inner_train, y_inner_calib = y_train_fold[inner_train_index], y_train_fold[inner_calib_index]

        # 超参数调优
        param_grid = {
            'C': [0.01, 0.1, 1, 10, 100],
            'solver': ['liblinear', 'lbfgs']
        }
        grid_search = GridSearchCV(LogisticRegression(random_state=666, max_iter=10000), param_grid, cv=3, n_jobs=-1, scoring='roc_auc')
        grid_search.fit(X_inner_train, y_inner_train)
        best_lr = grid_search.best_estimator_
        best_params = grid_search.best_params_

        # 训练最佳模型
        best_lr.fit(X_inner_train, y_inner_train)
        y_inner_train_proba = best_lr.predict_proba(X_inner_train)[:, 1]
        y_inner_calib_proba = best_lr.predict_proba(X_inner_calib)[:, 1]

        # 使用等渗回归进行概率校准
        iso_reg = IsotonicRegression(out_of_bounds='clip')
        iso_reg.fit(y_inner_calib_proba, y_inner_calib)

        y_inner_train_calibrated = iso_reg.transform(y_inner_train_proba)
        y_inner_calib_calibrated = iso_reg.transform(y_inner_calib_proba)

        # 使用校准后的概率进行预测
        y_inner_train_pred_calibrated = (y_inner_train_calibrated > 0.5).astype(int)
        y_inner_calib_pred_calibrated = (y_inner_calib_calibrated > 0.5).astype(int)

        # 计算混淆矩阵
        cm_inner_train = confusion_matrix(y_inner_train, y_inner_train_pred_calibrated)
        cm_inner_calib = confusion_matrix(y_inner_calib, y_inner_calib_pred_calibrated)

        # 计算性能指标
        train_metrics = calculate_metrics(cm_inner_train, y_inner_train, y_inner_train_calibrated)
        test_metrics = calculate_metrics(cm_inner_calib, y_inner_calib, y_inner_calib_calibrated)

        train_metrics_list.append(train_metrics)
        test_metrics_list.append(test_metrics)

        # 打印训练集和测试集的性能指标
        print("Inner Fold Training Metrics:")
        for key, value in train_metrics.items():
            print(f"{key}: {value:.4f}")
        
        print("Inner Fold Test Metrics:")
        for key, value in test_metrics.items():
            print(f"{key}: {value:.4f}")

# 计算并打印整体性能指标
avg_train_metrics = {key: np.mean([metrics[key] for metrics in train_metrics_list]) for key in train_metrics_list[0].keys()}
avg_test_metrics = {key: np.mean([metrics[key] for metrics in test_metrics_list]) for key in test_metrics_list[0].keys()}

print("Average Training Metrics:")
for key, value in avg_train_metrics.items():
    print(f"{key}: {value:.4f}")

print("Average Test Metrics:")
for key, value in avg_test_metrics.items():
    print(f"{key}: {value:.4f}")

# 打印最优参数
print("Best Logistic Regression Parameters:")
print(best_params)

# 使用校准后的模型预测测试集
best_lr.fit(X_train, y_train)
y_train_proba = best_lr.predict_proba(X_train)[:, 1]
y_test_proba = best_lr.predict_proba(X_test)[:, 1]
y_train_calibrated = iso_reg.transform(y_train_proba)
y_test_calibrated = iso_reg.transform(y_test_proba)
y_train_pred_calibrated = (y_train_calibrated > 0.5).astype(int)
y_test_pred_calibrated = (y_test_calibrated > 0.5).astype(int)

# 计算训练集和测试集混淆矩阵
cm_train = confusion_matrix(y_train, y_train_pred_calibrated)
cm_test = confusion_matrix(y_test, y_test_pred_calibrated)
print("训练集混淆矩阵:")
print(cm_train)
print("测试集混淆矩阵:")
print(cm_test)

# 计算并打印Brier分数(用于衡量校准效果)
brier_score_train = brier_score_loss(y_train, y_train_calibrated)
brier_score_test = brier_score_loss(y_test, y_test_calibrated)
print("训练集Brier分数:", brier_score_train)
print("测试集Brier分数:", brier_score_test)

# 计算训练集和测试集性能指标
train_metrics_final = calculate_metrics(cm_train, y_train, y_train_calibrated)
test_metrics_final = calculate_metrics(cm_test, y_test, y_test_calibrated)
print("Train Set Performance Metrics:")
for key, value in train_metrics_final.items():
    print(f"{key}: {value:.4f}")

print("Test Set Performance Metrics:")
for key, value in test_metrics_final.items():
    print(f"{key}: {value:.4f}")

# 绘制训练集和测试集ROC曲线
fpr_train, tpr_train, thresholds_train = roc_curve(y_train, y_train_calibrated, pos_label=1, drop_intermediate=False)
fpr_test, tpr_test, thresholds_test = roc_curve(y_test, y_test_calibrated, pos_label=1, drop_intermediate=False)

plt.figure(figsize=(12, 6))
plt.subplot(1, 2, 1)
plt.plot([0, 1], [0, 1], '--', color='navy')
plt.plot(fpr_train, tpr_train, 'k--', label='Mean ROC (area = {0:.4f})'.format(train_metrics_final['AUC']), lw=2, color='darkorange')
plt.xlim([-0.01, 1.01])
plt.ylim([-0.01, 1.01])
plt.xlabel('False Positive Rate')
plt.ylabel('True Positive Rate')
plt.title('ROC Curve for Training Set')
plt.legend(loc="lower right")

plt.subplot(1, 2, 2)
plt.plot([0, 1], [0, 1], '--', color='navy')
plt.plot(fpr_test, tpr_test, 'k--', label='Mean ROC (area = {0:.4f})'.format(test_metrics_final['AUC']), lw=2, color='darkorange')
plt.xlim([-0.01, 1.01])
plt.ylim([-0.01, 1.01])
plt.xlabel('False Positive Rate')
plt.ylabel('True Positive Rate')
plt.title('ROC Curve for Test Set')
plt.legend(loc="lower right")

plt.tight_layout()
plt.show()

输出:

有点用,但不多。

五、最后

各位可以去试一试在其他数据或者在其他机器学习分类模型中使用的效果。

数据不分享啦。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2034310.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

C语言中的结构体和位移段

在C语言中,结构体(struct)是一种用户自定义的数据类型,允许我们将不同类型的变量组合在一起,形成一个复合数据类型。结构体可以包含整型、浮点型、字符型等多种数据类型的成员。例如,我们可以定义一个表示人…

使用C语言构建Lua库

Lua 本身是用 C 语言编写的,因此使用 C 编写扩展可以更好地与 Lua 引擎集成,减少性能瓶颈,同时C 语言提供了对底层硬件和操作系统功能的直接访问能力,让 Lua 可以通过 C 扩展来实现对文件系统、网络等高级功能的支持。因为C 语言非…

The First项目报告:Web3人生模拟器,DegenReborn带你重开币圈

2023年6月14日,ReadON APP的首页上,一篇引人注目的文章《黑客马拉松奖:‘Degenreborn’——Meme与GameFi的梦幻交汇》跃然眼前,该文章巧妙融合了NFT、GameFi及Ethereum等热门话题,为读者带来了一场科技与娱乐的盛宴。 …

万字详述haproxy

目录 写在前面 1、Haproxy简介 2、Haproxy的安装和基本配置信息 2.1、haproxy的安装 2.2haproxy的基本配置信息 2.2.1基本配置文件global参数 2.2.2基本配置文件proxys的相关参数 2.2.2.1 default的相关参数 2.2.2.2 frontend的相关配置 2.2.2.3 backend的相关配置 …

24年下半年软考只剩下3个月时间,来得及准备吗?

过来人告诉你来得及,但是选对科目很重要! 一般来说,自学备考软考的时间为4-5个月,如果大家现在才开始备考的话,时间就有点紧张了,需要加倍努力才行,推荐大家可以报考一些相对简单的科目&#x…

Windows Server 2012 R2服务器安装CVE-2024-38077补丁KB5040456的安装及问题解决

Windows 远程桌面授权服务远程代码执行漏洞CVE-2024-38077,该漏洞影响: 远程执行代码,漏洞最高严重性: 严重。本文记录了Windows Server 2012 R2服务器补丁KB5040456的安装及报错“此更新不适用于你的计算机”的问题解决过程。 一、漏洞相关信息 1.影响…

具有 SAM2 分段的 NDVI 无人机

在我们之前的博客文章《OAK相机扩展NDVI功能检测植物健康情况》中,我们探讨了 NDVI 方法以及如何使用多光谱相机计算它。 今天,我们通过使用带有多光谱相机的无人机并使用 SAM2 模型进行场分割和健康比较,将 NDVI 感知提升到一个新的水平。 …

基于Python的孔夫子旧书网热销书籍爬虫与可视化分析报告

摘要:随着社会的不断发展,数据时代的到来,数据的背后是什么,数据有什么用,怎么用庞大的数据来呈现出数据的价值,让我们一起去揭开它神秘的面纱。 以孔夫子旧书网热销书籍5本图书数据爬取为例,介…

免费录屏软件之QQ

录屏太简单了 1、首先下载QQ 2、在随便打开个对话框,再操作1、2步骤即可 3、嫌打开对话框麻烦? 4、打开QQ后直接按下CtrlAltR即可录屏,连对话框都不用打开了,按完快捷键后效果如下: 5、点击右下角开始录屏即可

想在官网中放可以720°交互的3D模型,怎么做?

在官网中放置可以交互的3D模型,可以通过以下步骤实现: 一、准备3D模型 1、设计3D模型: 使用专业的3D建模软件(如Blender、3ds Max、Maya等)制作符合需求的3D模型。确保模型的尺寸、比例和细节都符合实际要求。 2、…

斜坡函数在PLC中的应用

最近在做项目的时候用到了通过模拟量输出控制设备速度快慢。因为之前大多数是通过端子控制或者是总线的控制方式来控制速度,因此首先尝试了端子控制模拟速度输出。但是由于加速度过大导致设备启动后会快速加速,停止时也会快速减速,不够平滑。…

数据库:数据查询

1 实验目的 掌握SQL语言的数据查询语句,具体包括: SELECT语句的基本用法 使用WHERE子句进行有条件的查询 使用IN,NOT IN,BETWEEN等谓词查询 利用LIKE子句实现模糊查询 利用ORDER子句为结果排序 用…

SQL Server 2022的游标

《SQL Server 2022从入门到精通(视频教学超值版)》图书介绍-CSDN博客 《SQL Server 2022从入门到精通(视频教学超值版)(数据库技术丛书)》(王英英)【摘要 书评 试读】- 京东图书 (jd.com) 游标是SQL Serv…

使用 CSS 打印样式为 Web 页面设置专业的打印机效果

对于有打印需求的网页,特别是文章的详情页,需要设置专门的打印样式来适配页面。CSS 打印样式允许你为网页设置专门用于打印的样式。文本就是专门介绍如何使用 CSS 打印样式为 Web 页面设置专业的打印机效果。 media print 通过使用 media print 媒体查…

【轨物洞见】当下是技术创新的好时机

“创新之父”熊比特认为,创新是一个经济学名词,是一种新的生产函数,即通过重新组合从未有过的生产要素来引入现有的生产过程,判断创新的关键是有没有创造价值。熊比特认为,创新是经济发展的根本动力,它包括…

[LitCTF 2023]debase64-入土为安的第十八天

点进去sub_401520(v15, (int)v4) if ( !*a1 )return 0;v2 a1 4;v3 a1;v4 0;v5 0;v13 0;while ( 1 ){v14 -1;for ( i 0; i ! 64; i ){while ( byte_404000[i] ! *v3 ){if ( i 64 )goto LABEL_7;}LOBYTE(v14) i;} LABEL_7:LOBYTE(i) 0;do{while ( byte_404000[i] ! a1…

【三维重建】SpotlessSplats:去除瞬态干扰物的三维高斯喷溅(3DGS)

代码:https://spotlesssplats.github.io 论文:https://arxiv.org/pdf/2406.20055 来源:DeepMind,多伦多大学,斯坦福大学,西蒙弗雷泽大学 提示:关注B站【方矩实验室】,查看视频讲解…

【SQL】有趣的电影

目录 题目 分析 代码 题目 表:cinema -------------------------- | Column Name | Type | -------------------------- | id | int | | movie | varchar | | description | varchar | | rating | float | -…

JDBC如何避免SQL注入

JDBC如何避免SQL注入 一 . 什么是SQL注入 SQL注入(SQL Injection)是一种代码注入技术,它允许攻击者将或“注入”恶意的SQL命令到后端数据库引擎执行。这些恶意的SQL命令可以执行未授权的数据库查询、修改数据、管理数据库服务器上的文件系统…

2024.8.12 作业

TCP服务器端代码实现 #include <myhead.h> #define SER_PORT 6666 #define SER_IP "192.168.254.129" int main(int argc,const char *argv[]) {//1.创建套接字文件int sfd socket(AF_INET,SOCK_STREAM,0);if(sfd-1){perror("socket error");retur…