Ich bin auf die attributes
von skbio's
PCoA
Methode (unten aufgeführt). Ich bin neu in diesem API
und ich möchte in der Lage sein, die eigenvectors
und die ursprünglichen Punkte projiziert auf die neue Achse ähnlich .fit_transform
in sklearn.decomposition.PCA
, so kann ich einige PC_1 vs PC_2
-Plots erstellen. Ich habe herausgefunden, wie man die eigvals
und proportion_explained
aber features
kommt wieder als None
.Wie bekomme ich `skbio` PCoA (Hauptkoordinatenanalyse) Ergebnisse?
Ist das, weil es in der Beta ist?
Wenn es irgendwelche Tutorials gibt, die dies verwenden, würde das sehr geschätzt werden. Ich bin ein großer Fan von scikit-learn
und möchte mehr Produkte von scikit's
verwenden.
| 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
Hier ist mein Code, um das principal component analysis
Objekt zu erzeugen.
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)
Ich glaube, '.samples' zurückgegeben nichts. Ich kann es erneut versuchen und werde sicherstellen, dass mein 'skbio' aktualisiert wird. Ich habe über PCoA gelesen und viele der Ressourcen sind eher kryptisch. In Bezug auf PCA, ist es die gleichen Schritte aber Eigenkomposition auf der Distanz-Matrix anstelle der Kovarianz-Matrix? –
'.samples' wird für' OrdinationResults' benötigt, die von 'pcoa' erzeugt werden. Wenn Sie immer noch "None" erhalten, können Sie bitte ein Problem im [scikit-bio issue tracker] (https://github.com/biocore/scikit-bio/issues) veröffentlichen. Nach meinem Verständnis wird PCoA auf eine Entfernungsmatrix angewendet, die die Verwendung nicht-euklidischer Entfernungsmetriken ermöglicht, während PCA auf eine Feature-Tabelle angewendet wird und die euklidische Distanz verwendet. Daher ist das Ausführen von PCoA auf einer euklidischen Abstandsmatrix äquivalent zu PCA. [Hier ist] (http://ordination.okstate.edu/overview.htm#Principal_coordinates_analysis) eine nützliche Ressource für Ordinationsmethoden. – jairideout
'DF = skbio.OrdinationResults (lang_Methodenname =" TESTEN ", short_method_name =" test ", eigvals = PCoA.eigvals, samples = DF_data) DF.samples' gibt mir meine Originaldaten zurück, die nicht transformiert wurden. Mache ich das falsch? –