DAY 22 复习日

@浙大疏锦行复习日

仔细回顾一下之前21天的内容,没跟上进度的同学补一下进度。

作业:

自行学习参考如何使用kaggle平台,写下使用注意点,并对下述比赛提交代码

导入需要的库

import pandas as pd  # 用于数据处理和分析,可处理表格数据。
import numpy as np  # 用于数值计算,提供了高效的数组操作。
import matplotlib.pyplot as plt  # 用于绘制各种类型的图表
import seaborn as sns  # 基于matplotlib的高级绘图库,能绘制更美观的统计图形。
import warnings
from sklearn.preprocessing import StandardScaler,MinMaxScaler
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestClassifier #随机森林分类器
from sklearn.metrics import  make_scorer,accuracy_score, precision_score, recall_score, f1_score # 用于评估分类器性能的指标
from sklearn.metrics import classification_report, confusion_matrix #用于生成分类报告和混淆矩阵
plt.rcParams['figure.dpi'] = 300
warnings.filterwarnings("ignore")
# 设置中文字体(解决中文显示问题)
plt.rcParams['font.sans-serif'] = ['SimHei']  # Windows系统常用黑体字体
plt.rcParams['axes.unicode_minus'] = False  # 正常显示负号
train = pd.read_csv('train.csv')  # 读取数据
print(train.isnull().sum())

Survived 是否存活(label)
PassengerId (乘客ID)
Pclass(用户阶级):1 - 1st class,高等用户;2 - 2nd class,中等用户;3 - 3rd class,低等用户;
Name(名字)
Sex(性别)
Age(年龄)
SibSp:描述了泰坦尼克号上与乘客同行的兄弟姐妹(Siblings)和配偶(Spouse)数目;
Parch:描述了泰坦尼克号上与乘客同行的家长(Parents)和孩子(Children)数目;
Ticket(船票号)
Fare(乘客费用)
Cabin(船舱)
Embarked(港口):用户上船时的港口

PassengerId(乘客ID),Name(姓名),Ticket(船票信息)存在唯一性,三类意义不大,可以考虑不加入后续的分析

看一下训练集有没有缺失值

可以看到Age,Cabin,Embarked有缺失值

#对Age使用中位数填充
median_income = train['Age'].median()
train['Age'].fillna(median_income, inplace=True)mode = train['Embarked'].mode()
print(mode)
mode = mode[0]
# 众数填补
train['Embarked'].fillna(mode, inplace=True)
# 检查下是否有缺失值
print(train['Embarked'].isnull().sum())# 对 Cabin 列的缺失值填充为 'U'
train['Cabin'] = train['Cabin'].fillna('U')
print(train.isnull().sum())

现在已无缺失值

对数据做一下分析

对数据的认识是十分重要的,所以我们在这里进行对各个字段的分析,看看每个属性与最后的Survived有什么关系
 

# 统计存活(Survived=1)和死亡(Survived=0)的人数
survived_counts = train['Survived'].value_counts()# 设置Seaborn风格
sns.set_style('ticks')# 配置中文字体,解决中文显示异常问题
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False# 创建画布,设置饼图为正圆形(figsize设为正方形)
fig, ax = plt.subplots(figsize=(6, 6))# 绘制饼图
survived_counts.plot.pie(ax=ax,autopct='%1.2f%%',  # 显示百分比,保留2位小数labels=['死亡', '存活'],  # 自定义图例标签colors=['#FF6B6B', '#4ECDC4'],  # 自定义颜色,红色代表死亡,青色代表存活startangle=90,  # 饼图从正上方开始绘制textprops={'fontsize': 12}  # 设置百分比文字大小
)# 设置标题
ax.set_title('泰坦尼克号乘客存活比例', fontsize=14, fontweight='bold', pad=20)
ax.set_ylabel('')  # 移除默认的y轴标签# 移除顶部和右侧的边框,让图表更简洁
sns.despine(top=True, right=True)# 自动调整布局,防止元素重叠
plt.tight_layout()
plt.show()

在这次中,大约有38.38%的人存活了下来

分别看一下各属性的基本分布情况,首先我们对适合利用图形展示的属性,通过绘图的方式探查属性的分布,分类型和数值型数据非常适合绘图,所以这部分我们选择乘客等级、性别、年龄、票价和登船港口五类属性。

# 绘图
fig = plt.figure()
# 乘客等级分布
plt.subplot2grid((2, 3), (0, 0))
train['Pclass'].value_counts().plot(kind='bar')
plt.ylabel(u"人数")
plt.xlabel(u'乘客等级')
plt.title(u'乘客等级分布')# 乘客性别分布
plt.subplot2grid((2, 3), (0, 1))
train['Sex'].value_counts().plot(kind='bar')
plt.ylabel(u"人数")
plt.xlabel(u'性别')
plt.title(u'乘客性别分布')# 乘客的年龄分布
plt.subplot2grid((2, 3), (0, 2))
train['Age'].hist()
plt.xlabel(u'年龄')
plt.title(u'乘客年龄分布')# 票价的分布
plt.subplot2grid((2, 3), (1, 0))
train['Fare'].hist()
plt.xlabel(u'票价')
plt.title(u'船票票价分布')# 箱线图:票价的异常情况探查
plt.subplot2grid((2, 3), (1, 1))
train['Fare'].plot(kind='box')
plt.title(u'票价箱线图')# 登船港口的分布情况
plt.subplot2grid((2, 3), (1, 2))
train['Embarked'].value_counts().plot(kind='bar')
plt.xlabel(u'登船口')
plt.title(u'登船口乘客量分布')
plt.show()

对于乘客等级、性别、登船口这类类别型的属性,从柱状图上探查各类的分布情况,而对于年龄和票价这类连续型的属性,我们可以选择利用直方图查看属性的分布。从乘客等级分布的柱状图上,我们得到三等乘客人数最多,1等和2等的乘客相对较少(等级顺序:1>2>3);在性别上,男性多于女性;在登船港口上,发现人数从高到低的港口分别是S>C>Q;看一下年龄的分布情况,我们发现20~30岁区间的乘客人数最多。

分析Sex
# 男性和女性存活情况
train[['Sex','Survived']].groupby('Sex').mean().plot.bar()survive_sex=train.groupby(['Sex','Survived'])['Survived'].count()print('女性存活率%.2f%%,男性存活率%.2f%%' %(survive_sex.loc['female',1]/survive_sex.loc['female'].sum()*100,survive_sex.loc['male',1]/survive_sex.loc['male'].sum()*100))
plt.tight_layout()
plt.show()

女性存活率74.20%,男性存活率18.89%

从数据结果可以得出,女性存活率是更高的

分析Age

g = sns.FacetGrid(train, col='Survived')
g.map(plt.hist, 'Age', bins=20)
plt.tight_layout()
plt.show()

从上图可以看出,Age与survived是有关系的,因此需要作为特征保存

分析登陆港口

# 绘图
plt.figure(figsize=(10, 8), dpi=100)# 乘客的等级和获救情况的关系, 从结果上发现,1和2等级的乘客获救率明显高于3等级的乘客
p1 = plt.subplot(221)
Pclass_0 = train.loc[train['Survived'] == 0, 'Pclass'].value_counts()
Pclass_1 = train.loc[train['Survived'] == 1, 'Pclass'].value_counts()
df_pclass = pd.DataFrame({u'获救':Pclass_1,u'未获救':Pclass_0})
df_pclass.plot(kind='bar', ax=p1)
plt.title(u'不同等级乘客的获救情况')# 同样的方法,我们看一下性别和获救情况的关系,结果非常明显,女性比男性的获救率高
p2 = plt.subplot(222)
Survived_m = train.loc[train['Sex'] == 'male', 'Survived'].value_counts()
Survived_f = train.loc[train['Sex'] == 'female', 'Survived'].value_counts()
df_sex = pd.DataFrame({u'男性':Survived_m, u'女性':Survived_f})
df_sex.plot(kind='bar', stacked=True, ax=p2)
plt.title(u'不同性别乘客的获救情况')# 年龄划分,划分的标准:0~10为儿童;10~60为成年人;60及以上为老年人
p3 = plt.subplot(223)
bins = [min(train['Age']), 10, 60, max(train['Age'])]
bins_label = ['10岁及以下', '10-60岁', '60岁以上']
train['Age_cut'] = pd.cut(train['Age'], bins=bins, labels=bins_label)
print(train['Age_cut'].value_counts())
# 再对数据进行统计,结果发现儿童的获救率明显高于成年人和老年人
Age_0 = train.loc[train['Survived'] == 0, 'Age_cut'].value_counts()
Age_1 = train.loc[train['Survived'] == 1, 'Age_cut'].value_counts()
df_age = pd.DataFrame({u'获救':Age_1, u'未获救':Age_0})
df_age.plot(kind='bar', ax=p3)
plt.title(u'不同年龄阶段乘客的获救情况')
plt.show()

从图中得的以下结论:等级高的乘客获救率高(1>2>3);女性获救率远大于男性

其次,针对类别较多的SibSp和Parch属性,我们直接统计各类的是否获救情况。

# 堂兄弟妹个数以及父母子女个数的获救情况统计
g1 = train.groupby(['SibSp', 'Survived'])
df_SibSp = pd.DataFrame(g1.count()['PassengerId'])
df_SibSp.rename(columns={'PassengerId':'count'}, inplace=True)
print(df_SibSp)g2 = train.groupby(['Parch', 'Survived'])
df_Parch = pd.DataFrame(g2.count()['PassengerId'])
df_Parch.rename(columns={'PassengerId': 'count'}, inplace=True)
print(df_Parch)

从结果中,我们发现,SibSp<3和Parch<3的情况下,获救率更高。

分析Fare
print(train.loc[train['Fare'] == 0, 'Survived'].value_counts())
print(train.loc[train['Fare'] == max(train['Fare']), 'Survived'].value_counts())
plt.show()

结果发现,票价为0的15名乘客,仅有1人获救,而票价最高的三名乘客,全部获救,这说明了票价的高低对是否获救存在影响

#删除无用特征Name、Ticket 、Cabin
train= train.drop(columns=["Name","Ticket","Cabin"])#接下来对sex、embarked进行独热编码
# 对Sex、Embarked进行独热编码
train["Sex"] = pd.get_dummies(train["Sex"], dtype=int, drop_first=True)
train_data = pd.concat([train.drop("Embarked", axis=1),pd.get_dummies(train["Embarked"], prefix="Embarked", dtype=int, drop_first=False)], axis=1)# 查看数据
print(train_data.head(10))#对测试集进行处理
# 删除无用特征Name、Ticket 、Cabin,补全缺失值
test = pd.read_csv('test.csv')  # 读取数据
test = test.drop(columns=["Name", "Ticket", "Cabin"])# 连续
continuous_features = test.select_dtypes(include=['float64', 'int64']).columns.tolist()
# 离散
discrete_features = test.select_dtypes(exclude=['float64', 'int64']).columns.tolist()# 离散特征使用众数进行补全
for feature in discrete_features:if test[feature].isnull().sum() > 0:mode_value = test[feature].mode()[0]test[feature].fillna(mode_value, inplace=True)# 连续变量用中位数进行补全
for feature in continuous_features:if test[feature].isnull().sum() > 0:median_value = test[feature].median()test[feature].fillna(median_value, inplace=True)
print(test.info())print(test.head(10))# 对Sex、Embarked进行独热编码
test["Sex"] = pd.get_dummies(test["Sex"], dtype=int, drop_first=True)
test_data = pd.concat([test.drop("Embarked", axis=1),pd.get_dummies(test["Embarked"], prefix="Embarked", dtype=int, drop_first=False)], axis=1)# 查看数据
print(test_data.head(10))from sklearn.model_selection import train_test_split
X = train_data.drop(['Survived'], axis=1)  # 特征,axis=1表示按列删除
y = train_data['Survived']  # 标签
# 按照8:2划分训练集和测试集
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)  # 80%训练集,20%测试集# SVM
svm_model = SVC(random_state=42)
svm_model.fit(X_train, y_train)
svm_pred = svm_model.predict(X_test)print("\nSVM 分类报告:")
print(classification_report(y_test, svm_pred))  # 打印分类报告
print("SVM 混淆矩阵:")
print(confusion_matrix(y_test, svm_pred))  # 打印混淆矩阵# 计算 SVM 评估指标,这些指标默认计算正类的性能
svm_accuracy = accuracy_score(y_test, svm_pred)
svm_precision = precision_score(y_test, svm_pred)
svm_recall = recall_score(y_test, svm_pred)
svm_f1 = f1_score(y_test, svm_pred)
print("SVM 模型评估指标:")
print(f"准确率: {svm_accuracy:.4f}")
print(f"精确率: {svm_precision:.4f}")
print(f"召回率: {svm_recall:.4f}")
print(f"F1 值: {svm_f1:.4f}")# KNN
knn_model = KNeighborsClassifier()
knn_model.fit(X_train, y_train)
knn_pred = knn_model.predict(X_test)print("\nKNN 分类报告:")
print(classification_report(y_test, knn_pred))
print("KNN 混淆矩阵:")
print(confusion_matrix(y_test, knn_pred))knn_accuracy = accuracy_score(y_test, knn_pred)
knn_precision = precision_score(y_test, knn_pred)
knn_recall = recall_score(y_test, knn_pred)
knn_f1 = f1_score(y_test, knn_pred)
print("KNN 模型评估指标:")
print(f"准确率: {knn_accuracy:.4f}")
print(f"精确率: {knn_precision:.4f}")
print(f"召回率: {knn_recall:.4f}")
print(f"F1 值: {knn_f1:.4f}")# 逻辑回归
logreg_model = LogisticRegression(random_state=42)
logreg_model.fit(X_train, y_train)
logreg_pred = logreg_model.predict(X_test)print("\n逻辑回归 分类报告:")
print(classification_report(y_test, logreg_pred))
print("逻辑回归 混淆矩阵:")
print(confusion_matrix(y_test, logreg_pred))logreg_accuracy = accuracy_score(y_test, logreg_pred)
logreg_precision = precision_score(y_test, logreg_pred)
logreg_recall = recall_score(y_test, logreg_pred)
logreg_f1 = f1_score(y_test, logreg_pred)
print("逻辑回归 模型评估指标:")
print(f"准确率: {logreg_accuracy:.4f}")
print(f"精确率: {logreg_precision:.4f}")
print(f"召回率: {logreg_recall:.4f}")
print(f"F1 值: {logreg_f1:.4f}")# 朴素贝叶斯
nb_model = GaussianNB()
nb_model.fit(X_train, y_train)
nb_pred = nb_model.predict(X_test)print("\n朴素贝叶斯 分类报告:")
print(classification_report(y_test, nb_pred))
print("朴素贝叶斯 混淆矩阵:")
print(confusion_matrix(y_test, nb_pred))nb_accuracy = accuracy_score(y_test, nb_pred)
nb_precision = precision_score(y_test, nb_pred)
nb_recall = recall_score(y_test, nb_pred)
nb_f1 = f1_score(y_test, nb_pred)
print("朴素贝叶斯 模型评估指标:")
print(f"准确率: {nb_accuracy:.4f}")
print(f"精确率: {nb_precision:.4f}")
print(f"召回率: {nb_recall:.4f}")
print(f"F1 值: {nb_f1:.4f}")# 决策树
dt_model = DecisionTreeClassifier(random_state=42)
dt_model.fit(X_train, y_train)
dt_pred = dt_model.predict(X_test)print("\n决策树 分类报告:")
print(classification_report(y_test, dt_pred))
print("决策树 混淆矩阵:")
print(confusion_matrix(y_test, dt_pred))dt_accuracy = accuracy_score(y_test, dt_pred)
dt_precision = precision_score(y_test, dt_pred)
dt_recall = recall_score(y_test, dt_pred)
dt_f1 = f1_score(y_test, dt_pred)
print("决策树 模型评估指标:")
print(f"准确率: {dt_accuracy:.4f}")
print(f"精确率: {dt_precision:.4f}")
print(f"召回率: {dt_recall:.4f}")
print(f"F1 值: {dt_f1:.4f}")# 随机森林
rf_model = RandomForestClassifier(random_state=42)
rf_model.fit(X_train, y_train)
rf_pred = rf_model.predict(X_test)print("\n随机森林 分类报告:")
print(classification_report(y_test, rf_pred))
print("随机森林 混淆矩阵:")
print(confusion_matrix(y_test, rf_pred))rf_accuracy = accuracy_score(y_test, rf_pred)
rf_precision = precision_score(y_test, rf_pred)
rf_recall = recall_score(y_test, rf_pred)
rf_f1 = f1_score(y_test, rf_pred)
print("随机森林 模型评估指标:")
print(f"准确率: {rf_accuracy:.4f}")
print(f"精确率: {rf_precision:.4f}")
print(f"召回率: {rf_recall:.4f}")
print(f"F1 值: {rf_f1:.4f}")# XGBoost
xgb_model = xgb.XGBClassifier(random_state=42)
xgb_model.fit(X_train, y_train)
xgb_pred = xgb_model.predict(X_test)print("\nXGBoost 分类报告:")
print(classification_report(y_test, xgb_pred))
print("XGBoost 混淆矩阵:")
print(confusion_matrix(y_test, xgb_pred))xgb_accuracy = accuracy_score(y_test, xgb_pred)
xgb_precision = precision_score(y_test, xgb_pred)
xgb_recall = recall_score(y_test, xgb_pred)
xgb_f1 = f1_score(y_test, xgb_pred)
print("XGBoost 模型评估指标:")
print(f"准确率: {xgb_accuracy:.4f}")
print(f"精确率: {xgb_precision:.4f}")
print(f"召回率: {xgb_recall:.4f}")
print(f"F1 值: {xgb_f1:.4f}")# LightGBM
lgb_model = lgb.LGBMClassifier(random_state=42)
lgb_model.fit(X_train, y_train)
lgb_pred = lgb_model.predict(X_test)print("\nLightGBM 分类报告:")
print(classification_report(y_test, lgb_pred))
print("LightGBM 混淆矩阵:")
print(confusion_matrix(y_test, lgb_pred))lgb_accuracy = accuracy_score(y_test, lgb_pred)
lgb_precision = precision_score(y_test, lgb_pred)
lgb_recall = recall_score(y_test, lgb_pred)
lgb_f1 = f1_score(y_test, lgb_pred)
print("LightGBM 模型评估指标:")
print(f"准确率: {lgb_accuracy:.4f}")
print(f"精确率: {lgb_precision:.4f}")
print(f"召回率: {lgb_recall:.4f}")
print(f"F1 值: {lgb_f1:.4f}")

SVM 分类报告:
              precision    recall  f1-score   support

           0       0.60      0.98      0.74       105
           1       0.67      0.05      0.10        74

    accuracy                           0.60       179
   macro avg       0.63      0.52      0.42       179
weighted avg       0.62      0.60      0.48       179

SVM 混淆矩阵:
[[103   2]
 [ 70   4]]
SVM 模型评估指标:
准确率: 0.5978
精确率: 0.6667
召回率: 0.0541
F1 值: 0.1000

KNN 分类报告:
              precision    recall  f1-score   support

           0       0.67      0.84      0.74       105
           1       0.64      0.41      0.50        74

    accuracy                           0.66       179
   macro avg       0.65      0.62      0.62       179
weighted avg       0.65      0.66      0.64       179

KNN 混淆矩阵:
[[88 17]
 [44 30]]
KNN 模型评估指标:
准确率: 0.6592
精确率: 0.6383
召回率: 0.4054
F1 值: 0.4959

逻辑回归 分类报告:
              precision    recall  f1-score   support

           0       0.79      0.88      0.83       105
           1       0.79      0.68      0.73        74

    accuracy                           0.79       179
   macro avg       0.79      0.78      0.78       179
weighted avg       0.79      0.79      0.79       179

逻辑回归 混淆矩阵:
[[92 13]
 [24 50]]
逻辑回归 模型评估指标:
准确率: 0.7933
精确率: 0.7937
召回率: 0.6757
F1 值: 0.7299

朴素贝叶斯 分类报告:
              precision    recall  f1-score   support

           0       0.83      0.77      0.80       105
           1       0.70      0.77      0.74        74

    accuracy                           0.77       179
   macro avg       0.77      0.77      0.77       179
weighted avg       0.78      0.77      0.77       179

朴素贝叶斯 混淆矩阵:
[[81 24]
 [17 57]]
朴素贝叶斯 模型评估指标:
准确率: 0.7709
精确率: 0.7037
召回率: 0.7703
F1 值: 0.7355

决策树 分类报告:
              precision    recall  f1-score   support

           0       0.78      0.79      0.79       105
           1       0.70      0.69      0.69        74

    accuracy                           0.75       179
   macro avg       0.74      0.74      0.74       179
weighted avg       0.75      0.75      0.75       179

决策树 混淆矩阵:
[[83 22]
 [23 51]]
决策树 模型评估指标:
准确率: 0.7486
精确率: 0.6986
召回率: 0.6892
F1 值: 0.6939

随机森林 分类报告:
              precision    recall  f1-score   support

           0       0.84      0.87      0.85       105
           1       0.80      0.77      0.79        74

    accuracy                           0.83       179
   macro avg       0.82      0.82      0.82       179
weighted avg       0.83      0.83      0.83       179

随机森林 混淆矩阵:
[[91 14]
 [17 57]]
随机森林 模型评估指标:
准确率: 0.8268
精确率: 0.8028
召回率: 0.7703
F1 值: 0.7862

XGBoost 分类报告:
              precision    recall  f1-score   support

           0       0.83      0.84      0.83       105
           1       0.77      0.76      0.76        74

    accuracy                           0.80       179
   macro avg       0.80      0.80      0.80       179
weighted avg       0.80      0.80      0.80       179

XGBoost 混淆矩阵:
[[88 17]
 [18 56]]
XGBoost 模型评估指标:
准确率: 0.8045
精确率: 0.7671
召回率: 0.7568
F1 值: 0.7619
 

LightGBM 分类报告:
              precision    recall  f1-score   support

           0       0.82      0.85      0.84       105
           1       0.77      0.74      0.76        74

    accuracy                           0.80       179
   macro avg       0.80      0.80      0.80       179
weighted avg       0.80      0.80      0.80       179

LightGBM 混淆矩阵:
[[89 16]
 [19 55]]
LightGBM 模型评估指标:
准确率: 0.8045
精确率: 0.7746
召回率: 0.7432
F1 值: 0.7586

综上比较几种模型,感觉随机森林更好一点,其实还能再调参或者其它的工作使得准确率更高一点
 

# 对测试集进行预测
test_pred = rf_model.predict(test)# 创建提交文件
submission = pd.DataFrame({'PassengerId': test['PassengerId'],  # 从测试数据中获取乘客ID'Survived': test_pred  # 模型预测的结果
})# 保存为CSV文件
submission.to_csv('titanic_submission.csv', index=False)

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

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

相关文章

biocmanager安装 库 老是提示网络连接错误 才尝试各种办法

您好&#xff0c;遇到 BioManager &#xff08;通常是 BiocManager&#xff09;安装R包时提示网络连接错误确实非常令人头疼。这通常与R/RStudio的配置、网络环境&#xff08;尤其是国内用户&#xff09;或SSL证书问题有关。 请不要着急&#xff0c;我们可以按照从易到难的顺序…

【开题答辩全过程】以 智能商品数据分析系统为例,包含答辩的问题和答案

个人简介一名14年经验的资深毕设内行人&#xff0c;语言擅长Java、php、微信小程序、Python、Golang、安卓Android等开发项目包括大数据、深度学习、网站、小程序、安卓、算法。平常会做一些项目定制化开发、代码讲解、答辩教学、文档编写、也懂一些降重方面的技巧。感谢大家的…

解构复杂财务逆向业务:如何优雅地生成与管理负数单?

文章目录一 核心复杂性二 关键设计模式&#xff1a;三 棘手场景与解决方案&#xff1a;1.分批合并处理&#xff1a;负数单需能智能拆分&#xff0c;精准冲销多批次的正向单据。2.优先级问题&#xff1a;3.超额处理&#xff1a;系统应坚决拦截而非处理&#xff0c;防止资金损失和…

Android集成OpenCV4实例

Android集成OpenCV4分以下几步骤&#xff1a; 使用Android Studio Giraffe | 2022.3.1创建一个Empty Views Activity空项目&#xff0c;包名为&#xff1a;com.example.andopencvdemo00 &#xff0c; 创建成功后&#xff0c;进行以下相关设置&#xff1a; 第一步&#xff1a;在…

npy可视化方法

npviewer 是一个应用程序&#xff0c;它允许您以热图的形式可视化 numpy 的 npy 文件中的数据。该应用程序根据不同的模式自动选择适当的维度进行显示。 根据不同的模式自动选择适当的维度进行显示支持不同格式的 numpy 数据的可视化&#xff0c;如 RGB 和灰度用户友好的界面使…

【Cesium】介绍及基础使用

文章目录一、Cesium 介绍二、 使用1、引入 cesium2、Viewer 配置选项1. 基础控件配置2. 场景与渲染配置3. 地形配置4. 天空与大气效果3、坐标系系统3.1 地理坐标系3.2 笛卡尔空间直角坐标系3.3 屏幕坐标系4、Entity 实体4.1 简介4.2 Entity 常见图形类型Point 点Polyline 线Pol…

基于SpringBoot的运动服装销售系统【2026最新】

作者&#xff1a;计算机学姐 开发技术&#xff1a;SpringBoot、SSM、Vue、MySQL、JSP、ElementUI、Python、小程序等&#xff0c;“文末源码”。 专栏推荐&#xff1a;前后端分离项目源码、SpringBoot项目源码、Vue项目源码、SSM项目源码、微信小程序源码 精品专栏&#xff1a;…

【嵌入式DIY实例-ESP32篇】-倾斜弹跳球游戏

倾斜弹跳球游戏 文章目录 倾斜弹跳球游戏 1、MPU6050介绍 2、硬件准备与接线 3、代码实现 在这个交互式 ESP32 Arduino 项目中,我们模拟了一个绿色球体在全彩 ST7789 170320 LCD 屏幕上弹跳,完全由 MPU6050 陀螺仪的运动控制。当你倾斜传感器时,球体会呈现出逼真的物理运动,…

从spring MVC角度理解HTTP协议及Request-Response模式

什么是HTTP协议&#xff1f;HTTP协议&#xff08;HyperText Transfer Protocol&#xff0c;超文本传输协议&#xff09;是一种通信规则&#xff0c;它定义了客户端&#xff08;如浏览器、手机APP&#xff09; 和服务器 之间如何交换信息&#xff0c;是用于在万维网&#xff08;…

江协科技STM32学习笔记补充之003 :STM32复位电路的详细分析

电路作用与每个器件R1&#xff08;10 kΩ&#xff0c;上拉到 3V3&#xff09;让 NRST 在无外力时保持高电平&#xff1d;不复位&#xff1b;同时与电容形成 RC&#xff0c;决定上电复位延时。阻值不能太小&#xff08;否则调试器或芯片复位驱动下拉电流太大&#xff09;&#x…

Spring Boot HTTP状态码详解

Spring Boot HTTP状态码完全指南&#xff1a;从入门到精通 前言 在RESTful API开发中&#xff0c;HTTP状态码是与客户端通信的重要桥梁。Spring Boot通过HttpStatus枚举提供了完整的HTTP状态码支持。本文将深入解析这些状态码的含义、使用场景以及在Spring Boot中的最佳实践。 …

怎样让外网计算机访问局域网计算机?通过公网地址访问不同内网服务的设置方法

局域网服务器提供公网访问&#xff0c;或指定某些端口应用资源给外地访问&#xff0c;都是常见跨网通信需求。在一些场景下&#xff0c;内部网络中的服务器需要通过公网地址进行访问&#xff0c;尤其是在没有固定公网IP或需要在外部访问时。为了解决这一问题&#xff0c;可以使…

Spring Boot启动失败从循环依赖到懒加载配置的深度排查指南

&#x1f49d;&#x1f49d;&#x1f49d;欢迎莅临我的博客&#xff0c;很高兴能够在这里和您见面&#xff01;希望您在这里可以感受到一份轻松愉快的氛围&#xff0c;不仅可以获得有趣的内容和知识&#xff0c;也可以畅所欲言、分享您的想法和见解。 持续学习&#xff0c;不断…

从零开始学大模型之大语言模型

大语言模型 4.1 什么是 LLM 在前三章&#xff0c;我们从 NLP 的定义与主要任务出发&#xff0c;介绍了引发 NLP 领域重大变革的核心思想——注意力机制与 Transformer 架构。随着 Transformer 架构的横空出世&#xff0c;NLP 领域逐步进入预训练-微调范式&#xff0c;以 Tran…

如何将视频从 iPhone 转移到 Mac

将视频从 iPhone 转移到 Mac 是许多用户常见的需求。无论你是想备份重要的视频&#xff0c;还是希望在更大的屏幕上观看&#xff0c;以下方法都能帮助你轻松完成。方法一&#xff1a;使用 iReaShare iPhone ManageriReaShare iPhone Manager 是一款功能强大的工具&#xff0c;可…

五、Docker 核心技术:容器数据持久化之数据卷

Docker 容器本身是无状态且生命周期短暂的。当一个容器被删除时&#xff0c;它在可写层产生的所有数据都会随之消失。这对于需要持久化存储数据的应用 (如数据库、日志系统、用户上传内容) 来说是不可接受的。为了解决这个问题&#xff0c;Docker 提供了多种数据持久化方案&…

前端视觉交互设计全解析:从悬停高亮到多维交互体系(含代码 + 图表)

在前端用户体验领域&#xff0c;视觉交互是连接用户与产品的 “隐形桥梁”—— 它通过可视化信号传递操作意图、反馈系统状态&#xff0c;直接决定用户对产品的感知。很多开发者对视觉交互的认知停留在 “鼠标悬停高亮”&#xff0c;但实际上&#xff0c;视觉交互是一个覆盖 “…

从零打造商业级LLMOps平台:开源项目LMForge详解,助力多模型AI Agent开发!

最近&#xff0c;我发现了一个超级实用的开源项目——LMForge-End-to-End-LLMOps-Platform-for-Multi-Model-Agents&#xff08;以下简称LMForge&#xff09;。这个项目是一个端到端的LLMOps&#xff08;Large Language Model Operations&#xff09;平台&#xff0c;专为多模型…

【C++练习】06.输出100以内的所有素数

目录输出100以内的所有素数方法1&#xff1a;基础判断法方法2&#xff1a;埃拉托斯特尼筛法&#xff08;效率更高&#xff09;方法3&#xff1a;优化版筛法&#xff08;只考虑奇数&#xff09;方法4&#xff1a;使用STL算法方法5&#xff1a;递归实现总结&#xff1a; 输出100以…

在开发中使用git rebase的场景

rebase介绍 一、背景 远程仓库有oh4w-dev和oh4k-dev两个分支&#xff0c;oh4k-dev是基于oh4w-dev开发到80%的代码新拉的分支&#xff1b;此后两条分支同步开发&#xff0c;当oh4k-dev开发完成&#xff0c;oh4w-dev还在开发阶段&#xff0c;oh4k-dev需要拉取到oh4w-dev自分出o…