2
$\begingroup$

I'm starting a very beginner tutorial for DS/ML. One of the first things to do is to poke at the data they gave me. After doing the typical head() and describe() in pandas, I want to look more carefully at the features that are numerical, to see if there's any correlation between them and the labels (for example, a simple linear relationship).

I've used matplotlib and stuff before, but I want to do this the "correct" way. The tutorial I'm looking at suggests using seaborn, but to be honest it seems difficult to apply to what I'm suggesting (they're looking at more complicated relationships/etc).

I could use matplotlib, but I've never found a smooth, seamless way of making a grid of several plots simultaneously. Doing the "subplot" thing was really clunky. Is there a better way?

What I'd like to do is, let's say I have 4 numerical features, and I want to plot each of them (or their average, etc) vs the label, and display it, so I can quickly see patterns. What's the best way to do this?

$\endgroup$
1
$\begingroup$

I believe seaborn's pairplot is what you are looking for.

Seaborn is a plotting library built on top of matplotlib for exactly the reason you want. To make quick aesthetically pleasing graphs for data analysis. Seaborn also work very well with pandas DataFrames.

$\endgroup$
2
  • $\begingroup$ Hi, thanks, I think this is what I'm looking for, but with one slight change... I want to have a seaborn grid of plots where each plot is from different data actually (not the same dataframe). For example, I want to look at average value of the labels for a given feature, for each of the feature values (of that feature). So it'll mean the data will have to come from different dataframes. Can seaborn do that? thanks! $\endgroup$ Apr 20 '18 at 17:39
  • $\begingroup$ I'd suggest merging the DataFrames into one. I'm not aware how this can be done with different DataFrames. $\endgroup$
    – user50386
    Apr 20 '18 at 23:24
0
$\begingroup$

What you could do is apply a dimensionality reduction technique such as tSNE to visualise all your features at once in 2 or 3 dimensions. Scikit learn has an excellent implementation of tSNE.

However, tSNE is used more to find local structure and clusters in high dimensions, rather than relationships between features. Furthermore, distances between clusters and the reduced X-Y axes mean nothing in tSNE.

If you know your data has some relationship between features, it may be best to use seaborns pairplot, as suggested by M Sef, to plot several features at once.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.