MachineLearningWithPython icon indicating copy to clipboard operation
MachineLearningWithPython copied to clipboard

List Comprehension Error?

Open gregcman opened this issue 4 years ago • 1 comments

Untitled

y_train[y_train[:] == 1] and y_train[y_train[:] == 0]

both return 537 rows.

gregcman avatar Jun 29 '21 02:06 gregcman

Yes can confirm that with docker jupyter/scipy-notebook:notebook-6.4.12. It uses Python 3.10.6, pandas 1.5.0. It works with:

print("Original True : {0} ({1:0.2f}%)".format(len(df.loc[df['diabetes'] == 1]), (len(df.loc[df['diabetes'] == 1])/len(df.index)) * 100.0)) print("Original False : {0} ({1:0.2f}%)".format(len(df.loc[df['diabetes'] == 0]), (len(df.loc[df['diabetes'] == 0])/len(df.index)) * 100.0)) print("") print("Training True : {0} ({1:0.2f}%)".format(y_train.value_counts()[1], y_train.value_counts()[1] / y_train.size * 100)) print("Training False : {0} ({1:0.2f}%)".format(y_train.value_counts()[0], y_train.value_counts()[0] / y_train.size * 100)) print("") print("Test True : {0} ({1:0.2f}%)".format(y_test.value_counts()[1], y_test.value_counts()[1] / y_test.size * 100)) print("Test False : {0} ({1:0.2f}%)".format(y_test.value_counts()[0], y_test.value_counts()[0] / y_test.size * 100))

ischoeff avatar Nov 29 '22 16:11 ischoeff