Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential Error in Resampling Notebook: shuffle_experiment function #7

Open
ramseyb4 opened this issue May 24, 2018 · 0 comments
Open

Comments

@ramseyb4
Copy link

ramseyb4 commented May 24, 2018

In the shuffle_experiment function, I believe the accessing of the experiment_data array used to calculate the mean is off (see highlighted portion below). Specifically, the condition is grabbing the rows labeled 0 or 1 correctly, however, after that we need to only grab the second column of each row so as to exclude the label value from the mean calculation.

Current code:

def shuffle_experiment(number_of_times):
experiment_diff_mean = np.empty([number_of_times,1])
for times in np.arange(number_of_times):
experiment_label = np.random.randint(0,2,shoe_sales.shape[0])
experiment_data = np.array([experiment_label, shoe_sales[:,1]]).T
experiment_diff_mean[times] = experiment_data[experiment_data[:,0]==1].mean()
- experiment_data[experiment_data[:,0]==0].mean()

return experiment_diff_mean

Proposed code:

def shuffle_experiment(number_of_times):
experiment_diff_mean = np.empty([number_of_times,1])
for times in np.arange(number_of_times):
experiment_label = np.random.randint(0,2,shoe_sales.shape[0])
experiment_data = np.array([experiment_label, shoe_sales[:,1]]).T
experiment_diff_mean[times] = experiment_data[experiment_data[:,0]==1][:,1].mean()
- experiment_data[experiment_data[:,0]==0][:,1].mean()
return experiment_diff_mean

The same issue exists in this block:

experiment_diff_mean = experiment_data[experiment_data[:,0]==1][:,1].mean()
- experiment_data[experiment_data[:,0]==0][:,1].mean()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant