Clement Vachet commited on
Commit
921c0a2
·
1 Parent(s): 09fc993

Convert features to numpy array

Browse files
Files changed (2) hide show
  1. classification/classifier.py +4 -4
  2. models/model.pkl +0 -0
classification/classifier.py CHANGED
@@ -4,7 +4,7 @@ from sklearn.model_selection import train_test_split
4
  import joblib
5
  import pandas as pd
6
  import os
7
-
8
 
9
  class Classifier:
10
  def __init__(self):
@@ -41,10 +41,10 @@ class Classifier:
41
  model_path = os.path.join(parent_dir, "models", "model.pkl")
42
  model = joblib.load(model_path)
43
 
44
- features = data.get('features', [])
45
 
46
- if not isinstance(features, list) or not all(isinstance(sample, list) for sample in features):
47
- raise ValueError("Input data should be a list of feature vectors.")
48
 
49
  # Predict the class
50
  predictions = model.predict(features).tolist()
 
4
  import joblib
5
  import pandas as pd
6
  import os
7
+ import numpy as np
8
 
9
  class Classifier:
10
  def __init__(self):
 
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.")
48
 
49
  # Predict the class
50
  predictions = model.predict(features).tolist()
models/model.pkl CHANGED
Binary files a/models/model.pkl and b/models/model.pkl differ