lib/rumale/dataset.rb
# Load a dataset with the libsvm file format into Numo::NArray.
#
# @param filename [String] A path to a dataset file.
# @param n_features [Integer/Nil] The number of features of data to load.
#   If nil is given, it will be detected automatically from given file.
# @param zero_based [Boolean] Whether the column index starts from 0 (true) or 1 (false).
# @param dtype [Numo::NArray] Data type of Numo::NArray for features to be loaded.
#
# @return [Array<Numo::NArray>]
#   Returns array containing the (n_samples x n_features) matrix for feature vectors
#   and (n_samples) vector for labels or target values.
Load a dataset with the libsvm file format into Numo::NArray.
Load a dataset with the libsvm file format into Numo :: NArray .
def dump_libsvm_line(label, ftvec, label_type, value_type, zero_based)
        line = dump_label(label, label_type.to_s)
        ftvec.to_a.each_with_index do |val, n|
          idx = n + (zero_based == false ? 1 : 0)
          line += format(" %d:#{value_type}", idx, val) if val != 0
        end
        line
      end
def dump_libsvm_line ( label , ftvec , label_type , value_type , zero_based ) line = dump_label ( label , label_type . to_s ) ftvec . to_a . each_with_index do | val , n | idx = n + ( zero_based == false ? 1 : 0 ) line += format ( " %d:#{value_type}" , idx , val ) if val != 0 end line end
Load a dataset with the libsvm file format into Numo::NArray.
Load a dataset with the libsvm file format into Numo :: NArray .
Returns array containing the (n_samples x n_features) matrix for feature vectors and (n_samples) vector for labels or target values.
Returns array containing the ( n_samples x n_features ) matrix for feature vectors and ( n_samples ) vector for labels or target values .
Array<Numo::NArray>
label
<not_specific>
ftvec
<not_specific>
label_type
<not_specific>
value_type
<not_specific>
zero_based
Whether the column index starts from 0 (true) or 1 (false).
Whether the column index starts from 0 ( true ) or 1 ( false ) .
filename
<not_specific>
A path to a dataset file.
A path to a dataset file .
n_features
<not_specific>
The number of features of data to load. If nil is given, it will be detected automatically from given file.
The number of features of data to load . If nil is given it will be detected automatically from given file .
dtype
<not_specific>
Data type of Numo::NArray for features to be loaded.
Data type of Numo :: NArray for features to be loaded .