<commit_before>package edu.neu.ccs.pyramid.multilabel_classification.thresholding;

import edu.neu.ccs.pyramid.dataset.DataSetUtil;
import edu.neu.ccs.pyramid.dataset.MultiLabelClfDataSet;
import edu.neu.ccs.pyramid.multilabel_classification.MultiLabelClassifier;

/**
 * Created by chengli on 5/12/16.
 */
public class MacroFMeasureTuner {

    public static double[] tuneThresholds(MultiLabelClassifier.ClassProbEstimator multiLabelClassifier, MultiLabelClfDataSet dataSet, double beta){
        double[] thresholds = new double[multiLabelClassifier.getNumClasses()];
        for (int k=0;k<multiLabelClassifier.getNumClasses();k++){
            thresholds[k] = tuneThreshold(multiLabelClassifier,dataSet,k,beta);
        }
        return thresholds;<commit_msg>parallelize macro F tuning<commit_after>package edu.neu.ccs.pyramid.multilabel_classification.thresholding;

import edu.neu.ccs.pyramid.dataset.DataSetUtil;
import edu.neu.ccs.pyramid.dataset.MultiLabelClfDataSet;
import edu.neu.ccs.pyramid.multilabel_classification.MultiLabelClassifier;

import java.util.stream.IntStream;

/**
 * Created by chengli on 5/12/16.
 */
public class MacroFMeasureTuner {

    public static double[] tuneThresholds(MultiLabelClassifier.ClassProbEstimator multiLabelClassifier, MultiLabelClfDataSet dataSet, double beta){
        double[] thresholds = new double[multiLabelClassifier.getNumClasses()];
        IntStream.range(0, multiLabelClassifier.getNumClasses()).parallel()
                .forEach(k->thresholds[k] = tuneThreshold(multiLabelClassifier,dataSet,k,beta));
        return thresholds;
{'fraction_non_alphanumeric': 0.10037641154328733, 'fraction_numerical': 0.0075282308657465494, 'mean_word_length': 5.2795275590551185, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7326100', 'n_tokens_mistral': 523, 'n_tokens_neox': 497, 'n_words': 75}