convert.from_numpy
¶
Convert vector-based ML datasets to tuple-based ILP datasets.
from_numpy(X, y, names=None)
¶
Convert numpy data (X
) and target (y
) arrays to a RelationalDataset
with modes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
np.ndarray
|
Integer matrix of covariates |
required |
y |
np.ndarray
|
Integer or float array containing the target variable |
required |
names |
Optional[List[str]]
|
List of strings representing the variable names |
None
|
Returns:
Type | Description |
---|---|
Tuple[RelationalDataset, List[str]]
|
Tuple of |
Raises:
Type | Description |
---|---|
TypeError
|
When classification vs. regression cannot be determined from the types of the input values. |
Examples:
Demonstrates converting a set of binary classification data.
from relational_datasets.convert import from_numpy
import numpy as np
data, modes = from_numpy(
np.array([[0, 1, 1], [0, 1, 2], [1, 2, 2]]),
np.array([0, 0, 1]),
)
Source code in relational_datasets/convert/convert_numpy.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
|
Last update:
June 20, 2022