首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何获取` `skbio`‘PCoA (主坐标分析)结果?

如何获取` `skbio`‘PCoA (主坐标分析)结果?
EN

Stack Overflow用户
提问于 2016-07-15 05:10:58
回答 0查看 2.2K关注 0票数 4

我正在研究skbio's PCoA方法的attributes (如下所列)。我是这个API的新手,我希望能够将eigenvectors和原始点投影到新的轴上,类似于sklearn.decomposition.PCA中的.fit_transform,这样我就可以创建一些PC_1 vs PC_2-style图。我想出了如何获取eigvalsproportion_explained,但featuresNone的形式返回。

是不是因为它还处于测试阶段?

如果有任何教程使用这一点,那将非常感谢。我是scikit-learn的超级粉丝,并且想要开始使用更多的scikit's产品。

代码语言:javascript
复制
|  Attributes
 |  ----------
 |  short_method_name : str
 |      Abbreviated ordination method name.
 |  long_method_name : str
 |      Ordination method name.
 |  eigvals : pd.Series
 |      The resulting eigenvalues.  The index corresponds to the ordination
 |      axis labels
 |  samples : pd.DataFrame
 |      The position of the samples in the ordination space, row-indexed by the
 |      sample id.
 |  features : pd.DataFrame
 |      The position of the features in the ordination space, row-indexed by
 |      the feature id.
 |  biplot_scores : pd.DataFrame
 |      Correlation coefficients of the samples with respect to the features.
 |  sample_constraints : pd.DataFrame
 |      Site constraints (linear combinations of constraining variables):
 |      coordinates of the sites in the space of the explanatory variables X.
 |      These are the fitted site scores
 |  proportion_explained : pd.Series
 |      Proportion explained by each of the dimensions in the ordination space.
 |      The index corresponds to the ordination axis labels

下面是生成principal component analysis对象的代码。

代码语言:javascript
复制
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.datasets import load_iris
from sklearn.preprocessing import StandardScaler
from sklearn import decomposition
import seaborn as sns; sns.set_style("whitegrid", {'axes.grid' : False})
import skbio
from scipy.spatial import distance

%matplotlib inline
np.random.seed(0)

# Iris dataset
DF_data = pd.DataFrame(load_iris().data, 
                       index = ["iris_%d" % i for i in range(load_iris().data.shape[0])],
                       columns = load_iris().feature_names)
n,m = DF_data.shape
# print(n,m)
# 150 4

Se_targets = pd.Series(load_iris().target, 
                       index = ["iris_%d" % i for i in range(load_iris().data.shape[0])], 
                       name = "Species")

# Scaling mean = 0, var = 1
DF_standard = pd.DataFrame(StandardScaler().fit_transform(DF_data), 
                           index = DF_data.index,
                           columns = DF_data.columns)

# Distance Matrix
Ar_dist = distance.squareform(distance.pdist(DF_standard.T, metric="braycurtis")) # (m x m) distance measure
DM_dist = skbio.stats.distance.DistanceMatrix(Ar_dist, ids=DF_standard.columns)
PCoA = skbio.stats.ordination.pcoa(DM_dist)

EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38384329

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档