Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save readytheory/78203a4651c4079c62de3dd7924cc0a9 to your computer and use it in GitHub Desktop.
Save readytheory/78203a4651c4079c62de3dd7924cc0a9 to your computer and use it in GitHub Desktop.
Anomalous Dex -- Stuck on 4.1.c.3
# run this script using persisted model.joblib from step 3
from typing import Optional, List
from pydantic import BaseModel
from joblib import load
clf = load("model.joblib")
class FeatureVector(BaseModel):
vector: List[float]
score: Optional[bool] = None
demo_input = FeatureVector(vector=[-0.15795269682074692, 0.0007172682747855299])
clf.score_samples(demo_input.vector)
"""Line above gets error:
Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample.
"""
x = clf.score_samples([(-0.15795269682074692,-0.10624223103526062),
(-0.2531546758780664,-0.10674898283572026),
(0.0007172682747855299,-0.10674898283572026)])
print(x)
# array([-0.34156764, -0.42965497, -0.3826468 ])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment