类 GWDA
定义于 File GWDA.h
继承关系
基类
public gwm::SpatialMonoscaleAlgorithm(类 SpatialMonoscaleAlgorithm)public gwm::IMultivariableAnalysis(结构体 IMultivariableAnalysis)public gwm::IParallelizable(结构体 IParallelizable)public gwm::IParallelOpenmpEnabled(结构体 IParallelOpenmpEnabled)
类文档
-
class GWDA : public gwm::SpatialMonoscaleAlgorithm, public gwm::IMultivariableAnalysis, public gwm::IParallelizable, public gwm::IParallelOpenmpEnabled
地理加权判别分析类。 地理加权判别分析是一种用于计算局部加权统计的算法,其中还计算位置概率及其相关熵。
公有方法
-
inline GWDA(const arma::mat x, const arma::mat coords, const SpatialWeight &spatialWeight)
构造一个新的 GWDA 对象。
-
inline bool isWqda() const
获取是否应用加权二次判别分析;否则将应用加权线性判别分析。
- 返回:
true 是
- 返回:
false 否
-
inline void setIsWqda(bool iswqda)
设置是否应用加权二次判别分析;否则将应用加权线性判别分析。
- 参数:
isqwda -- 是否应用加权二次判别分析;否则将应用加权线性判别分析。
-
inline bool hasCov() const
获取是否将局部方差协方差矩阵用于GW判别分析;否则,使用全局方差协方差矩阵。
- 返回:
true 是
- 返回:
false 否
-
inline void setHascov(bool hascov)
设置将局部方差协方差矩阵用于GW判别分析;否则,使用全局方差协方差矩阵。
- 参数:
hascov -- 是否将局部方差协方差矩阵用于GW判别分析;否则,使用全局方差协方差矩阵。
-
inline bool hasMean() const
获取是否使用局部平均值进行GW判别分析;否则,使用全局平均值。
- 返回:
true 是
- 返回:
false 否
-
inline void setHasmean(bool hasmean)
设置使用局部平均值进行GW判别分析;否则,使用全局平均值。
- 参数:
hasmean -- 是否使用局部平均值进行GW判别分析;否则,使用全局平均值。
-
inline bool hasPrior() const
获取是否将局部先验概率用于GW判别分析;否则,使用固定的先验概率。
- 返回:
true 是
- 返回:
false 否
-
inline void setHasprior(bool hasprior)
设置将局部先验概率用于GW判别分析;否则,使用固定的先验概率。
- 参数:
hasprior -- 是否将局部先验概率用于GW判别分析;否则,使用固定的先验概率。
-
inline double correctRate() const
获取预测正确率
- 返回:
double 预测正确率
-
inline const arma::mat &res() const
获取地理加权判别分析结果矩阵
- 返回:
arma::mat 地理加权判别分析结果矩阵
-
inline const std::vector<std::string> &group() const
获取分类结果
- 返回:
std::vector<std::string> 分类结果
-
inline const arma::mat &probs() const
获取位置概率
- 返回:
arma::mat 位置概率
-
inline const arma::mat &pmax() const
获取位置概率最大值
- 返回:
arma::mat 位置概率最大值
-
inline const arma::mat &entropy() const
获取相关熵
- 返回:
arma::mat 相关熵
-
arma::mat wqda(arma::mat &x, std::vector<std::string> &y, arma::mat &wt, arma::mat &xpr, bool hasCOv, bool hasMean, bool hasPrior)
加权二次判别分析
- 参数:
x -- 自变量矩阵。
y -- 因变量。
wt -- 权重矩阵。
xpr -- 待预测数据变量
hasCov -- 是否使用局部平均值进行GW判别分析;否则,使用全局平均值。
hasMean -- 是否将局部方差协方差矩阵用于GW判别分析;否则,使用全局方差协方差矩阵。
hasPrior -- 是否将局部先验概率用于GW判别分析;否则,使用固定的先验概率。
- 返回:
arma::mat 地理加权判别分析结果矩阵。
-
arma::mat wlda(arma::mat &x, std::vector<std::string> &y, arma::mat &wt, arma::mat &xpr, bool hasCOv, bool hasMean, bool hasPrior)
加权线性判别分析。
- 参数:
x -- 自变量矩阵。
y -- 因变量。
wt -- 权重矩阵。
xpr -- 待预测数据变量
hasCov -- 是否使用局部平均值进行GW判别分析;否则,使用全局平均值。
hasMean -- 是否将局部方差协方差矩阵用于GW判别分析;否则,使用全局方差协方差矩阵。
hasPrior -- 是否将局部先验概率用于GW判别分析;否则,使用固定的先验概率。
- 返回:
arma::mat 地理加权判别分析结果矩阵。
-
std::vector<arma::mat> splitX(arma::mat &x, std::vector<std::string> &y)
根据不同类别筛选自变量矩阵。
- 参数:
x -- 自变量矩阵。
y -- 因变量。
- 返回:
std::vector<arma::mat> 筛选结果。
-
arma::mat wMean(arma::mat &x, arma::mat &wt)
计算局部加权平均值。
- 参数:
x -- 自变量矩阵。
wt -- 权重矩阵。
- 返回:
arma::mat 计算结果。
-
arma::cube wVarCov(arma::mat &x, arma::mat &wt)
计算局部方差协方差。
- 参数:
x -- 自变量矩阵。
wt -- 权重矩阵。
- 返回:
arma::mat 计算结果。
-
arma::vec wPrior(arma::mat &wt, double sumW)
计算局部先验概率。
- 参数:
x -- 自变量矩阵。
sumW -- 权重和。
- 返回:
arma::vec 计算结果。
-
std::vector<std::string> levels(std::vector<std::string> &y)
获取因变量的类别信息。
- 参数:
y -- 因变量。
- 返回:
std::vector<std::string> 类别信息。
-
double shannonEntropy(arma::vec &p)
计算关联熵。
- 参数:
p -- 位置概率
- 返回:
arma::vec 计算结果。
-
arma::uvec findSameString(std::vector<std::string> &y, std::string s)
获取因变量中相同类别的索引。
- 参数:
y -- 因变量。
s -- 检测值。
- 返回:
arma::uvec 索引信息。
-
std::unordered_map<std::string, arma::uword> ytable(std::vector<std::string> &y)
获取因变量中各个类别的数量。
- 参数:
y -- 因变量。
- 返回:
arma::uvec 各个类别的数量信息。
-
virtual bool isValid() override
检查算法配置是否合法。
- 返回:
true 如果算法配置是合法的。
- 返回:
false 如果算法配置不合法。
-
inline virtual const arma::mat &variables() const override
Get variables.
- 返回:
Vector of variables.
-
inline virtual void setVariables(const arma::mat &x) override
Set variables.
- 参数:
x -- Vector of variables.
-
inline void setGroup(std::vector<std::string> &y)
-
virtual void run() override
Run analysis algorithm.
-
inline virtual int parallelAbility() const override
返回该算法的并行能力。
- 返回:
当前算法并行能力的按位或运算结果。
-
inline virtual ParallelType parallelType() const override
返回当前算法的并行类型。
- 返回:
当前算法的并行类型。
-
virtual void setParallelType(const ParallelType &type) override
Set the parallel type of this algorithm.
Use gwmodel_set_gwss_openmp() to set parallel type of this algorithm to ParallelType::OpenMP in shared build.
- 参数:
type -- Parallel type of this algorithm.
-
inline virtual void setOmpThreadNum(const int threadNum) override
Set the thread numbers while paralleling.
Use gwmodel_set_gwss_openmp() to set this property in shared build.
- 参数:
threadNum -- Number of threads.
公有静态方法
-
static arma::mat covwtmat(const arma::mat &x, const arma::vec &wt)
计算两个矩阵的加权协方差矩阵。
- 参数:
x -- 矩阵 \( X \)
w -- 权重向量 \( w \)
- 返回:
加权协方差
\[ cov(X_1,X_2) = \frac{\sum_{i=1}^n w_i(x_{1i} - \bar{x}_1) \sum_{i=1}^n w_i(x_{2i} - \bar{x}_2)}{1 - \sum_{i=1}^n w_i} \]
-
static inline double covwt(const arma::mat &x1, const arma::mat &x2, const arma::vec &w)
计算两个矩阵的加权协方差。
- 参数:
x1 -- 矩阵 \( X_1 \)
x2 -- 矩阵 \( X_2 \)
w -- 权重向量 \( w \)
- 返回:
加权协方差
\[ cov(X_1,X_2) = \frac{\sum_{i=1}^n w_i(x_{1i} - \bar{x}_1) \sum_{i=1}^n w_i(x_{2i} - \bar{x}_2)}{1 - \sum_{i=1}^n w_i} \]
-
static inline double corwt(const arma::mat &x1, const arma::mat &x2, const arma::vec &w)
计算两个矩阵的加权相关系数。
- 参数:
x1 -- 矩阵 \( X_1 \)
x2 -- 矩阵 \( X_2 \)
w -- 权重向量 \( w \)
- 返回:
-
inline GWDA(const arma::mat x, const arma::mat coords, const SpatialWeight &spatialWeight)