public static load<T extends AbstractFloat = Float>(folder as Path = null, testSplit as Double = 0.2, seed as Long = 42l, shuffle as Boolean = true, trainLimit as Long = 0l, testLimit as Long = 0l, download as Boolean = true) as Tuple<NDArray<T>, NDArray<T>, NDArray<T>, NDArray<T>>
Loads four independent tensors, downloading and checking missing data. Features have shape [samples, 8] and targets [samples]. Both use T, Float by default; targets are real values, not integer class indices. Original room/bedroom counts and population are divided by households to produce AveRooms, AveBedrms and AveOccup. No train/test statistics are fitted and no standardization is performed by this loader.
A seeded Fisher-Yates permutation defines disjoint splits. The first N - ceil(N * testSplit) permuted rows train; the rest test. Limits select prefixes of these splits, without changing membership or their order. The seed is local and does not change application-wide randomness. This split is reproducible in Klyn, not identical to other libraries' RNGs.
The source is read with bounded buffers and written directly into the four outputs, never into an additional full-size unpartitioned tensor. A first byte scan counts records so custom local subsets can be used. Downloads use curl over verified HTTPS with interactive progress, as MNIST does. The published archive is checked using SHA-256 before Klyn decompresses it. Completed local data is reused without network access.
| Parameter | Description |
|---|---|
<T> | Float16, Float or Double storage for features and targets. |
folder | Cache directory; null selects ~/datasets/california_housing. |
testSplit | Finite test fraction strictly between zero and one; default 0.2. |
seed | Any Long; deterministically normalized to a local generator state. |
shuffle | Shuffle before splitting; false preserves source row order. |
trainLimit | Leading training rows; zero selects the whole split. |
testLimit | Leading test rows; zero selects the whole split. |
download | Fetch missing cal_housing.data; false requires a local file. |
(xTrain, yTrain, xTest, yTest), in that exact order.
xTrain, yTrain, xTest, yTest = CaliforniaHousing.load<Double>(testSplit=0.25, seed=42l)