np2ds

Convert a NumPy array into a URANIE DataServer object.

converter.np2ds(mat, attrib_names, name="", title="")

Parameters:

Parameter

Type

Description

mat

numpy.ndarray

Input array with shape (n_samples, n_attributes). 1-D arrays are automatically reshaped to (1, n_features).

attrib_names

str

Colon-separated attribute names, e.g., "x1:x2:x3". Length must match mat.shape[1].

name

str

Name for the DataServer object (optional, default: "").

title

str

Title for the DataServer object (optional, default: "").

Returns:

Type

Description

DataServer.TDataServer

A DataServer object with attributes populated from the array columns.

Example

import numpy as np
from uratools import converter

# Create data
X = np.random.randn(100, 3)

# Convert to DataServer
tds = converter.np2ds(X, "x1:x2:x3", name="samples", title="Random samples")

print(f"Patterns: {tds.getNPatterns()}")   # 100
print(f"Attributes: {tds.getNAttributes()}")  # 3

Use Cases

  • Prepare NumPy data for URANIE sampling workflows

  • Convert preprocessed data into URANIE format

  • Create DataServer objects from external data sources (CSV, HDF5, etc.)