All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.virtdata.libbasics.shared.distributions.CSVFrequencySamplerAutoDocsInfo Maven / Gradle / Ivy

There is a newer version: 2.12.15
Show newest version
// This file is auto-generated.
package io.virtdata.libbasics.shared.distributions;

import io.virtdata.annotations.Category;
import io.virtdata.annotations.Service;
import io.virtdata.processors.DocCtorData;
import io.virtdata.processors.DocForFuncCtor;
import io.virtdata.processors.DocFuncData;
import java.lang.String;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;

@Service(DocFuncData.class)
public class CSVFrequencySamplerAutoDocsInfo implements DocFuncData {
  public String getClassName() {
    return "CSVFrequencySampler";
  }

  public String getPackageName() {
    return "io.virtdata.libbasics.shared.distributions";
  }

  public String getClassJavadoc() {
    return "Takes a CSV with sample data and generates random values based on the\n"
            + "relative frequencies of the values in the file.\n"
            + "The CSV file must have headers which can\n"
            + "be used to find the named columns.\n"
            + "\n"
            + "I.E. take the following imaginary `animals.csv` file:\n"
            + "animal,count,country\n"
            + "puppy,1,usa\n"
            + "puppy,2,colombia\n"
            + "puppy,3,senegal\n"
            + "kitten,2,colombia\n"
            + "\n"
            + "`CSVFrequencySampler('animals.csv', animal)` will return `puppy` or `kitten` randomly. `puppy` will be 3x more frequent than `kitten`.\n"
            + "\n"
            + "`CSVFrequencySampler('animals.csv', country)` will return `usa`, `columbia`, or `senegal` randomly. `colombia` will be 2x more frequent than `usa` or `senegal`.\n"
            + "\n"
            + "Use this function to infer frequencies of categorical values from CSVs.\n";
  }

  public String getInType() {
    return "long";
  }

  public String getOutType() {
    return "java.lang.String";
  }

  public Category[] getCategories() {
    return new Category[] { Category.general };
  }

  public List getCtors() {
    return new ArrayList() {{
          add(new DocForFuncCtor("CSVFrequencySampler", "Create a sampler of strings from the given CSV file. The CSV file must have plain CSV headers\n"
              + "as its first line.\n"
              + "@param filename The name of the file to be read into the sampler buffer\n"
              + "@param columnName The name of the column to be sampled\n", 
            new LinkedHashMap() {{
              put("filename","java.lang.String");
              put("columnName","java.lang.String");
            }},
            new ArrayList>() {{
              add(new ArrayList() {{
                add("CSVFrequencySampler('values.csv','modelno')");
                add("Read values.csv, count the frequency of values in 'modelno' column, and sample from this column proportionally");
              }});
            }}
          ));
        }};
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy