refactored to add memory of z_score during train
threshold has default argument
added test skeleton