File c:\Users\narvashi\projects\STERIS\venv\Lib\site-packages\supervised\automl.py:451, in AutoML.predict(self, X)
434 def predict(self, X: Union[List, numpy.ndarray, pandas.DataFrame]) -> numpy.ndarray:
435 """
436 Computes predictions from AutoML best model.
437
(...)
449 AutoMLException: Model has not yet been fitted.
450 """
--> 451 return self._predict(X)
File c:\Users\narvashi\projects\STERIS\venv\Lib\site-packages\supervised\base_automl.py:1503, in BaseAutoML._predict(self, X)
1502 def _predict(self, X):
-> 1503 predictions = self._base_predict(X)
1504 # Return predictions
1505 # If classification task the result is in column 'label'
1506 # If regression task the result is in column 'prediction'
1507 return (
1508 predictions["label"].to_numpy()
1509 if self._ml_task != REGRESSION
1510 else predictions["prediction"].to_numpy()
1511 )
File c:\Users\narvashi\projects\STERIS\venv\Lib\site-packages\supervised\base_automl.py:1469, in BaseAutoML._base_predict(self, X, model)
1467 predictions = model.predict(X_stacked)
1468 else:
-> 1469 predictions = model.predict(X)
1471 if self._ml_task == BINARY_CLASSIFICATION:
1472 # need to predict the label based on predictions and threshold
1473 neg_label, pos_label = (
1474 predictions.columns[0][11:],
1475 predictions.columns[1][11:],
1476 )
File c:\Users\narvashi\projects\STERIS\venv\Lib\site-packages\supervised\model_framework.py:447, in ModelFramework.predict(self, X)
444 y_predicted = None # np.zeros((X.shape[0],))
445 for ind, learner in enumerate(self.learners):
446 # preprocessing goes here
--> 447 Xdata, , _ = self.preprocessings[ind].transform(X.copy(), None)
448 y_p = learner.predict(X_data)
449 y_p = self.preprocessings[ind].inverse_scale_target(y_p)
File c:\Users\narvashi\projects\STERIS\venv\Lib\site-packages\supervised\preprocessing\preprocessing.py:361, in Preprocessing.transform(self, X_validation, y_validation, sample_weight_validation)
359 for tt in self._text_transforms:
360 if X_validation is not None and tt is not None:
--> 361 X_validation = tt.transform(X_validation)
363 for missing in self._missing_values:
364 if X_validation is not None and missing is not None:
File c:\Users\narvashi\projects\STERIS\venv\Lib\site-packages\supervised\preprocessing\text_transformer.py:36, in TextTransformer.transform(self, X)
34 ii = ~pd.isnull(X[self._old_column])
35 x = X[self._old_column][ii]
---> 36 vect = self._vectorizer.transform(x)
38 for f in self._new_columns:
39 X[f] = 0.0
File c:\Users\narvashi\projects\STERIS\venv\Lib\site-packages\sklearn\feature_extraction\text.py:2118, in TfidfVectorizer.transform(self, raw_documents)
2115 check_is_fitted(self, msg="The TF-IDF vectorizer is not fitted")
2117 X = super().transform(raw_documents)
-> 2118 return self._tfidf.transform(X, copy=False)
File c:\Users\narvashi\projects\STERIS\venv\Lib\site-packages\sklearn\feature_extraction\text.py:1707, in TfidfTransformer.transform(self, X, copy)
1702 X.data += 1.0
1704 if hasattr(self, "idf_"):
1705 # the columns of X (CSR matrix) can be accessed with X.indicesand
1706 # multiplied with the corresponding idf value
-> 1707 X.data *= self.idf_[X.indices]
1709 if self.norm is not None:
1710 X = normalize(X, norm=self.norm, copy=False)
TypeError: only integer scalar arrays can be converted to a scalar index
I am trying to load the saved model using the following command
automl = AutoML(mode='Explain',results_path='Auto_Ml_testing') automl.fit(X_train,y_train)
automl = AutoML(results_path='Auto_Ml_testing')
automl.predict(X_test)
but the '.predict' is giving the following error
TypeError Traceback (most recent call last) Cell In[12], line 1 ----> 1 automl.predict(X_test)
File c:\Users\narvashi\projects\STERIS\venv\Lib\site-packages\supervised\automl.py:451, in AutoML.predict(self, X) 434 def predict(self, X: Union[List, numpy.ndarray, pandas.DataFrame]) -> numpy.ndarray: 435 """ 436 Computes predictions from AutoML best model. 437 (...) 449 AutoMLException: Model has not yet been fitted. 450 """ --> 451 return self._predict(X)
File c:\Users\narvashi\projects\STERIS\venv\Lib\site-packages\supervised\base_automl.py:1503, in BaseAutoML._predict(self, X) 1502 def _predict(self, X): -> 1503 predictions = self._base_predict(X) 1504 # Return predictions 1505 # If classification task the result is in column 'label' 1506 # If regression task the result is in column 'prediction' 1507 return ( 1508 predictions["label"].to_numpy() 1509 if self._ml_task != REGRESSION 1510 else predictions["prediction"].to_numpy() 1511 )
File c:\Users\narvashi\projects\STERIS\venv\Lib\site-packages\supervised\base_automl.py:1469, in BaseAutoML._base_predict(self, X, model) 1467 predictions = model.predict(X_stacked) 1468 else: -> 1469 predictions = model.predict(X) 1471 if self._ml_task == BINARY_CLASSIFICATION: 1472 # need to predict the label based on predictions and threshold 1473 neg_label, pos_label = ( 1474 predictions.columns[0][11:], 1475 predictions.columns[1][11:], 1476 )
File c:\Users\narvashi\projects\STERIS\venv\Lib\site-packages\supervised\model_framework.py:447, in ModelFramework.predict(self, X) 444 y_predicted = None # np.zeros((X.shape[0],)) 445 for ind, learner in enumerate(self.learners): 446 # preprocessing goes here --> 447 Xdata, , _ = self.preprocessings[ind].transform(X.copy(), None) 448 y_p = learner.predict(X_data) 449 y_p = self.preprocessings[ind].inverse_scale_target(y_p)
File c:\Users\narvashi\projects\STERIS\venv\Lib\site-packages\supervised\preprocessing\preprocessing.py:361, in Preprocessing.transform(self, X_validation, y_validation, sample_weight_validation) 359 for tt in self._text_transforms: 360 if X_validation is not None and tt is not None: --> 361 X_validation = tt.transform(X_validation) 363 for missing in self._missing_values: 364 if X_validation is not None and missing is not None:
File c:\Users\narvashi\projects\STERIS\venv\Lib\site-packages\supervised\preprocessing\text_transformer.py:36, in TextTransformer.transform(self, X) 34 ii = ~pd.isnull(X[self._old_column]) 35 x = X[self._old_column][ii] ---> 36 vect = self._vectorizer.transform(x) 38 for f in self._new_columns: 39 X[f] = 0.0
File c:\Users\narvashi\projects\STERIS\venv\Lib\site-packages\sklearn\feature_extraction\text.py:2118, in TfidfVectorizer.transform(self, raw_documents) 2115 check_is_fitted(self, msg="The TF-IDF vectorizer is not fitted") 2117 X = super().transform(raw_documents) -> 2118 return self._tfidf.transform(X, copy=False)
File c:\Users\narvashi\projects\STERIS\venv\Lib\site-packages\sklearn\feature_extraction\text.py:1707, in TfidfTransformer.transform(self, X, copy) 1702 X.data += 1.0 1704 if hasattr(self, "idf_"): 1705 # the columns of X (CSR matrix) can be accessed with
X.indices
and 1706 # multiplied with the correspondingidf
value -> 1707 X.data *= self.idf_[X.indices] 1709 if self.norm is not None: 1710 X = normalize(X, norm=self.norm, copy=False)TypeError: only integer scalar arrays can be converted to a scalar index