私はattributes
をskbio's
PCoA
(以下に記載)の方法で探しています。私はこの新しいAPI
に新しく、を得て、.fit_transform
のsklearn.decomposition.PCA
に似た新しい軸に投影された元の点が得られるように、PC_1 vs PC_2
スタイルのプロットを作成することができます。私はeigvals
とproportion_explained
を得る方法を考え出しましたが、features
はNone
として戻ってきます。`skbio` PCoA(Principal Coordinate Analysis)の結果を得る方法は?
これはベータ版のためですか?
これを使用するチュートリアルがあれば、それは非常に感謝しています。私はscikit-learn
の巨大なファンであり、より多くの製品を使用開始したいと考えていますscikit's
製品。
| 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
オブジェクトを生成するコードです。
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)
私は '.samples'は何も返されないと信じています。私はもう一度やり直すことができます、私は私の 'skbio'を更新していることを確認します。私はPCoAについて読んできましたが、多くのリソースはかなりわかりにくいです。 PCAに関しては、それは同じステップであるが、共分散行列の代わりに距離行列上の固有分解であるか? –
'' pcoa 'によって生成された 'OrdinationResults'に' .samples'が必要です。まだ 'None'を取得している場合は、[scikit-bio issue tracker](https://github.com/biocore/scikit-bio/issues)に問題を投稿してください。私の理解では、PCoAは距離行列に適用され、非ユークリッド距離メトリクスの使用が可能になりますが、PCAはフィーチャテーブルに適用されユークリッド距離が使用されます。したがって、ユークリッド距離行列上でPCoAを実行することは、PCAと同等である。 [ここにある](http://ordination.okstate.edu/overview.htm#Principal_coordinates_analysis)は、指導方法の役に立つ資料です。 – jairideout
'DF = skbio.OrdinationResults(long_method_name =" TESTING "、short_method_name ="テスト "、eigvals = PCoA.eigvals、samples = DF_data) DF.samples'は変換されていない元のデータを返します。私はこれを間違ってやっていますか? –