Sha256: 442a2cc08e632ce8491e4daeb3b4e5d7a44d1d83d662869f07235046c7a7eba7

Contents?: true

Size: 958 Bytes

Versions: 2

Compression:

Stored size: 958 Bytes

Contents

module TensorFlow
  module Keras
    module Datasets
      module BostonHousing
        def self.load_data(path: "boston_housing.npz", test_split: 0.2, seed: 113)
          file = Utils.get_file(
            path,
            "https://storage.googleapis.com/tensorflow/tf-keras-datasets/boston_housing.npz",
            file_hash: "f553886a1f8d56431e820c5b82552d9d95cfcb96d1e678153f8839538947dff5"
          )

          data = Npy.load_npz(file)

          x = data["x"]
          y = data["y"]

          len = x.shape[0]
          indices = (0...len).to_a.shuffle(random: Random.new(seed))
          x = x[indices, true]
          y = y[indices]

          x_train = x[0...(len * (1 - test_split)), true]
          y_train = y[0...(len * (1 - test_split))]
          x_test = x[(len * (1 - test_split))..-1, true]
          y_test = y[(len * (1 - test_split))..-1]

          [[x_train, y_train], [x_test, y_test]]
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tensorflow-0.2.0 lib/tensorflow/keras/datasets/boston_housing.rb
tensorflow-0.1.2 lib/tensorflow/keras/datasets/boston_housing.rb