google-gemini/cookbook

Anomaly detection issue

Closed this issue · 2 comments

Honestly the code/process in Anomaly detection was way over my head, but I was slowly going through it and ran into an error. I was in the second code cell after "Choose a radius. Anything beyond this bound from the centroid of that category is considered an outlier."

range_ = np.arange(0.3, 0.75, 0.02).round(decimals=2).tolist()
num_outliers = []
for i in range_:
  num_outliers.append(detect_outlier(df_train, emb_c, i))

And got:

image

I honestly don't know if this is expected, or I messed something up earlier. As far as I know I ran every previous cell and it worked ok.

If you have

run every previous cell and it worked ok

the only possible issue I can imagine is that you have restarted the Kernel, because when you restart the Jupyter kernel, all variables defined in previous sessions are lost.

Our notebooks are designed to be run from start to finish, in order. If you skip a cell then you can run into errors like that, try running step by step from the start again.

FWIW, the cell where emb_c is defined contains this:

emb_c = get_embedding_centroids(df_train)

Make sure you are running that.

If running step-by-step doesn't work, you may have deleted the cell. Try loading the notebook fresh, running step-by-step, and then if you still encounter issues you can re-open this.