# Predicting Introversion/Extroversion Based on Your Writing?

Introversion/extroversion/ambiversion is a non-linear, multi-faceted spectrum, which many people overlook — one can achieve energy and be drained by the same activity, one’s behavior may change drastically dependent on certain situations, etc.

That being said, the concept of “energy” itself is fascinating — what exactly is one’s energy, and how does that affect others when you interact?

`#define a function to appropriately label extrovert/introvert tendenciesdef label(energy_in):energy_out = 0if energy_in == 'I':energy_out = 0elif energy_in == 'E':energy_out = 1return energy_outdf['energyquant'] =  df['energy'].apply(lambda  x: label(x))df.head()`
`nb_matrix = confusion_matrix(y_test, nb_test_preds)group_names = ['True Neg','False Pos','False Neg','True Pos']group_counts = ["{0:0.0f}".format(value) for value innb_matrix.flatten()]group_percentages = ["{0:.2%}".format(value) for value innb_matrix.flatten()/np.sum(nb_matrix)]labels = [f"{v1}\n{v2}\n{v3}" for v1, v2, v3 inzip(group_names,group_counts,group_percentages)]labels = np.asarray(labels).reshape(2,2)sns.heatmap(nb_matrix, annot=labels, fmt='', cmap='Blues')`

polymath using data science to build friendship + camaraderie

## More from Alaska Lam

polymath using data science to build friendship + camaraderie