klyn.math.datasets.CaliforniaHousing.load
method
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>>
Description

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.

Parameters
ParameterDescription
<T>Float16, Float or Double storage for features and targets.
folderCache directory; null selects ~/datasets/california_housing.
testSplitFinite test fraction strictly between zero and one; default 0.2.
seedAny Long; deterministically normalized to a local generator state.
shuffleShuffle before splitting; false preserves source row order.
trainLimitLeading training rows; zero selects the whole split.
testLimitLeading test rows; zero selects the whole split.
downloadFetch missing cal_housing.data; false requires a local file.
Returns

(xTrain, yTrain, xTest, yTest), in that exact order.

Throws
  • IOException for missing files, download, integrity or I/O failures.
  • ValueException for invalid options, malformed data, empty splits, or data not representable as finite values in T.
Example

xTrain, yTrain, xTest, yTest = CaliforniaHousing.load<Double>(testSplit=0.25, seed=42l)