我正试图解开模型出现以下错误?

时间:2018-07-22 04:09:30

标签: python machine-learning attributes pickle prediction

取消选择预测模型时出现错误。 这些是我的以下代码。

import pickle
import numpy as np
filename = 'finalized_model.sav'
# load the model from disk
loadedmodel = pickle.load(open(filename, 'rb'))

newinput=np.array([ 8450,     0,     7,     5,     2]) # new input features
newinput=newinput.reshape(1, 5)

predictions = loadedmodel.predict(newinput) # given getting errror
print('Input sample:',newinput)
print('Predicted Class:',predictions)

这些是我得到的以下错误

> AttributeError                            Traceback (most recent call
> last) <ipython-input-11-a30582e8c946> in <module>()
>      14 newinput=newinput.reshape(1, 5)
>      15 
> ---> 16 predictions = loadedmodel.predict(newinput) # given unlabeled observations X, returns the predicted labels y.
>      17 print('Input sample:',newinput)
>      18 print('Predicted Class:',predictions)
> 
> ~/.local/lib/python3.6/site-packages/pandas/core/generic.py in
> __getattr__(self, name)    4370             if self._info_axis._can_hold_identifiers_and_holds_name(name):    4371   
> return self[name]
> -> 4372             return object.__getattribute__(self, name)    4373     4374     def __setattr__(self, name, value):
> 
> AttributeError: 'DataFrame' object has no attribute 'predict'

0 个答案:

没有答案