INNER CODE UNIT · Ruby

dump_libsvm_file

yoshoku/rumale · rumale-core/lib/rumale/dataset.rb:43

      def dump_libsvm_file(data, labels, filename, zero_based: false)
        n_samples = [data.shape[0], labels.shape[0]].min
        single_label = labels.shape[1].nil?
        label_type = detect_dtype(labels)
        value_type = detect_dtype(data)
        File.open(filename, 'w') do |file|
          n_samples.times do |n|
            label = single_label ? labels[n] : labels[n, true].to_a
            file.puts(dump_libsvm_line(label, data[n, true],
                                       label_type, value_type, zero_based))
          end
        end
      end

      # Generate a two-dimensional data set consisting of an inner circle and an outer circle.
      #
      # @param n_samples [Integer] The number of samples.
      # @param shuffle [Boolean] The flag indicating whether to shuffle the dataset

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…