【Python实现Select by Location】使用geopandas对多边形进行buffer筛选

import geopandas as gpd

dist_buffer = 500
jy_12_poly_gdf = gpd.read_file(jy_12_split_file)

for i in range(100):
    nei_poly = jy_12_poly_gdf[jy_12_poly_gdf.within(jy_12_poly_gdf[
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Python中,可以使用scikit-learn库来实现PCA进行特征筛选。具体步骤如下: 1. 导入所需的库和数据 ```python from sklearn.decomposition import PCA from sklearn.datasets import load_iris # 导入数据 iris = load_iris() X = iris.data y = iris.target ``` 2. 对数据进行标准化处理 ```python from sklearn.preprocessing import StandardScaler # 标准化处理 X = StandardScaler().fit_transform(X) ``` 3. 进行PCA特征提取 ```python # 实例化PCA对象 pca = PCA(n_components=2) # 基于数据进行PCA降维 principalComponents = pca.fit_transform(X) # 将主成分转换为DataFrame,方便可视化 principalDf = pd.DataFrame(data = principalComponents, columns = ['principal component 1', 'principal component 2']) ``` 4. 查看主成分的方差贡献率 ```python print(pca.explained_variance_ratio_) ``` 5. 可视化结果 ```python import matplotlib.pyplot as plt # 可视化结果 finalDf = pd.concat([principalDf, pd.DataFrame(y, columns = ['target'])], axis = 1) fig = plt.figure(figsize = (8,8)) ax = fig.add_subplot(1,1,1) ax.set_xlabel('Principal Component 1', fontsize = 15) ax.set_ylabel('Principal Component 2', fontsize = 15) ax.set_title('2 Component PCA', fontsize = 20) targets = [0, 1, 2] colors = ['r', 'g', 'b'] for target, color in zip(targets,colors): indicesToKeep = finalDf['target'] == target ax.scatter(finalDf.loc[indicesToKeep, 'principal component 1'] , finalDf.loc[indicesToKeep, 'principal component 2'] , c = color , s = 50) ax.legend(targets) ax.grid() ``` 以上就是使用Python实现PCA进行特征筛选的基本步骤。通过PCA可以将高维数据压缩到低维,同时保留数据的主要特征,进而提高模型训练效率。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值