Issue
I have loop like below:
for feature1 in numeric_features:
for feature2 in [var for var in numeric_features if var != feature1]:
scatter_plot(f"{zmienna1}", f"{zmienna2}", "Overweight")
plt.tight_layout()
plt.show()
This loop generate scatter plots, using function created by me, for combination feature1 x feature 2, nevetheless how can I change this loop so as to do not generate 2 time the same plots but with other combination of features.
For example I have plot 1 Height vs Age :
ANd I have plot 2 Age vs Height:
And I need to change this loop so as to generate only one scatter plot for combination feature1 vs feature2.
Solution
Use itertools:
import itertools
for feature1,feature2 in itertools.combinations(numeric_features,2):
scatter_plot(f"{zmienna1}", f"{zmienna2}", "Overweight")
plt.tight_layout()
plt.show()
Answered By - Tim Roberts
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.