TypeError: fit() got an unexpected keyword argument 'dtype'
请问这样报错应该如何解决?
dtype=int这个删掉运行试试
dtype是数组元素的类型,它是一个关键字,不能把它定义成一个普通变量。
属性dtype用于描述数组的元素类型
import numpy as np
arr = np.array([2, 5, 8, 4, 7, 2], dtype='int32')
print(arr, arr.dtype)
[2 5 8 4 7 2] int32
安装numpy最新版本或这检查python环境
其次,指定类型并创建数组,
a= np.array([2,4,5,6],dtype=np.float64)
print(a,a.dtype)