Compare commits

...

11 Commits

@ -0,0 +1,2 @@
hello
111

@ -39,19 +39,19 @@ sonarqube {
property "sonar.login", "admin" // sonar
property "sonar.password", "Qian15825254201!" // sonar
property "sonar.password", "Kns154273@sonarqube" // sonar
property "sonar.sourceEncoding", "UTF-8"
property "sonar.projectKey", "qqjnb" //sonarkey
property "sonar.projectKey", "ns_project" //sonarkey
property "sonar.projectName", "qqjnb" //sonar
property "sonar.projectName", "ns_project" //sonar
property "sonar.sources", "src/main/java" //sonar
property "sonar.projectVersion", project.version //
property "sonar.projectVersion", 1.0 //
property "sonar.binaries", "build/intermediates/classes"
}

@ -98,6 +98,8 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashSet;
// 导入 android.content.res.Resources 类,该类用于访问应用的资源,
// 比如字符串、颜色、布局文件等。通过该类可以获取应用中定义的各种资源,以在代码中动态使用
import android.content.res.Resources;
public class NotesListActivity extends Activity implements OnClickListener, OnItemLongClickListener, NotesListItem.OnClickListener {
@ -108,7 +110,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
/** 菜单操作常量 */
private static final int MENU_FOLDER_DELETE = 0; // 删除文件夹的菜单选项
private static final int MENU_FOLDER_VIEW = 1; // 查看文件夹的菜单选项
private static final int MENU_FOLDER_CHANGE_NAME = 2; // 更改文件夹名称的菜单选项
private static final int MENU_FOLDER_CHANGE_NAME = 2; // 更改文件夹名称的菜单选项
/** 排序方式常量 */
private static final int SORT_BY_MODIFIED_DATE = 0; // 按修改日期排序

@ -14,7 +14,7 @@ buildscript {
}
plugins {
id "org.sonarqube" version "5.1.0.4882"
id "org.sonarqube" version "6.0.1.5171"
}
ext {

@ -3,8 +3,9 @@ systemProp.sonar.host.url=http://localhost:9000
systemProp.sonar.login=admin
systemProp.sonar.password=Qian15825254201!
systemProp.sonar.password=Kns154273@sonarqube
sonar.token=sqp_3917154449d9d20f39feff1c42a5de00542dbe76
# ??Androidx???????
android.useAndroidX=true
# ??Maven??????

@ -0,0 +1,73 @@
import os
import pickle
import numpy as np
from pathlib import Path
def merge_pkl_files(input_dir, output_path="feature_dataset.pkl"):
all_features = []
all_labels = []
pkl_files = list(Path(input_dir).glob("*.pkl"))
if not pkl_files:
raise FileNotFoundError(f"在目录 {input_dir} 中未找到PKL文件")
# 排除已合并的文件和无效文件
pkl_files = [f for f in pkl_files if f.name not in ["feature_dataset.pkl", "infer_results.pkl"]]
print(f"发现 {len(pkl_files)} 个有效PKL文件开始合并...")
for file in pkl_files:
try:
with open(file, "rb") as f:
data = pickle.load(f)
if "matrix" not in data or "label" not in data:
print(f"跳过 {file.name}:缺少'matrix''label'字段")
continue
features = data["matrix"]
labels = data["label"]
# 强制将标签转为一维整数数组(核心修复)
labels = labels.ravel().astype(np.int64) # 转为int64类型
# 验证特征和标签数量匹配
if len(features) != len(labels):
print(f"跳过 {file.name}:特征({len(features)})与标签({len(labels)})数量不匹配")
continue
# 验证特征维度一致性
if all_features and features.shape[1] != all_features[0].shape[1]:
print(f"跳过 {file.name}:特征维度与已有数据不一致(现有{all_features[0].shape[1]}维,当前{features.shape[1]}维)")
continue
all_features.append(features)
all_labels.append(labels)
print(f"已加载 {file.name}{len(features)} 条样本(特征{features.shape[1]}维)")
except Exception as e:
print(f"处理 {file.name} 时出错:{str(e)},已跳过")
if not all_features:
raise ValueError("没有有效数据可合并,请检查输入文件")
# 合并特征和标签
merged_matrix = np.vstack(all_features)
merged_label = np.concatenate(all_labels, axis=0) # 数组拼接
print("\n合并结果:")
print(f"总样本数:{len(merged_matrix)}")
print(f"特征矩阵形状:{merged_matrix.shape}")
# 确保标签为整数后再统计分布
print(f"标签分布:{np.bincount(merged_label)} (索引对应标签值)")
with open(output_path, "wb") as f:
pickle.dump({"matrix": merged_matrix, "label": merged_label}, f)
print(f"\n已成功保存至 {output_path}")
if __name__ == "__main__":
INPUT_DIRECTORY = r"D:\SummerSchool\mat_cv\mat_cv-02"
OUTPUT_FILE = r"D:\SummerSchool\mat_cv\mat_cv-02\feature_dataset00.pkl" # 路径
merge_pkl_files(INPUT_DIRECTORY, OUTPUT_FILE)
Loading…
Cancel
Save