Image processing 特征约简

Image processing 特征约简,image-processing,feature-extraction,Image Processing,Feature Extraction,如何减少特征维度?我的功能看起来像: 1(类号)10_10_1(文件名) 0 0 0 0 0 0 0 0 0.564971751 23.16384181 25.98870056 19.20903955 16.10169492 13.27683616 1.694915254 0 0 0 0 0 0 0 3.95480226 11.5819209 20.33898305 60.4519774 3.672316384 0 0

如何减少特征维度?我的功能看起来像:

1(类号)10_10_1(文件名) 0 0 0 0 0 0 0 0 0.564971751 23.16384181 25.98870056 19.20903955 16.10169492 13.27683616 1.694915254 0 0 0 0 0 0 0 3.95480226 11.5819209 20.33898305 60.4519774 3.672316384 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3.107344633 62.99435028 33.89830508 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1.412429379 66.66666667 31.92090395 0 0 0 0 0 0 0 0 0 0 0 0 0 0.564971751 22.59887006 26.83615819 46.89265537 3.107344633 0 0 0 0 0 0 0 0 0 0 0 0 0 0.564971751 16.38418079 28.53107345 50.84745763 3.672316384 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 90.6779661 9.322033898 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.847457627 90.11299435 9.039548023 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 17.79661017 81.3559322 0.847457627 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 27.11864407 72.88135593 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.564971751 37.85310734 61.29943503 0.282485876 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1.412429379 50.84745763 47.45762712 0.282485876 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 24.57627119 75.42372881 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 17.23163842 82.20338983 0.564971751 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 29.37853107 70.62146893 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 55.64971751 44.35028249 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 64.40677966 35.59322034 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 67.79661017 32.20338983 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 66.66666667 33.33333333 0 0 0 0 0 0 0 0 0 0 0 0 1 3 2 6 7 5 4 8 9 10 11 12 13 14 15 16 17 18 14.81834463 3.818489078 3.292123621 2.219541777 2.740791003 1.160544518 2.820053602 1.006906813 0.090413195 2.246638594 0.269778302 2.183126126 2.239168249 0.781498607 2.229795302 0.743329919 1.293839141 0.783068011.104421291 0.77031277 0.697659061.082266169 0.408339745 1.073922207 0.999148017 0.602195061 1 1.2472866588 0.712143548 0.867327913 0.603063537 0.474115683 0.596387106 0.37084474747522 0.5490000 0.35930586 0.58027230.397060353371


文件名后会给出功能值。

如果您的功能未受监督,则可以使用

如果有人监督,你可以使用


为了减少交给模型的特征数量,除其他外,还可以使用特征缩减或特征删除/选择。这里已经指出了一些常用的特征约简方法,如主成分分析(PCA)、线性判别分析(LDA)或偏最小二乘回归(PLSR)。这些基本上是将原始数据投影到一个子空间中,以较少的特征来表示信息。特别是,PCA因此尝试最大化原始数据中的保留方差(无监督),而LDA尝试最小化类内方差并最大化类间距离(有监督,用于分类),PLSR尝试最大化原始数据中的保留方差并最大化与目标变量的相关性(监督,回归)

此外,可以使用经典的特征选择来减少特征的数量。这些特征不将数据投影到子空间,而是选择“有用”直接从现有功能集提取的功能。通常这些方法分为功能过滤器功能包装,其中过滤器仅通过查看功能和目标变量来决定使用哪些功能(例如,尽量减少特征间相关性,同时最大化特征目标相关性)相反,特征包装器还考虑使用所选特征的模型,因此它们直接优化模型性能。通常,过滤器在计算上比包装便宜,但是类似于使用PCA,特征过滤器不一定需要改进后续模型性能,因为它们不知道要做什么。优化

编辑:当您处理图像数据时,如果单独使用功能过滤器和包装器,它们可能不是最佳的-它们可能需要在使用前进行图像预处理和/或缩小尺寸

如果您使用的是
R
,我建议您使用
caret
软件包,该软件包提供了已经嵌入到模型培训和评估过程中的所有上述内容,这一点非常重要(有关其过滤器/包装器的一些详细信息,请参阅)。以下是使用上述方法的一个小片段:

library(caret)
# PCA with preserving 95% variance in original data
modelPca <- train(x = iris[,1:4], iris[,5], preProcess=c('center', 'scale', 'pca'), trControl=trainControl(preProcOptions=list(thresh=0.95)),  method='svmLinear', tuneGrid=expand.grid(C=3**(-3:3)))
# LDA with selection of dimensions
modelLda2 <- train(x = iris[,1:4], y = iris[,5], method='lda2', tuneGrid=expand.grid(dimen=1:4))
# PLSR with selection of dimensions
modelPls <- train(x = iris[,1:3], y = iris[,4], method='pls', tuneGrid=expand.grid(ncomp=1:3))
# feature wrapper: (backwards) recursive feature elimination (there exist more...)
modelRfe <- rfe(x = iris[,1:4], y = iris[,5], sizes = 1:4, rfeControl = rfeControl())
# feature filter: univariate filtering
modelSbf <- sbf(x = iris[,1:4], y = iris[,5], sbfControl = sbfControl())
库(插入符号)
#保留原始数据95%方差的主成分分析

modelPca如果要组合这些功能以减少功能的数量,则可以使用PCA。但是,您可能需要执行功能选择(选择最佳功能并放弃其他功能),然后查看本课程().最后,它指向三个不同的库。就我个人而言,我只使用过Weka,但它在这方面并不太好。
import numpy as np
from sklearn.lda import LDA
X = np.array([[-1, -1], [-2, -1], [-3, -2], [1, 1], [2, 1], [3, 2]])
y = np.array([1, 1, 1, 2, 2, 2])
clf = LDA()
clf.fit(X, y)
library(caret)
# PCA with preserving 95% variance in original data
modelPca <- train(x = iris[,1:4], iris[,5], preProcess=c('center', 'scale', 'pca'), trControl=trainControl(preProcOptions=list(thresh=0.95)),  method='svmLinear', tuneGrid=expand.grid(C=3**(-3:3)))
# LDA with selection of dimensions
modelLda2 <- train(x = iris[,1:4], y = iris[,5], method='lda2', tuneGrid=expand.grid(dimen=1:4))
# PLSR with selection of dimensions
modelPls <- train(x = iris[,1:3], y = iris[,4], method='pls', tuneGrid=expand.grid(ncomp=1:3))
# feature wrapper: (backwards) recursive feature elimination (there exist more...)
modelRfe <- rfe(x = iris[,1:4], y = iris[,5], sizes = 1:4, rfeControl = rfeControl())
# feature filter: univariate filtering
modelSbf <- sbf(x = iris[,1:4], y = iris[,5], sbfControl = sbfControl())