如何修复 numpy.ndarray 的常见错误
How to fix this common error of numpy.ndarray
'''I am working upon a project of analyzing and predicting information about a cricket dataset.I came across a error of numpy.ndarrary object not callable.How should i fix this error'''
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)])
'''here on the first line itself i get an error of numpy.ndarrary object not callable.Please help me get this.'''
您名为 input 的变量隐藏了 Python 函数输入。
您可能正在使用不稳定版本的 numpy。我正在使用 google colab 使用的版本,即 1.14.6。您可以使用以下方式安装它:
pip install numpy==1.14.6
您还可以检查您的 numpy 版本。 运行 a python console/ 编写程序并执行以下内容:
import numpy
numpy.__version__
'''I am working upon a project of analyzing and predicting information about a cricket dataset.I came across a error of numpy.ndarrary object not callable.How should i fix this error'''
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)])
'''here on the first line itself i get an error of numpy.ndarrary object not callable.Please help me get this.'''
您名为 input 的变量隐藏了 Python 函数输入。
您可能正在使用不稳定版本的 numpy。我正在使用 google colab 使用的版本,即 1.14.6。您可以使用以下方式安装它:
pip install numpy==1.14.6
您还可以检查您的 numpy 版本。 运行 a python console/ 编写程序并执行以下内容:
import numpy
numpy.__version__