本文整理匯總了Python中numpy.string0方法的典型用法代碼示例。如果您正苦於以下問題:Python numpy.string0方法的具體用法?Python numpy.string0怎麽用?Python numpy.string0使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類numpy
的用法示例。
在下文中一共展示了numpy.string0方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: breastcancer_cont
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import string0 [as 別名]
def breastcancer_cont(replication=2):
f = open(path + "breast_cancer_wisconsin_cont.txt", "r")
data = np.loadtxt(f, delimiter=",", dtype=np.string0)
x_train = np.array(data[:, range(0, 9)])
y_train = np.array(data[:, 9])
for j in range(replication - 1):
x_train = np.vstack([x_train, data[:, range(0, 9)]])
y_train = np.hstack([y_train, data[:, 9]])
x_train = np.array(x_train, dtype=np.float)
f = open(path + "breast_cancer_wisconsin_cont_test.txt")
data = np.loadtxt(f, delimiter=",", dtype=np.string0)
x_test = np.array(data[:, range(0, 9)])
y_test = np.array(data[:, 9])
for j in range(replication - 1):
x_test = np.vstack([x_test, data[:, range(0, 9)]])
y_test = np.hstack([y_test, data[:, 9]])
x_test = np.array(x_test, dtype=np.float)
return x_train, y_train, x_test, y_test
示例2: iris
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import string0 [as 別名]
def iris(replication=2):
f = open(path + "iris.txt")
data = np.loadtxt(f, delimiter=",", dtype=np.string0)
x_train = np.array(data[:, range(0, 4)], dtype=np.float)
y_train = data[:, 4]
for j in range(replication - 1):
x_train = np.vstack([x_train, data[:, range(0, 4)]])
y_train = np.hstack([y_train, data[:, 4]])
x_train = np.array(x_train, dtype=np.float)
f = open(path + "iris_test.txt")
data = np.loadtxt(f, delimiter=",", dtype=np.string0)
x_test = np.array(data[:, range(0, 4)], dtype=np.float)
y_test = data[:, 4]
for j in range(replication - 1):
x_test = np.vstack([x_test, data[:, range(0, 4)]])
y_test = np.hstack([y_test, data[:, 4]])
x_test = np.array(x_test, dtype=np.float)
return x_train, y_train, x_test, y_test