FranciscoLozDataScience commited on
Commit
1cea5f0
·
1 Parent(s): e4e6b6a

I have to reshape the array

Browse files
Files changed (1) hide show
  1. model.py +10 -2
model.py CHANGED
@@ -30,9 +30,9 @@ class SmokerModel:
30
 
31
  return new_data_scaled
32
 
33
- def predict(self, X):
34
  """
35
- Make predictions using the loaded model.
36
 
37
  INPUT
38
  -----
@@ -43,6 +43,14 @@ class SmokerModel:
43
  predicted label
44
  """
45
 
 
 
 
 
 
 
 
 
46
  # scale the data
47
  X_scaled = self.scale(X)
48
 
 
30
 
31
  return new_data_scaled
32
 
33
+ def predict(self, X: np.ndarray):
34
  """
35
+ Make a prediction on one sample using the loaded model.
36
 
37
  INPUT
38
  -----
 
43
  predicted label
44
  """
45
 
46
+ # Check if the array is 1-dimensional aka one sample
47
+ if len(X.shape) != 1:
48
+ raise ValueError("Input array must be one-dimensional (one sample), but got a shape of {}".format(X.shape))
49
+ return
50
+
51
+ # Reshape the array
52
+ X = X.reshape(1, -1)
53
+
54
  # scale the data
55
  X_scaled = self.scale(X)
56