-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtester.py
42 lines (34 loc) · 834 Bytes
/
tester.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# -*- coding: utf-8 -*-
"""
Created on Sat Feb 29 19:29:58 2020
@author: Akshat
"""
import pandas as pd
import numpy as np
from keras.models import load_model
def pre(fname):
df = pd.read_csv(fname).dropna()
index = df["original_index"]
del df["original_index"]
u = df.mean()
s = df.std()
output = df.apply(lambda x: (x - u) / s, axis = 1)
return output.to_numpy(), index
def predict():
model = load_model("trained_models/flat0.h5")
x, dex = pre("../shell_data/clean_dataset.csv")
xhat = model.predict(x)
se = np.square(xhat - x)
mse = np.mean(se, axis = 1)
return mse, dex
import matplotlib.pyplot as plt
y, x = predict()
plt.scatter(x, y)
anomalies = [10634, 36136, 57280, 57618, 60545, 63144, 118665, 128524, 131118]
dexes = []
for i in anomalies:
try:
a, = x[x == i].index
dexes += [y[a]]
except:
...