oss_src/unity/extensions/random_sframe_generation.cpp
gl_sframe _generate_random_classification_sframe(size_t n_rows, std::string column_types,
                                                 size_t random_seed, size_t num_classes,
                                                 size_t num_extra_class_bins,
                                                 double misclassification_spread) {

  // Set up the bin mapping. 
  size_t n_bins = num_classes + num_extra_class_bins;
  std::vector<size_t> bin_to_class_map(n_bins);

  gl_sframe X = _generate_random_sframe(n_rows, column_types, random_seed, true,
                                        misclassification_spread / n_bins);
  
  random::seed(random_seed);
  
  for(size_t i = 0; i < num_classes; ++i) {
    bin_to_class_map[i] = i;
  }
  
  for(size_t i = num_classes; i < n_bins; ++i) {
    bin_to_class_map[i] = random::fast_uniform<size_t>(0, num_classes - 1);
  }

  random::shuffle(bin_to_class_map);
  
  std::function<flexible_type(const flexible_type&)> classify
      = [=](const flexible_type& x) {
    size_t b = std::min<flex_int>(n_bins - 1,
        std::max<flex_int>(0,
            flex_int(std::floor(x.get<flex_float>() * n_bins))));
    
    return bin_to_class_map[b];
  };
      
  X["target"] = X["target"].apply(classify, flex_type_enum::INTEGER, false); 

  return X;
}
/**  Creates a random SFrame for testing purposes, with num_rows,
 *   column_types, and random_seed the same as _generate_random_sframe
 *   above.  In addition, an integer categorical target column is
 *   added by binning the output of the numerical target column given
 *   in _generate_random_sframe.
 *
 *   The target column, called "target", is an integer value that
 *   represents the binning of the output of a noisy linear function
 *   of the chosen random variables into `num_bins_scale_factor *
 *   num_classes` bins, shuffled, and then each bin is mapped to
 *   num_classes values.  This means that some non-linearity is
 *   present if num_bins_scale_factor > 1, but many patterns can be
 *   learned. For details on how the random linear value is chosen,
 *   see the documentation on
 *   :ref:`generate_random_regression_sframe`.
 *
 *   The noise_level is handled identically to
 *   _generate_random_sframe, except that noise_level is divided by
 *   the number of bins.  Thus it here represents the probability that
 *   a class will be mapped to the wrong neighboring bin.
 */
Creates a random SFrame for testing purposes, with num_rows,
column_types, and random_seed the same as _generate_random_sframe
above.  In addition, an integer categorical target column is
added by binning the output of the numerical target column given
in _generate_random_sframe.

The target column, called "target", is an integer value that
represents the binning of the output of a noisy linear function
of the chosen random variables into `num_bins_scale_factor
num_classes` bins, shuffled, and then each bin is mapped to
num_classes values.  This means that some non-linearity is
present if num_bins_scale_factor > 1, but many patterns can be
learned. For details on how the random linear value is chosen,
see the documentation on
:ref:`generate_random_regression_sframe`.

The noise_level is handled identically to
_generate_random_sframe, except that noise_level is divided by
the number of bins.  Thus it here represents the probability that
a class will be mapped to the wrong neighboring bin.
Creates a random SFrame for testing purposes with num_rows column_types and random_seed the same as _generate_random_sframe above . In addition an integer categorical target column is added by binning the output of the numerical target column given in _generate_random_sframe . The target column called " target " is an integer value that represents the binning of the output of a noisy linear function of the chosen random variables into ` num_bins_scale_factor num_classes ` bins shuffled and then each bin is mapped to num_classes values . This means that some non - linearity is present if num_bins_scale_factor > 1 but many patterns can be learned . For details on how the random linear value is chosen see the documentation on : ref : ` generate_random_regression_sframe ` . The noise_level is handled identically to _generate_random_sframe except that noise_level is divided by the number of bins . Thus it here represents the probability that a class will be mapped to the wrong neighboring bin .
gl_sframe _generate_random_classification_sframe(size_t n_rows, std::string column_types,
                                                 size_t random_seed, size_t num_classes,
                                                 size_t num_extra_class_bins,
                                                 double misclassification_spread) {
  size_t n_bins = num_classes + num_extra_class_bins;
  std::vector<size_t> bin_to_class_map(n_bins);
  gl_sframe X = _generate_random_sframe(n_rows, column_types, random_seed, true,
                                        misclassification_spread / n_bins);
  random::seed(random_seed);
  for(size_t i = 0; i < num_classes; ++i) {
    bin_to_class_map[i] = i;
  }
  for(size_t i = num_classes; i < n_bins; ++i) {
    bin_to_class_map[i] = random::fast_uniform<size_t>(0, num_classes - 1);
  }
  random::shuffle(bin_to_class_map);
  std::function<flexible_type(const flexible_type&)> classify
      = [=](const flexible_type& x) {
    size_t b = std::min<flex_int>(n_bins - 1,
        std::max<flex_int>(0,
            flex_int(std::floor(x.get<flex_float>() * n_bins))));
    return bin_to_class_map[b];
  };
  X["target"] = X["target"].apply(classify, flex_type_enum::INTEGER, false); 
  return X;
}
gl_sframe _generate_random_classification_sframe ( size_t n_rows , std :: string column_types , size_t random_seed , size_t num_classes , size_t num_extra_class_bins , double misclassification_spread ) { size_t n_bins = num_classes + num_extra_class_bins ; std :: vector < size_t > bin_to_class_map ( n_bins ) ; gl_sframe X = _generate_random_sframe ( n_rows , column_types , random_seed , true , misclassification_spread / n_bins ) ; random :: seed ( random_seed ) ; for ( size_t i = 0 ; i < num_classes ; ++ i ) { bin_to_class_map [ i ] = i ; } for ( size_t i = num_classes ; i < n_bins ; ++ i ) { bin_to_class_map [ i ] = random :: fast_uniform < size_t > ( 0 , num_classes - 1 ) ; } random :: shuffle ( bin_to_class_map ) ; std :: function < flexible_type ( const flexible_type & ) > classify = [ = ] ( const flexible_type & x ) { size_t b = std :: min < flex_int > ( n_bins - 1 , std :: max < flex_int > ( 0 , flex_int ( std :: floor ( x . get < flex_float > ( ) * n_bins ) ) ) ) ; return bin_to_class_map [ b ] ; } ; X [ " " ] = X [ " " ] . apply ( classify , flex_type_enum :: INTEGER , false ) ; return X ; }
Creates a random SFrame for testing purposes, with num_rows,
   column_types, and random_seed the same as _generate_random_sframe
   above.
Creates a random SFrame for testing purposes with num_rows column_types and random_seed the same as _generate_random_sframe above .
// Set up the bin mapping. 