修改分割模块
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -587,22 +587,22 @@ def predict_with_model(df, model_path, model_type='SVM', ProcessMethods1='SS', P
|
||||
# 主函数,用于训练
|
||||
if __name__ == "__main__":
|
||||
# 使用 pandas 读取 CSV 文件
|
||||
file_path = r"E:\code\plastic\plastic20260224\plastic\plastic\output\20260224\all.csv"
|
||||
file_path = r"D:\Data2\traindata1\all\isf0303.csv"
|
||||
df = pd.read_csv(
|
||||
file_path,
|
||||
encoding='utf-8', # 指定编码,如果出错可尝试 'gbk' 或 'gb18030'
|
||||
low_memory=False # 避免数据类型推断问题
|
||||
)
|
||||
|
||||
# 使用 pandas 选择要删除的列(第93到117列,索引从0开始)
|
||||
cols_to_remove = df.columns[np.r_[1:5, 87:110, 166:169]]
|
||||
|
||||
# 使用 pandas 删除指定列
|
||||
df_filtered = df.drop(columns=cols_to_remove)
|
||||
# # 使用 pandas 选择要删除的列(第93到117列,索引从0开始)
|
||||
# cols_to_remove = df.columns[87:110]
|
||||
#
|
||||
# # 使用 pandas 删除指定列
|
||||
# df_filtered = df.drop(columns=cols_to_remove)
|
||||
|
||||
# 使用 pandas 提取特征数据(从第2列开始到最后,排除第一列标签列)
|
||||
x = df_filtered.iloc[:, 1:]
|
||||
# x = df.iloc[:, 1:]
|
||||
# x = df_filtered.iloc[:, 1:]
|
||||
x = df.iloc[:, 1:]
|
||||
# 使用 pandas 提取标签(第一列)
|
||||
y = df.iloc[:, 0]
|
||||
X_train, X_test, y_train, y_test = SpectralQualitativeAnalysis(x, y, 'SS', 'None', 'None', 'random', use_smote=True)
|
||||
@ -622,7 +622,7 @@ if __name__ == "__main__":
|
||||
# save_model(clf, r"D:\WQ\plastic\classification_model\modelsave\svm.m", model_type='SVM')
|
||||
|
||||
# 示例2: 使用统一的训练和保存函数(推荐)
|
||||
save_dir = r"E:\code\plastic\plastic20260224\plastic\plastic\output\20260224\modelsave"
|
||||
save_dir = r"D:\plastic\plastic\modelsave\240model\new\0303"
|
||||
|
||||
# 训练并保存多个模型
|
||||
models_to_train = ['SVM']#'SVM', 'RF', 'XGBoost', 'LogisticRegression'
|
||||
|
||||
@ -132,7 +132,7 @@ def Preprocessing(method, input_spectrum):
|
||||
elif method == 'MMS':
|
||||
output_spectrum = MMS(input_spectrum.values)
|
||||
elif method == 'SS':
|
||||
output_spectrum = SS(input_spectrum.values, r'E:\code\plastic\plastic20260224\plastic\plastic\output\20260224\modelsave\scaler_params.pkl')
|
||||
output_spectrum = SS(input_spectrum.values, r'D:\plastic\plastic\modelsave\240model\new\0303\scaler_params.pkl')
|
||||
elif method == 'CT':
|
||||
output_spectrum = CT(input_spectrum.values)
|
||||
elif method == 'SNV':
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user