作者注:本文以武汉大学的 WHU-HI-HanChuan 高光谱遥感数据集为例,采用 PCA 进行波段降维,再利用 CatBoost 构建分类模型,并结合主成分特征重要性分析与参数敏感性评估,构建了完整的遥感分类流程(本篇仍然是入门教程,重点放在参数分析,大家注意下如何制图)。
一、数据说明
- 数据名称:WHU-Hi-HanChuan
- 下载地址:https://rsidea.whu.edu.cn/resource_WHUHi_sharing.htm
- 图像尺寸:
Height × Width × Bands - 标签说明:像素标签范围1-16,0表示无标签区域。
参考文献:
- Zhong et al., “WHU-Hi: UAV-borne hyperspectral with high spatial resolution (H2) benchmark datasets and classifier for precise crop identification…”, Remote Sens. Environ., 2020.
- Zhong et al., “Mini-UAV-borne hyperspectral remote sensing: From observation and processing to applications”, IEEE GRSM, 2018.
二、完整代码详解
📌 请将
data_dir替换为你的本地数据路径,如r"F:\YourFolder"。
# -*- coding: utf-8 -*-
import os
import numpy as np
import scipy.io
import matplotlib.pyplot as plt
import matplotlib
import pandas as pd
from sklearn.decomposition import PCA
from sklearn.model_selection import train_test_split, GridSearchCV
from sklearn.metrics import accuracy_score, classification_report
from catboost import CatBoostClassifier
# 设置中文显示和负号
matplotlib.rcParams['font.family'] = 'SimHei'
matplotlib.rcParams['axes.unicode_minus'] = False
# ===================== 1. 数据加载 =====================
data_dir = r"your_path" # 修改为你自己的路径
x_path = os.path.join(data_dir, "WHU_Hi_HanChuan.mat")
y_path = os.path.join(data_dir, "WHU_Hi_HanChuan_gt.mat")
def load_data(x_path, y_path):
x_data = scipy.io.loadmat(x_path)
y_data = scipy.io.loadmat(y_path
1449




被折叠的 条评论
为什么被折叠?



