Clement Vachet commited on
Commit
f4e0e4a
·
1 Parent(s): 78adc20

Use list of features as direct input

Browse files
classification/classifier.py CHANGED
@@ -41,7 +41,7 @@ class Classifier:
41
  model_path = os.path.join(parent_dir, "models", "model.pkl")
42
  model = joblib.load(model_path)
43
 
44
- features = np.array(data["features"])
45
 
46
  if features.shape[-1] != 4:
47
  raise ValueError("Expected 4 features per input.")
 
41
  model_path = os.path.join(parent_dir, "models", "model.pkl")
42
  model = joblib.load(model_path)
43
 
44
+ features = np.array(data)
45
 
46
  if features.shape[-1] != 4:
47
  raise ValueError("Expected 4 features per input.")
main.py CHANGED
@@ -9,11 +9,11 @@ if __name__ == "__main__":
9
  cls.train_and_save()
10
 
11
  # Testing
12
- data = { "features": [
13
- [6.5, 3.0, 5.8, 2.2],
14
- [6.1, 2.8, 4.7, 1.2]
15
- ]}
16
- results = cls.load_and_test(data)
17
  print("results:", results)
18
 
19
  # Response similar to REST API call
 
9
  cls.train_and_save()
10
 
11
  # Testing
12
+ data = {
13
+ "features": [[6.5, 3.0, 5.8, 2.2],[6.1, 2.8, 4.7, 1.2]]
14
+ }
15
+ features = data["features"]
16
+ results = cls.load_and_test(features)
17
  print("results:", results)
18
 
19
  # Response similar to REST API call
models/model.pkl CHANGED
Binary files a/models/model.pkl and b/models/model.pkl differ
 
tests/test_classifier.py CHANGED
@@ -21,4 +21,4 @@ def response():
21
  return ["virginica", "versicolor"]
22
 
23
  def test_response(setup_pipeline, requests, response):
24
- assert response == setup_pipeline.load_and_test(requests)["predictions"]
 
21
  return ["virginica", "versicolor"]
22
 
23
  def test_response(setup_pipeline, requests, response):
24
+ assert response == setup_pipeline.load_and_test(requests["features"])["predictions"]