Python numpy.string0() Examples

The following are 2 code examples of numpy.string0(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module numpy , or try the search function .
Example #1
Source File: datasets.py    From discomll with Apache License 2.0 6 votes vote down vote up
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 
Example #2
Source File: datasets.py    From discomll with Apache License 2.0 6 votes vote down vote up
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