Quando gerei o predict (modelo.predict(27.74456356)) usei a função Reshape para organizar os dados em Array e código gerou o erro abaixo :
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-57-3e5aae9f4605> in <module>
----> 1 modelo.predict(27.74456356)
~/opt/anaconda3/lib/python3.7/site-packages/sklearn/linear_model/_base.py in predict(self, X)
223 Returns predicted values.
224 """
--> 225 return self._decision_function(X)
226
227 _preprocess_data = staticmethod(_preprocess_data)
~/opt/anaconda3/lib/python3.7/site-packages/sklearn/linear_model/_base.py in _decision_function(self, X)
205 check_is_fitted(self)
206
--> 207 X = check_array(X, accept_sparse=['csr', 'csc', 'coo'])
208 return safe_sparse_dot(X, self.coef_.T,
209 dense_output=True) + self.intercept_
~/opt/anaconda3/lib/python3.7/site-packages/sklearn/utils/validation.py in check_array(array, accept_sparse, accept_large_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, ensure_min_samples, ensure_min_features, warn_on_dtype, estimator)
547 "Reshape your data either using array.reshape(-1, 1) if "
548 "your data has a single feature or array.reshape(1, -1) "
--> 549 "if it contains a single sample.".format(array))
550 # If input is 1D raise error
551 if array.ndim == 1:
ValueError: Expected 2D array, got scalar array instead:
array=27.74456356.
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.
Mas quando usei o dado da bilheteria (bilheteria = 27.74456356) diretamente na função (modelo.coef_*27.74456356 + modelo.intercept_) consegui encontrar o valor do investimento. O que aconteceu de errado ?