1

I was wondering how I can plot a correlation circle after a PCA.

I came accross this subject: Plot a Correlation Circle in Python.

But the code given in the answer doesn't plot the graph shown in the question message (which is what I want) but something else.

I also found out about a module called Prince which is supposed to have a function plotting a correlation circle, but it's not working for me, I get an assertion error :

assert k > 0 
AssertionError

And here is my code (i got the dataframe from a SQL query and it's ok) :

pca = prince.PCA(df, n_components=2)
pca.plot_correlation_circle()
plt.show()

So, does anyone know how to use prince's PCA or simply how to plot a correlation circle in Python?

Community
  • 1
  • 1
MarieC
  • 37
  • 3
  • 6
  • 1
    why not using the code from the link done in the answer of this post : http://stackoverflow.com/questions/37815987/plot-a-correlation-circle-in-python ?? – Dadep Apr 11 '17 at 14:13
  • Because I tried it but it's not doing a correlation circle, it draws one line per observation in a circle which is not what I want – MarieC Apr 12 '17 at 07:34
  • maybe your not passing the right information as argument of this function, in the function `circleOfCorrelations(pc_infos, ebouli):` done by Mazieres (https://github.com/mazieres/analysis/blob/master/analysis.py#L19-34), you shouldn't pass the dataframe as argument, have a look more in detail, this function is called in the other function call `myPCA`. You can have a look at the example in comment at the end of the code – Dadep Apr 12 '17 at 11:28
  • Yes you are right, it works, thanks :) – MarieC Apr 13 '17 at 12:09

0 Answers0