<jupyter_start><jupyter_text>Análisis de Componentes Principales - SkLearn<jupyter_code>import pandas as pd

import plotly.plotly as py
from plotly.graph_objs import * 
import plotly.tools as tls

from sklearn.preprocessing import StandardScaler

tls.set_credentials_file(username='JuanGabriel', api_key='6mEfSXf8XNyIzpxwb8z7')
df = pd.read_csv("../datasets/iris/iris.csv")
X = df.iloc[:,0:4].values
y = df.iloc[:,4].values
X_std = StandardScaler().fit_transform(X)
from sklearn.decomposition import PCA as sk_pca
acp = sk_pca(n_components=2)
Y = acp.fit_transform(X_std)
Y
results = []

for name in ('setosa', 'versicolor', 'virginica'):
    result = Scatter(x = Y[y==name,0], y = Y[y==name, 1],
                    mode = "markers", name = name,
                    marker = Marker(size=8, line=Line(color="rgba(225,225,225,0.2)", width=0.5),
                                   opacity = 0.75))
    results.append(result)
    
data = Data(results)
layout = Layout(xaxis = XAxis(title="CP1", showline=False),
               yaxis = YAxis(title="CP2", showline=False))

fig = Figure(data = data, layout = layout)
py.iplot(fig)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14100346020761245, 'fraction_numerical': 0.025086505190311418, 'mean_word_length': 3.800829875518672, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '413011', 'license': 'MIT', 'n_tokens_mistral': 445, 'n_tokens_neox': 426, 'n_words': 83, 'path': 'notebooks/T10 - 2 - Analisis de Componentes Principales SK Learn.ipynb', 'repo_name': 'eliza9528/python-ml-course', 'size': '1156'}