コード例 #1
0
def main(readcsv=read_csv, method='svdDense'):
    infile = "./data/batch/qr.csv"

    # configure a QR object
    algo = d4p.qr()

    # let's provide a file directly, not a table/array
    result1 = algo.compute(infile)

    # We can also load the data ourselfs and provide the numpy array
    data = readcsv(infile)
    result2 = algo.compute(data)

    # QR result provide matrixQ and matrixR
    assert result1.matrixQ.shape == data.shape
    assert result1.matrixR.shape == (data.shape[1], data.shape[1])

    assert np.allclose(result1.matrixQ, result2.matrixQ, atol=1e-07)
    assert np.allclose(result1.matrixR, result2.matrixR, atol=1e-07)

    if hasattr(data, 'toarray'):
        data = data.toarray(
        )  # to make the next assertion work with scipy's csr_matrix
    assert np.allclose(data, np.matmul(result1.matrixQ, result1.matrixR))

    return data, result1
コード例 #2
0
ファイル: qr_batch.py プロジェクト: Laymer/daal4py
def main(readcsv=read_csv, method='svdDense'):
    infile = "./data/batch/qr.csv"

    # configure a QR object
    algo = d4p.qr()

    # let's provide a file directly, not a table/array
    result1 = algo.compute(infile)

    # We can also load the data ourselfs and provide the numpy array
    data = readcsv(infile)
    result2 = algo.compute(data)

    # QR result objects provide eigenvalues, eigenvectors, means and variances
    return result1
コード例 #3
0
ファイル: qr_streaming.py プロジェクト: samaid/daal4py
def main(readcsv=None, method='svdDense'):
    infile = "./data/batch/qr.csv"

    # configure a QR object
    algo = d4p.qr(streaming=True)

    # get the generator (defined in stream.py)...
    rn = read_next(infile, 112, readcsv)
    # ... and iterate through chunks/stream
    for chunk in rn:
        algo.compute(chunk)

    # finalize computation
    result = algo.finalize()

    # QR result objects provide matrixQ and matrixR
    return result
コード例 #4
0
def main():
    # Each process gets its own data
    infile = "./data/distributed/qr_{}.csv".format(d4p.my_procid() + 1)

    # configure a QR object
    algo = d4p.qr(distributed=True)

    # let's provide a file directly, not a table/array
    result1 = algo.compute(infile)

    # We can also load the data ourselfs and provide the numpy array
    data = loadtxt(infile, delimiter=',')
    result2 = algo.compute(data)

    # QR result provide matrixQ and matrixR
    assert result1.matrixQ.shape == data.shape
    assert result1.matrixR.shape == (data.shape[1], data.shape[1])

    assert allclose(result1.matrixQ, result2.matrixQ, atol=1e-07)
    assert allclose(result1.matrixR, result2.matrixR, atol=1e-07)

    return data, result1