Created
June 30, 2020 19:28
-
-
Save a-agmon/7dab578f71b5c6252364cbbd171b58ba to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_sequence_anomaly_rank(seq_a): | |
t_vec = tokenizer.texts_to_sequences([seq_a]) | |
pad_seq = pad_sequences(t_vec, maxlen=MAX_FEAT_LEN, padding='post', truncating='post') | |
vec_seq = vectorize_sequences(pad_seq, VOCAB_SIZE) | |
pred_seq = autoencoder.predict(vec_seq) | |
# get anomaly score | |
score = np.mean(np.power(vec_seq - pred_seq, 2), axis=1) | |
# get anomaly rank | |
rank = stats.percentileofscore(mse, score) | |
return score, rank |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment