24/9/19 算法笔记 kaggle BankChurn数据分类

题目是要预测银行里什么样的客户会流失,流失的概率是多少

我这边先展示一下我写的二分类的算法

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score, confusion_matrix, classification_report# 读取训练集和测试集数据
train = pd.read_csv("C:\\Users\\91144\\Desktop\\kaggle比赛数据\\Bank Churn 数据集进行二元分类\\playground-series-s4e1\\train.csv")
test = pd.read_csv("C:\\Users\\91144\\Desktop\\kaggle比赛数据\\Bank Churn 数据集进行二元分类\\playground-series-s4e1\\test.csv")# 删除不需要的列
data = train
data.drop(['id','CustomerId','Surname'],axis=1,inplace=True)# 对分类变量进行独热编码
object_cols = data.select_dtypes(include=['object']).columns
dumm = pd.get_dummies(data, columns=object_cols, prefix_sep='')# 数据缩放
data = dumm
data['CreditScore'] = (data['CreditScore'] - data['CreditScore'].min()) / (data['CreditScore'].max() - data['CreditScore'].min())
data['EstimatedSalary'] = (data['EstimatedSalary'] - data['EstimatedSalary'].min()) / (data['EstimatedSalary'].max() - data['EstimatedSalary'].min())# 划分训练集和测试集
X = data.drop('Exited',axis=1)  # 特征集 X
y = data['Exited']    # 标签集 y
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)# 使用逻辑回归模型进行训练和预测
LR = LogisticRegression()
LR.fit(X_train, y_train)
print('训练集准确率:\n', LR.score(X_train, y_train))
print('验证集准确率:\n', LR.score(X_test, y_test))# 对测试集进行预测
data = test
data.drop(['id','CustomerId','Surname'],axis=1,inplace=True)
object_cols = data.select_dtypes(include=['object']).columns
dumm = pd.get_dummies(data, columns=object_cols, prefix_sep='')# 数据缩放
data = dumm
data['CreditScore'] = (data['CreditScore'] - data['CreditScore'].min()) / (data['CreditScore'].max() - data['CreditScore'].min())
data['EstimatedSalary'] = (data['EstimatedSalary'] - data['EstimatedSalary'].min()) / (data['EstimatedSalary'].max() - data['EstimatedSalary'].min())# 进行预测
y_pred = LR.predict(data)
print(y_pred)# 将预测结果保存到CSV文件中
df = pd.read_csv("C:\\Users\\91144\\Desktop\\kaggle比赛数据\\Bank Churn 数据集进行二元分类\\playground-series-s4e1\\test.csv")
id = df['id']
result = pd.DataFrame({'id':id, 'Exited':y_pred})
result.to_csv('2combined_columns.csv', index=False)

但是我预测出来基本Exited全是0

这里我应该是特征处理做的太草率,或者是数据参数问题

跑了这么多分

然后加以了改进,我用到了管道,交叉验证

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split, GridSearchCV
from sklearn.linear_model import LogisticRegression
from sklearn.preprocessing import StandardScaler, OneHotEncoder
from sklearn.compose import ColumnTransformer
from sklearn.pipeline import Pipeline
from sklearn.metrics import accuracy_score, confusion_matrix, classification_report# 读取训练集和测试集数据
train = pd.read_csv("C:\\Users\\91144\\Desktop\\kaggle比赛数据\\Bank Churn 数据集进行二元分类\\playground-series-s4e1\\train.csv")
test = pd.read_csv("C:\\Users\\91144\\Desktop\\kaggle比赛数据\\Bank Churn 数据集进行二元分类\\playground-series-s4e1\\test.csv")# 删除不需要的列
train.drop(['id', 'CustomerId', 'Surname'], axis=1, inplace=True)
test.drop(['id', 'CustomerId', 'Surname'], axis=1, inplace=True)# 定义特征和目标变量
X = train.drop('Exited', axis=1)
y = train['Exited']# 划分训练集和验证集
X_train, X_val, y_train, y_val = train_test_split(X, y, test_size=0.2, random_state=42)# 定义数值和分类特征
num_cols = ['CreditScore', 'Age', 'Balance', 'EstimatedSalary']
cat_cols = ['Geography', 'Gender', 'Tenure', 'NumOfProducts', 'HasCrCard', 'IsActiveMember']# 创建预处理步骤
numeric_transformer = Pipeline(steps=[('scaler', StandardScaler())
])categorical_transformer = Pipeline(steps=[('onehot', OneHotEncoder(handle_unknown='ignore'))
])preprocessor = ColumnTransformer(transformers=[('num', numeric_transformer, num_cols),('cat', categorical_transformer, cat_cols)])# 创建逻辑回归模型的管道
model = Pipeline(steps=[('preprocessor', preprocessor),('classifier', LogisticRegression(max_iter=1000))
])
# 定义要尝试的参数网格
param_grid = {'classifier__C': [0.1, 1, 10],  # 逻辑回归的正则化强度'classifier__penalty': ['l1', 'l2']  # 正则化类型
}# 创建 GridSearchCV 对象
grid_search = GridSearchCV(estimator=model, param_grid=param_grid, cv=5, scoring='accuracy', verbose=1)# 训练模型
grid_search.fit(X_train, y_train)# 获取最佳参数和最佳模型
best_params = grid_search.best_params_
best_model = grid_search.best_estimator_# 训练模型
model.fit(X_train, y_train)# 验证模型
y_val_pred = best_model.predict(X_val)
print('验证集准确率:', accuracy_score(y_val, y_val_pred))
print(confusion_matrix(y_val, y_val_pred))
print(classification_report(y_val, y_val_pred))# 对测试集进行预测
test_predictions = best_model.predict(test)
test = pd.read_csv("C:\\Users\\91144\\Desktop\\kaggle比赛数据\\Bank Churn 数据集进行二元分类\\playground-series-s4e1\\test.csv")# 将预测结果保存到CSV文件中
submission = pd.DataFrame({'id': test['id'],  # 如果需要保留 id 列'Exited': test_predictions
})
submission.to_csv('3catboost_submission.csv', index=False)
print("Submission file created: catboost_submission.csv")
  1. 数据预处理整合到管道中:通过使用 ColumnTransformerPipeline,将数据预处理步骤(包括数值特征的标准化和分类特征的独热编码)整合到了模型训练的管道中。这样做的好处是,预处理步骤和模型训练步骤可以一起执行,简化了代码,并且确保了训练集和测试集使用相同的预处理步骤。

  2. 使用 GridSearchCV 进行参数调优:这是一个重要的改进,因为模型的性能很大程度上取决于其参数的设置。

  3. 避免数据泄露:通过在管道中整合预处理步骤,您确保了测试集的预测是在与训练集相同的预处理步骤之后进行的,这有助于避免数据泄露。

  4. 模型参数调整:在 LogisticRegression 中设置了 max_iter=1000,这有助于确保收敛,特别是在处理较大的数据集时。

跑了这么多分

然后还有一大佬写的用GBM梯度提升来做的

导入库

# import libraries# to handle the data
import pandas as pd
import numpy as np# to visualize the dataset
import matplotlib.pyplot as plt
import seaborn as sns
import plotly.graph_objects as go# to preprocess the data
from sklearn.preprocessing import MinMaxScaler, LabelEncoder #用于将特征缩放到给定的最小值和最大值之间。#用于将标签编码为从0开始的连续整数# machine learning
from sklearn.model_selection import StratifiedKFold
from sklearn.feature_extraction.text import TfidfVectorizer #用于将文本数据转换为TF-IDF特征向量。
from sklearn.decomposition import TruncatedSVD  #用于降维的奇异值分解(SVD)方法。
from sklearn.model_selection import cross_val_score# model
import lightgbm as lgb
from catboost import CatBoostClassifier, Pool
import xgboost as xgb# evaluation
from sklearn.metrics import roc_auc_score, accuracy_score# max columns 
pd.set_option('display.max_columns', None)# hide warnings
import warnings
warnings.filterwarnings('ignore')

数据

df_train = pd.read_csv("C:\\Users\\91144\\Desktop\\kaggle比赛数据\\Bank Churn 数据集进行二元分类\\playground-series-s4e1\\train.csv")
df_test = pd.read_csv("C:\\Users\\91144\\Desktop\\kaggle比赛数据\\Bank Churn 数据集进行二元分类\\playground-series-s4e1\\test.csv")

处理缺失值

#缺失值
train_null = df_train.isnull().sum().sum()
test_null = df_test.isnull().sum().sum()
print(f"Null count in Training Data: {train_null}")
print(f"Null count in Test Data: {test_null}")

处理重复值

#重复值
train_duplicate = df_train.drop("id",axis = 1).duplicated().sum()
test_duplicate = df_test.drop("id",axis = 1).duplicated().sum()
print(f"Duplicate count in Training Data: {train_duplicate}")
print(f"Duplicate count in Test Data: {test_duplicate}")
df_train.info()

df_train.describe().T

查看各个特征对流失率的影响

#目标变量是不平衡的,所以我们对这个不平衡的数据集使用分层交叉验证
fig, ax = plt.subplots(figsize=(9, 4))# Create the count plot
sns.countplot(y="Exited", data=df_train, ax=ax, palette="deep")# Customize the plot
ax.set_title("Distribution of Exited", fontsize=18, fontweight='semibold', pad=20)
ax.set_xlabel("Count", fontsize=14, labelpad=10)
ax.set_ylabel("Exited", fontsize=14, labelpad=10)# Add value labels to the bars
for container in ax.containers:ax.bar_label(container, label_type='center', fontsize=12, padding=5, color='white', fontweight='bold')plt.show()

# Create the figure and axes
fig, ax = plt.subplots(figsize=(9, 4))# Create the count plot
sns.countplot(y="Gender", data=df_train, ax=ax, palette="deep")# Customize the plot
ax.set_title("Distribution of Gender", fontsize=18, fontweight='semibold', pad=20)
ax.set_xlabel("Count", fontsize=14, labelpad=10)
ax.set_ylabel("Gender", fontsize=14, labelpad=10)# Add value labels to the bars
for container in ax.containers:ax.bar_label(container, label_type='center', fontsize=12, padding=5, color='white', fontweight='bold')plt.show()

# Create the figure and axes
fig, ax = plt.subplots(figsize=(9, 4))# Create the count plot
sns.countplot(y="Tenure", data=df_train, ax=ax, palette="deep")# Customize the plot
ax.set_title("Distribution of Tenure", fontsize=18, fontweight='semibold', pad=20)
ax.set_xlabel("Count", fontsize=14, labelpad=10)
ax.set_ylabel("Tenure", fontsize=14, labelpad=10)# Add value labels to the bars
for container in ax.containers:ax.bar_label(container, label_type='edge', fontsize=10, padding=2, color='black', fontweight='normal')# Adjust layout to prevent label cutoff
plt.tight_layout()plt.show()

# Create the figure and axes
fig, ax = plt.subplots(figsize=(9, 4))# Create the count plot
sns.countplot(y="NumOfProducts", data=df_train, ax=ax, palette="deep")# Customize the plot
ax.set_title("Distribution of NumOfProducts", fontsize=18, fontweight='semibold', pad=20)
ax.set_xlabel("Count", fontsize=14, labelpad=10)
ax.set_ylabel("NumOfProducts", fontsize=14, labelpad=10)# Add value labels to the bars
for container in ax.containers:ax.bar_label(container, label_type='edge', fontsize=10, padding=2, color='black', fontweight='normal')# Adjust layout to prevent label cutoff
plt.tight_layout()plt.show()

# Create the figure and axes
fig, ax = plt.subplots(figsize=(9, 4))# Create the count plot
sns.countplot(y="HasCrCard", data=df_train, ax=ax, palette="deep")# Customize the plot
ax.set_title("Distribution of HasCrCard", fontsize=18, fontweight='semibold', pad=20)
ax.set_xlabel("Count", fontsize=14, labelpad=10)
ax.set_ylabel("HasCrCard", fontsize=14, labelpad=10)# Add value labels to the bars
for container in ax.containers:ax.bar_label(container, label_type='center', fontsize=12, padding=5, color='white', fontweight='bold')plt.show()

# Create the figure and axes
fig, ax = plt.subplots(figsize=(9, 4))# Create the count plot
sns.countplot(y="IsActiveMember", data=df_train, ax=ax, palette="deep")# Customize the plot
ax.set_title("Distribution of IsActiveMember", fontsize=18, fontweight='semibold', pad=20)
ax.set_xlabel("Count", fontsize=14, labelpad=10)
ax.set_ylabel("IsActiveMember", fontsize=14, labelpad=10)# Add value labels to the bars
for container in ax.containers:ax.bar_label(container, label_type='center', fontsize=12, padding=5, color='white', fontweight='bold')plt.show()

cat_cols = ['Geography', 'Gender', 'Tenure', 'NumOfProducts', 'HasCrCard','IsActiveMember']target = 'Exited'fig = plt.figure(figsize=(9, len(cat_cols)*1.8))# background_color = 'grey'
for i, col in enumerate(cat_cols):plt.subplot(len(cat_cols)//2 + len(cat_cols) % 2, 2, i+1)sns.countplot(x=col, hue=target, data=df_train, palette='deep', color='#26090b', edgecolor='#26090b')plt.title(f"{col} countplot by target", fontweight = 'bold')plt.ylim(0, df_train[col].value_counts().max() + 10)plt.tight_layout()
plt.show()

num_cols = ['CreditScore', 'Age', 'Balance', 'EstimatedSalary']
colors = ['#4e79a7', '#f28e2b', '#e15759', '#76b7b2']fig, axes = plt.subplots(2, 2, figsize=(12, 10))
fig.suptitle("Distribution of Numerical Features", fontsize=20, fontweight='bold', y=1.02)for i, column in enumerate(num_cols):ax = axes[i//2, i%2]sns.histplot(data=df_train, x=column, kde=True, bins=30, ax=ax, color=colors[i], edgecolor='white', linewidth=0.8)mean, median = df_train[column].mean(), df_train[column].median()ax.axvline(mean, color='red', linestyle='dashed', linewidth=2, label=f'Mean: {mean:.2f}')ax.axvline(median, color='blue', linestyle='dashed', linewidth=2, label=f'Median: {median:.2f}')ax.set_title(column, fontsize=16, pad=15)ax.set_xlabel(column, fontsize=14, labelpad=10)ax.set_ylabel('Frequency', fontsize=14, labelpad=10)ax.tick_params(axis='both', which='major', labelsize=12)ax.grid(True, linestyle='--', alpha=0.7)ax.set_axisbelow(True)ax.spines['top'].set_visible(False)ax.spines['right'].set_visible(False)ax.legend(fontsize=12)plt.tight_layout()
fig.subplots_adjust(top=0.93, hspace=0.3, wspace=0.25)
plt.show()

palette_cmap = ["#6c9a76","#cc4b57","#764a23","#f25a29","#f7941d"]
df_corr = df_train.copy()catcol = [col for col in df_corr.columns if df_corr[col].dtype == "object"]
le = LabelEncoder()
for col in catcol:df_corr[col] = le.fit_transform(df_corr[col])plt.subplots(figsize =(10, 10))sns.heatmap(df_corr.corr(), cmap = palette_cmap, square=True, cbar_kws=dict(shrink =.82), annot=True, vmin=-1, vmax=1, linewidths=3,linecolor='#e0b583',annot_kws=dict(fontsize =8))
plt.title("Pearson Correlation Of Features\n", fontsize=25)
plt.xticks(rotation=90)
plt.yticks(rotation=0)
plt.show()

我们可以看到,年龄和人口流动之间有很强的正相关性,这意味着,当年龄越大,人口流动的可能性越大,这可以告诉我们,随着年龄的增长,人口流动的可能性越大。

此外,我们可以看到这次(产品数量和活跃成员)与退出概率之间的强烈负相关,这告诉我们,当一个人更活跃的时候,他们退出的概率是低的,也是当一个客户有更多的产品在银行,他们不太可能搅局。

由此我们可以看出,这两个变量在决定客户流失的可能性是非常重要的。

numeirc_cols = ['Age','CreditScore', 'Balance','EstimatedSalary']
#Use Loop Function
for col in numeirc_cols:sc = MinMaxScaler()df_train[col+"_scaled"] = sc.fit_transform(df_train[[col]])df_test[col+"_scaled"] = sc.fit_transform(df_test[[col]])

拼接 

df_train['Sur_Geo_Gend_Sal'] = df_train['CustomerId'].astype(str) + \df_train['Surname'] + \df_train['Geography'] + \df_train['Gender'] + \np.round(df_train['EstimatedSalary']).astype(str)df_test['Sur_Geo_Gend_Sal'] = df_test['CustomerId'].astype(str) + \df_test['Surname'] + \df_test['Geography'] + \df_test['Gender'] + \np.round(df_test['EstimatedSalary']).astype(str)

 将文本数据转换为TF-IDF特征向量

def get_vectors(df_train,df_test,col_name):vectorizer = TfidfVectorizer(max_features=1000)vectors_train = vectorizer.fit_transform(df_train[col_name])vectors_test = vectorizer.transform(df_test[col_name])#用svd降维svd = TruncatedSVD(3)x_sv_train = svd.fit_transform(vectors_train)x_sv_test = svd.transform(vectors_test)#将数据转换为 pandas 的 DataFrame 结构tfidf_df_train = pd.DataFrame(x_sv_train)tfidf_df_test = pd.DataFrame(x_sv_test)#命名cols = [(col_name + "_tfidf_" + str(f)) for f in tfidf_df_train.columns.to_list()]tfidf_df_train.columns = colstfidf_df_test.columns = cols#合并df_train = df_train.reset_index(drop=True)df_test = df_test.reset_index(drop=True)df_train = pd.concat([df_train, tfidf_df_train], axis="columns")df_test = pd.concat([df_test, tfidf_df_test], axis="columns")return df_train,df_test

 SVD降维通常用于文本挖掘(如TF-IDF矩阵降维)、图像处理、推荐系统等领域。然而,SVD也有一些局限性,比如计算复杂度较高,对于非常大的数据集可能不够高效。此外,SVD是一种线性降维方法,可能无法捕捉到数据中的所有非线性结构。在这些情况下,可以考虑使用其他降维技术,如主成分分析(PCA)或t-SNE。

df_train,df_test = get_vectors(df_train,df_test,'Surname')
df_train,df_test = get_vectors(df_train,df_test,'Sur_Geo_Gend_Sal')
df_train.head()

 将数据集中的某些列转换为新的特征,并对这些特征进行处理

def feature_data(df):df['Senior'] = df['Age'].apply(lambda x: 1 if x >= 60 else 0)df['Active_by_CreditCard'] = df['HasCrCard'] * df['IsActiveMember']df['Products_Per_Tenure'] =  df['Tenure'] / df['NumOfProducts']df['AgeCat'] = np.round(df.Age/20).astype('int').astype('category')cat_cols = ['Geography', 'Gender', 'NumOfProducts','AgeCat']    #onehotEncodingdf=pd.get_dummies(df,columns=cat_cols)return df
#Genrating New Features
df_train = feature_data(df_train)
df_test = feature_data(df_test)##Selecting Columns FOr use 
feat_cols=df_train.columns.drop(['id', 'CustomerId', 'Surname','Exited','Sur_Geo_Gend_Sal'])
feat_cols=feat_cols.drop(numeirc_cols)#Printing
print(feat_cols)
df_train.head()

X=df_train[feat_cols]
y=df_train['Exited']
# LightGBM Parameters
lgbParams = {'n_estimators': 1000,'max_depth': 25, 'learning_rate': 0.025,'min_child_weight': 3.43,'min_child_samples': 216, 'subsample': 0.782,'subsample_freq': 4, 'colsample_bytree': 0.29, 'num_leaves': 21,'verbose':-1}lgb_model = lgb.LGBMClassifier(**lgbParams)
lgb_cv_scores = cross_val_score(lgb_model, X, y, cv=10, scoring='roc_auc')print("Cross-validation scores:", lgb_cv_scores)
print("Mean AUC:", lgb_cv_scores.mean())

 这段代码是使用Python的LightGBM库进行机器学习模型训练和交叉验证的例子。LightGBM是一个梯度提升框架,用于训练预测模型,它在处理大型数据集时非常高效。

lgb_model.fit(X,y)test_predictions = lgb_model.predict_proba(df_test[feat_cols])[:, 1]# Create a submission DataFrame
submission = pd.DataFrame({'id': df_test['id'],'Exited': test_predictions
})# # Save the submission file
submission.to_csv('3submission.csv', index=False)
# Initialize CatBoostClassifier
cat_model = CatBoostClassifier(eval_metric='AUC',learning_rate=0.022,iterations=1000,verbose=False
)# Perform cross-validation with StratifiedKFold
catboost_cv_scores = cross_val_score(cat_model, X, y, cv=5, scoring='roc_auc')print("Cross-validation scores:", catboost_cv_scores)
print("Mean AUC:", catboost_cv_scores.mean())

#Cat_features
cat_features = np.where(X.dtypes != np.float64)[0]# Train the model on the entire dataset
train_pool = Pool(X, y, cat_features=cat_features)
cat_model.fit(train_pool)# Make predictions on the test set
test_pool = Pool(df_test[feat_cols], cat_features=cat_features)
test_predictions = cat_model.predict_proba(test_pool)[:, 1]# Create submission DataFrame
submission = pd.DataFrame({'id': df_test['id'],'Exited': test_predictions
})# Save the submission file
submission.to_csv('catboost_submission.csv', index=False)
print("Submission file created: catboost_submission.csv")
xgb_params = {'max_depth': 6,'learning_rate': 0.01,'n_estimators': 1000,'min_child_weight': 1,'subsample': 0.8,'colsample_bytree': 0.8,'gamma': 0,'objective': 'binary:logistic','eval_metric': 'auc','use_label_encoder': False,'nthread': -1,'random_state': 42
}# Initialize XGBoost Classifier
xgb_model = xgb.XGBClassifier(**xgb_params)# Perform cross-validation with StratifiedKFold
cv = StratifiedKFold(n_splits=5, shuffle=True, random_state=42)
xgb_cv_scores = cross_val_score(xgb_model, X, y, cv=cv, scoring='roc_auc')print("Cross-validation scores:", xgb_cv_scores)
print("Mean AUC:", xgb_cv_scores.mean())

classifiers = ['LightGBM', 'CatBoost', 'XGBoost']
auc_scores = [lgb_cv_scores.mean(), catboost_cv_scores.mean(), xgb_cv_scores.mean()]
# Create data for the plot
colors = ['#4e79a7', '#f28e2b', '#e15759']# Create the figure with optimized settings
fig = go.Figure(data=[go.Bar(x=classifiers,y=auc_scores,name='AUC Score',marker_color=colors
)])# Update layout with optimized settings
fig.update_layout(title='AUC Comparison',xaxis_title='Classifier',yaxis_title='AUC Score',template='plotly_white',font=dict(family="Arial", size=12),width=600,margin=dict(l=50, r=50, t=50, b=50)
)# Add gridlines
fig.update_yaxes(showgrid=True, gridwidth=1, gridcolor='#E0E0E0')# Show the plot
fig.show()

创建一个柱状图,用于比较不同分类器的 AUC 分数。 

# Selcting Best and Highest AUC_Score  from Above trained Models # Find the index of the maximum AUc_Score
best_accuracy_index = auc_scores.index(max(auc_scores))# Print the best model for accuracy
print(f'Best Accuracy: {auc_scores[best_accuracy_index]:.4f} with Model: {classifiers[best_accuracy_index]}')
Best Accuracy: 0.8946 with Model: LightGBM

​​​​​​​

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

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

相关文章

金砖软件测试赛项之Jmeter如何录制脚本!

一、简介 Apache JMeter 是一款开源的性能测试工具,用于测试各种服务的负载能力,包括Web应用、数据库、FTP服务器等。它可以模拟多种用户行为,生成负载以评估系统的性能和稳定性。 JMeter 的主要特点: 图形用户界面:…

Stable Diffusion绘画 | ControlNet应用-IP-Adapter:一致性角色就这么简单

IP-Adapter 更新了全新的模型—FaceID plus V2 版本,同时还支持 SDXL 模型。 FaceID plus V2 版本的优点: 解决任务一致性 一张图生成相似角色 下载地址:https://huggingface.co/h94/IP-Adapter-FaceID/tree/main 其中,两个 Lora文…

AIGC时代!AI的“iPhone时刻”与投资机遇

AIGC时代!AI的“iPhone时刻”与投资机遇 前言AI的“iPhone时刻”与投资机遇 前言 AIGC,也就是人工智能生成内容,它就像是一股汹涌的浪潮,席卷了整个科技世界。它的出现,让我们看到了人工智能的无限潜力,也…

基于协同过滤算法+PHP的新闻推荐系统

作者:计算机学姐 开发技术:SpringBoot、SSM、Vue、MySQL、JSP、ElementUI、Python、小程序等,“文末源码”。 专栏推荐:前后端分离项目源码、SpringBoot项目源码、SSM项目源码 系统展示 【2025最新】基于协同过滤算法PHPMySQL的新…

【STM32 HAL库】OLED显示模块

【STM32 HAL库】OLED显示模块 前言理论OLED基本参数OLED基本驱动原理OLED坐标轴 应用CubeMx配置底层函数代码高层封装函数printf显示函数 前言 本文为笔者学习 OLED 的总结,基于keysking的视频内容,如有错误,欢迎指正 理论 OLED基本参数 …

react + antDesign封装图片预览组件(支持多张图片)

需求场景:最近在开发后台系统时经常遇到图片预览问题,如果一个一个的引用antDesign的图片预览组件就有点繁琐了,于是在antDesign图片预览组件的基础上二次封装了一下,避免重复无用代码的出现 效果 公共预览组件代码 import React…

【machine learning-十-grading descent梯度下降实现】

grading descent 梯度下降参数更新方法 --导数和学习率 从导数项直观理解梯度下降 grading descent 算法就是更新参数,今天来学习下如何更新w和b 梯度下降 还是以线性回归的均方差损失函数如下为例: 损失函数的可视化图如下 : 横轴和纵轴分…

影刀RPA实战:网页爬虫之苦瓜书籍数据

书籍常常被视为心灵的慰藉,因为它们能够在不同的层面上为人们提供支持和安慰。 1. 书籍对我们的重要性 书籍是人类知识的载体,也是智慧的结晶。它们不仅是学习的工具,更是人类心灵的慰藉。在忙碌的生活中,书籍能够提供知识、启发…

魅思CMS getOrderStatus SQL注入漏洞复现

0x01 漏洞描述: 魅思是一款集成了视频管理、用户管理、手机端应用封装等功能的综合性视频管理系统。该系统不仅以其强大的视频管理功能、灵活的用户管理机制、便捷的手机端应用封装功能以及高安全性和现代化的界面设计,成为了市场上备受关注的视频管理系…

技术美术百人计划 | 《4.5 DOF景深算法》笔记

1. 景深定义 景深(Depth of Field,DOF),是指在摄影机镜头或其他成像器前沿能够取得清晰图像的成像所测定的被摄物体前后距离范围。镜头光圈、镜头焦距、及焦平面到拍摄物的距离是影响景深的重要因素。在聚焦完成后,焦点…

监控IDS和IPS增强网络安全性

入侵检测系统(IDS)和入侵防御系统(IPS)是当今使用的最复杂的网络安全设备之一,它们检查网络数据包并阻止可疑数据包,并提醒管理员有关攻击企图的信息。 在当今威胁不断变化的网络环境中,防火墙…

TopoDOT2024.1注册机 道路自动化提取 雷达点云数据

TopoDOT2024.1是一套成熟的点云数据处理及应用系统,全面具备点云数据的存储管理、精度检核、特征自动提取、智能分析、高效建模、成果输出等应用功能。TopoDOT在LiDAR数据应用领域有着多年的实战经验,用户在实际项目中长期使用,尤其在交通领域…

iOS 巨魔神器,Geranium 天竺葵:6大功能,个个都解决痛点

嘿,这是黑猫。如果你装了巨魔,却只知道安装第三方APP,那就是暴殄天物。巨魔的价值不仅是应用侧载,还有强大的玩机工具生态——这也是我花费大量时间,去制作巨魔精选IPA合集的原因。 通过巨魔商店安装的APP&#xff0c…

初学者的鸿蒙多线程并发之 TaskPool 踩坑之旅

1. 背景 目标群体:鸿蒙初学者 版本:HarmonyOS 3.1/4.0 背景:鸿蒙 App 的全局路由管理功能,需要在 App 启动时初始化对 raw 下的相关配置文件进行读取、解析并缓存。App 启动时涉及到了大量模块的初始化,好多模块都涉…

智能绘画Midjourney AIGC在设计领域中的应用

科技的进步,人工智能(AI)正以前所未有的方式渗透进各个领域,尤其是在艺术创作,尤其是绘画。Midjourney作为AI绘画技术的代表,其AIGC(Artificial Intelligence for Generative Content&#xff0…

python SQLAlchemy 数据库连接池

文章目录 前言python SQLAlchemy 数据库连接池1. 安装2. 创建数据库引擎3. 新建表,增删改查demo 前言 如果您觉得有用的话,记得给博主点个赞,评论,收藏一键三连啊,写作不易啊^ _ ^。   而且听说点赞的人每天的运气都…

【Linux】—— muduo网络库的安装配置与使用

muduo网络库编程 Linux环境下Epollpthread线程库 Boost库安装与使用 安装Boost库 下载boost库源码,linux环境解压 tar -zxvf boost_1_69_0.tar.gz 解压完成后,进入该目录,查看内容 运行bootstrap.sh工程编译构建程序 ./bootstrap.sh …

JAVA同城生活新引擎外卖跑腿团购到店服务多合一高效系统小程序源码

🚀同城生活新风尚!一站式高效系统,让日常更便捷🛍️ 🍽️【开篇:同城生活,一触即发】🍽️ 在这个快节奏的时代,同城生活的便利性与效率成为了我们追求的新风尚。想象一下…

C# 从字符串中分离文件路径、文件名及扩展名

C# 从字符串中分离文件路径、文件名及扩展名 对文件进行操作时,首先要获取文件路径信息,然后创建文件对象,通过IO流将数据读取大宋内存中并进行处理。在操作文件时,可能还需要提取文件的一些信息,比如,文件…

有效安全计划评估的基本指标

衡量安全计划成功与否的最有效指标是什么? 最直接的指标是:您的组织是否遭到入侵?如果答案是肯定的,那么显然还有工作要做。如果答案是否定的,那么您的状况就更好了——但情况比这更复杂。 即使您没有遭到入侵&#…