Sha256: da38a16a6683b336f6eb4da087e6a78065a42ae9e62fd9ce6942a01f52c0785d

Contents?: true

Size: 1.07 KB

Versions: 7

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

module Rumale
  # @!visibility private
  module Validation
    module_function

    # @!visibility private
    def check_convert_sample_array(x)
      x = Numo::DFloat.cast(x) unless x.is_a?(Numo::DFloat)
      raise ArgumentError, 'the sample array is expected to be 2-D array' unless x.ndim == 2

      x
    end

    # @!visibility private
    def check_convert_label_array(y)
      y = Numo::Int32.cast(y) unless y.is_a?(Numo::Int32)
      raise ArgumentError, 'the label array is expected to be 1-D arrray' unless y.ndim == 1

      y
    end

    # @!visibility private
    def check_convert_target_value_array(y)
      y = Numo::DFloat.cast(y) unless y.is_a?(Numo::DFloat)
      raise ArgumentError, 'the target value array is expected to be 1-D or 2-D arrray' unless y.ndim == 1 || y.ndim == 2

      y
    end

    # @!visibility private
    def check_sample_size(x, y)
      return if x.shape[0] == y.shape[0]

      raise ArgumentError, 'the sample array and label or target value array are expected to have the same number of samples'
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rumale-core-0.29.0 lib/rumale/validation.rb
rumale-core-0.28.1 lib/rumale/validation.rb
rumale-core-0.28.0 lib/rumale/validation.rb
rumale-core-0.27.0 lib/rumale/validation.rb
rumale-core-0.26.0 lib/rumale/validation.rb
rumale-core-0.25.0 lib/rumale/validation.rb
rumale-core-0.24.0 lib/rumale/validation.rb