【问题标题】:How to fix this common error of numpy.ndarray如何修复 numpy.ndarray 的这个常见错误
【发布时间】:2019-03-27 02:34:42
【问题描述】:

'''我正在开展一个分析和预测有关板球数据集的信息的项目。我遇到了 numpy.ndarrary 对象不可调用的错误。我应该如何解决这个错误'''

team1='MI'
team2='CSK'
toss_winner='CSK'
input=[dicVal[team1],dicVal[team2],'15',dicVal[toss_winner],'12','1']
input = np.array(input).reshape((1, -1))
output=model.predict(input)
print(list(dicVal.keys())[list(dicVal.values()).index(output)])
#This code works fine as there is direct initialization of team1 and team2


team1=input("Enter team-1 :")   #<--numpy.ndarrary object not callable
team2=input("Enter team-2 :")
toss_winner=input("Enter toss winner :")
city=input("Enter the corresponding no for the following cities :")
venue=input("Enter the corresponding no for the following stadiums :")
toss=input("Enter the corresponding no for the following toss decision :")

input=[dicVal[team1],dicVal[team2],venue,dicVal[toss_winner],city,toss]
input = np.array(input).reshape((1, -1))
output=model.predict(input)
print(list(dicVal.keys())[list(dicVal.values()).index(output)])

'''在第一行本身我得到一个 numpy.ndarrary object not callable 的错误。请帮我解决这个问题。'''

【问题讨论】:

    标签: python-3.x numpy-ndarray


    【解决方案1】:

    名为 input 的变量隐藏了 Python 函数输入。

    【讨论】:

    • 在我们得到 OP 的意见之前,我认为是有道理的。
    【解决方案2】:

    您可能使用的是不稳定版本的 numpy。我正在使用 google colab 使用的那个,即 1.14.6。您可以使用以下方式安装它:

    pip install numpy==1.14.6
    

    您还可以检查您的 numpy 版本。运行一个python控制台/写一个程序,执行如下:

    import numpy
    numpy.__version__
    

    【讨论】:

      猜你喜欢
      • 2013-04-08
      • 1970-01-01
      • 1970-01-01
      • 2020-06-17
      • 2011-02-20
      • 1970-01-01
      • 1970-01-01
      • 2020-10-06
      • 2019-04-23
      相关资源
      最近更新 更多