title: Using 4 components in Principle Component Analysis (PCA)
body: <p>I don't know how to interpret the output of Principle Components Analysis (PCA) and the cumulative sum graph.</p>
  
  <p>I have the following problem. I have 4 machines (A, B, C, and D), and each machine has 9 features where measurements were taken along the time. The goal is to classify the machine behavior.</p>
  
  <p>I am using Principle Components Analysis to reduce the dimensionality from 9 features. By reducing the dimensionality of the original feature space by projecting it onto a smaller subspace, and then plotting the cumulative sum over all the variance, you can see that the first 4 eigenvalues correspond to approximately 82% of all variance <a href="https://i.stack.imgur.com/KPP8U.png" rel="nofollow noreferrer">1</a>. It means that there is 18% of information being lost with the dimensionality reduction.</p>
  
  <p>I want to cluster machines based on the Principal Components, but the examples that I find always plot the data using 2 Principal components (PCs) <a href="https://i.stack.imgur.com/9FKqV.png" rel="nofollow noreferrer">2</a>. The <a href="https://i.stack.imgur.com/9FKqV.png" rel="nofollow noreferrer">2</a> is the graph that I plot using just 2 PCs.</p>
  
  <p>If the cumulative sum graph suggests that 4 PCs corresponds to 82% of all variance, and the examples of PCA only have 2 PCs, what should I do? Do I apply PCA a second time? Or I need to do something else that I don't know?</p>
  
  <p>In [3] I show the code that I have to use PCA with 2 components and plot the graph. The A, B, C, and D are the machines.</p>
  
  <p><a href="https://i.stack.imgur.com/KPP8U.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KPP8U.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/9FKqV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9FKqV.png" alt="enter image description here"></a></p>
  
  <p>[3]</p>
  
  <pre><code>sklearn_pca = sklearnPCA(n_components=2)
  Y_sklearn = sklearn_pca.fit_transform(X_std)
  
  data = []
  
  for name, col in zip(machine_list, colors.values()):
  
      trace = dict(
          type='scatter',
          x=Y_sklearn[y==name,0],
          y=Y_sklearn[y==name,1],
          mode='markers',
          name=name,
          marker=dict(
              color=col,
              size=12,
              line=dict(
                  color='rgba(217, 217, 217, 0.14)',
                  width=0.5),
              opacity=0.8)
      )
      data.append(trace)
  
  layout = dict(
          xaxis=dict(title='PC1', showline=False),
          yaxis=dict(title='PC2', showline=False)
  )
  fig = dict(data=data, layout=layout)
  iplot(fig)
  </code></pre>