Codota Logo
StructuredProblem
Code IndexAdd Codota to your IDE (free)

How to use
StructuredProblem
in
edu.illinois.cs.cogcomp.indsup.learning

Best Java code snippets using edu.illinois.cs.cogcomp.indsup.learning.StructuredProblem (Showing top 18 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Dictionary d =
  • Codota Iconnew Hashtable()
  • Codota IconBundle bundle;bundle.getHeaders()
  • Codota Iconnew Properties()
  • Smart code suggestions by Codota
}
origin: edu.illinois.cs.cogcomp/JLIS-core

StructuredProblem train = new StructuredProblem();
StructuredProblem test = new StructuredProblem();
if (weight_list != null) {
  train.weight_list = new ArrayList<Double>();
for (int i = 0; i < size(); i++) {
  if (i < n_train) {
    train.input_list.add(input_list.get(i));
origin: edu.illinois.cs.cogcomp/JLIS-reranking

public static double getTOP1Score(StructuredProblem sp) throws Exception {
  double pred_loss = 0.0;
  for (int i = 0; i < sp.size(); i++) {
    RerankingInstance ri = (RerankingInstance) sp.input_list.get(i);            
    pred_loss += ri.score_list.get(0);
  }
  return pred_loss/sp.size();
}
origin: edu.illinois.cs.cogcomp/JLIS-multiclass

public LabeledMulticlassData(Map<String, Integer> m, Integer n_fea) {		
  label_mapping = m;
  n_base_feature_in_train = n_fea;
  sp = new StructuredProblem();
}    

origin: edu.illinois.cs.cogcomp/JLIS-reranking

.splitData(n_fold, new Random(0));
origin: edu.illinois.cs.cogcomp/JLIS-reranking

  public static double getPredictedScore(StructuredProblem sp,
      RerankerBestItemFinder s_finder, WeightVector wv) throws Exception {
    double pred_loss = 0.0;
    for (int i = 0; i < sp.size(); i++) {
      RerankingInstance ri = (RerankingInstance) sp.input_list.get(i);
      LabeledRerankingIns pred = (LabeledRerankingIns) s_finder
          .getBestStructure(wv, ri);
      pred_loss += ri.score_list.get(pred.pred_item);
    }
    return pred_loss/sp.size();
  }
}
origin: edu.illinois.cs.cogcomp/JLIS-reranking

public static StructuredProblem readFeatureFile(String fea_file_name)
    throws IOException {
  int index = 0;
  StructuredProblem sp = new StructuredProblem();
  ArrayList<String> fea_lines = LineIO.read(fea_file_name);
origin: edu.illinois.cs.cogcomp/JLIS-multiclass

public static double crossValidation(double C, int n_thread, int n_fold,
    LabeledMulticlassData train) throws Exception {
  double cv_res = 0;
  List<Pair<StructuredProblem, StructuredProblem>> data_pair_list = train.sp
      .splitData(n_fold, new Random(0));
  for (int i = 0; i < n_fold; i++) {
    StructuredProblem cv_sp_train = data_pair_list.get(i).getFirst();
    StructuredProblem cv_sp_test = data_pair_list.get(i).getSecond();
    LabeledMulticlassData cv_train = new LabeledMulticlassData(
        train.label_mapping, train.n_base_feature_in_train,
        cv_sp_train);
    LabeledMulticlassData cv_test = new LabeledMulticlassData(
        train.label_mapping, train.n_base_feature_in_train,
        cv_sp_test);
    MulticlassModel cv_model = trainMultiClassModel(C, n_thread,
        cv_train);
    Pair<int[], int[]> gold_pred = getPredictionResults(cv_model, cv_test);
    double test_acc = getTestingAcc(gold_pred.getFirst(), gold_pred.getSecond());
    cv_res += test_acc;
    System.out.println("Fold " + i + ":" + test_acc);
  }
  return cv_res / n_fold;
}
origin: edu.illinois.cs.cogcomp/JLIS-core

int bp_size = size();
for (int i = 0; i < bp_size; i++)
  index_list.add(i);
  StructuredProblem cv_train = new StructuredProblem();
  StructuredProblem cv_test = new StructuredProblem();
origin: edu.illinois.cs.cogcomp/JLIS-multiclass

public static Pair<int[],int[]> getPredictionResults(MulticlassModel model,
    LabeledMulticlassData test) throws Exception {
  int[] gold = new int[test.sp.size()];
  int[] pred = new int[test.sp.size()];
  for (int i = 0; i < test.sp.size(); i++) {
    LabeledMultiClassStructure prediction = (LabeledMultiClassStructure) model.s_finder
        .getBestStructure(model.wv, test.sp.input_list.get(i));
    gold[i] = ((LabeledMultiClassStructure) test.sp.output_list
        .get(i)).output;
    pred[i] = prediction.output;            
  }
  return new Pair<int[], int[]>(gold, pred);
  
}

origin: edu.illinois.cs.cogcomp/JLIS-multiclass

public static Pair<Double,Double> crossValidation(double C, int n_thread, int n_fold,
    LabeledMulticlassData train, double[][] cost_matrix) throws Exception {
  double cv_acc = 0;
  double cv_cost = 0;
  
  List<Pair<StructuredProblem, StructuredProblem>> data_pair_list = train.sp
      .splitData(n_fold, new Random(0));
  for (int i = 0; i < n_fold; i++) {
    StructuredProblem cv_sp_train = data_pair_list.get(i).getFirst();
    StructuredProblem cv_sp_test = data_pair_list.get(i).getSecond();
    LabeledMulticlassData cv_train = new LabeledMulticlassData(
        train.label_mapping, train.n_base_feature_in_train,
        cv_sp_train);
    LabeledMulticlassData cv_test = new LabeledMulticlassData(
        train.label_mapping, train.n_base_feature_in_train,
        cv_sp_test);
    MulticlassModel cv_model = trainCostSensitiveMultiClassModel(C, n_thread,
        cv_train,cost_matrix);
    Pair<int[], int[]> gold_pred = getPredictionResults(cv_model, cv_test);
    double test_acc = getTestingAcc(gold_pred.getFirst(), gold_pred.getSecond());
    cv_acc += test_acc;
    System.out.println("Fold " + i + " acc :" + test_acc);
          
    double test_cost = getTestingCost(gold_pred.getFirst(), gold_pred.getSecond(), cost_matrix);
    cv_cost += test_cost;
    System.out.println("Fold " + i + " cost :" + test_cost);
  }
  return new Pair<Double, Double>(cv_acc/n_fold, cv_cost/n_fold);
}
origin: edu.illinois.cs.cogcomp/JLIS-core

if (para.TRAINMINI && 5 * para.TRAINMINI_SIZE < sp.size()) {
  int t_size = para.TRAINMINI_SIZE;
  System.out.println("Train a mini sp to speed up! size = " + t_size);
  StructuredProblem minisp = new StructuredProblem();
  minisp.input_list = new ArrayList<IInstance>();
  minisp.output_list = new ArrayList<IStructure>();
  ArrayList<Integer> index_list = new ArrayList<Integer>();
  for (int i = 0; i < sp.size(); i++)
    index_list.add(i);
  Collections.shuffle(index_list, new Random(0));
origin: edu.illinois.cs.cogcomp/JLIS-core

/**
 * A helper function that shuffles the order of the examples in this
 * problem.
 * 
 * @param rnd
 *            A random number generator ---- if you use the same random
 *            generator (with the same seed), you will get the same
 *            ordering.
 */
public void shuffle(Random rnd) {
  int n_ex = size();
  for (int i = 0; i < n_ex; i++) {
    int j = i + rnd.nextInt(n_ex - i);
    IInstance tmp_ins = input_list.get(i);
    input_list.set(i, input_list.get(j));
    input_list.set(j, tmp_ins);
    IStructure tmp_st = output_list.get(i);
    output_list.set(i, output_list.get(j));
    output_list.set(j, tmp_st);
    if (weight_list != null) {
      Double tmp_weight = weight_list.get(i);
      weight_list.set(i, weight_list.get(j));
      weight_list.set(j, tmp_weight);
    }
  }
}
origin: edu.illinois.cs.cogcomp/JLIS-core

public WeightVector parallelTrainLatentStructuredSVMWithInitStructures_old(
    final AbstractLatentLossSensitiveStructureFinder[] struct_finder_list,
    final StructuredProblem sp, final JLISParameters para)
    throws Exception {
  WeightVector wv = new WeightVector(para.total_number_features + 1); // +1
  for (int i = 0; i < para.MAX_OUT_ITER; i++) {
    wv = multiThreadGetJointWeightVector(wv, struct_finder_list, sp,
        empty_b, para);
    for (int j = 0; j < sp.size(); j++) {
      IStructure newLatentStructureWithSameOutputStructure = struct_finder_list[0]
          .getBestLatentStructure(wv, sp.input_list.get(j),
              sp.output_list.get(j));
      sp.output_list
          .set(j, newLatentStructureWithSameOutputStructure);
    }
  }
  return wv;
}
origin: edu.illinois.cs.cogcomp/JLIS-core

for (int i = 0; i < sp.size(); i++) {
  alpha_ins_list[i] = new L2LossStructureInstanceWithAlphas(
      sp.input_list.get(i), sp.output_list.get(i),
for (int i = 0; i < sp.size(); i++) {
  alpha_ins_list[i] = new L2LossStructureInstanceWithAlphas(
      sp.input_list.get(i), sp.output_list.get(i),
origin: edu.illinois.cs.cogcomp/JLIS-reranking

for (int i = 0; i < sp.size(); i++) {
  RerankingInstance ri = (RerankingInstance) sp.input_list.get(i);
  LabeledRerankingIns pred = (LabeledRerankingIns) s_finder
origin: edu.illinois.cs.cogcomp/JLIS-core

protected WeightVector multiThreadGetJointWeightVector(WeightVector old_wv,
    final AbstractStructureFinder[] struct_finder_list,
    StructuredProblem sp, BinaryProblem bp, JLISParameters para)
    throws Exception {
  int struct_size = sp.size();
  int binary_size = bp.size();
  int total_size = struct_size + binary_size;
  System.out.println("Number of traing data: #struct: " + struct_size
      + " #binary: " + binary_size);
  WeightVector new_wv = new WeightVector(old_wv, 0); // allocate bias term
                            // for indirect
                            // supervision
  L2LossInstanceWithAlphas[] alpha_ins_list = initArrayOfInstances(sp,
      bp, para.c_struct, para.c_binary, struct_size, total_size);
  return multitreadTrainJLIS(struct_finder_list, para.MAX_OUT_ITER,
      struct_size, total_size, new_wv, alpha_ins_list, para)
      .getFirst();
}
origin: edu.illinois.cs.cogcomp/JLIS-core

  BinaryProblem bp, JLISParameters para) throws Exception {
L2LossInstanceWithAlphas.setJLISParameters(para);
int struct_size = sp.size();
int binary_size = bp.size();
origin: edu.illinois.cs.cogcomp/JLIS-core

int struct_size = sp.size();
int binary_size = empty_b.size();
int total_size = struct_size + binary_size;
edu.illinois.cs.cogcomp.indsup.learningStructuredProblem

Javadoc

This class represents a structured problem. A structured problem is a collection of the (input-structure) pairs.

Most used methods

  • <init>
  • size
  • splitData
    A helper function that helps you to perform cross validation. It splits the data in to n_fold Pairs,

Popular in Java

  • Finding current android device location
  • notifyDataSetChanged (ArrayAdapter)
  • getExternalFilesDir (Context)
  • getContentResolver (Context)
  • FileInputStream (java.io)
    A FileInputStream obtains input bytes from a file in a file system. What files are available depends
  • IOException (java.io)
    Signals that an I/O exception of some sort has occurred. This class is the general class of exceptio
  • Path (java.nio.file)
  • JList (javax.swing)
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • Project (org.apache.tools.ant)
    Central representation of an Ant project. This class defines an Ant project with all of its targets,
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now