private PagesIndex( OrderingCompiler orderingCompiler, JoinCompiler joinCompiler, FunctionRegistry functionRegistry, boolean groupByUsesEqualTo, List<Type> types, int expectedPositions, boolean eagerCompact) { this.orderingCompiler = requireNonNull(orderingCompiler, "orderingCompiler is null"); this.joinCompiler = requireNonNull(joinCompiler, "joinCompiler is null"); this.functionRegistry = requireNonNull(functionRegistry, "functionRegistry is null"); this.groupByUsesEqualTo = groupByUsesEqualTo; this.types = ImmutableList.copyOf(requireNonNull(types, "types is null")); this.valueAddresses = new LongArrayList(expectedPositions); this.eagerCompact = eagerCompact; //noinspection rawtypes channels = (ObjectArrayList<Block>[]) new ObjectArrayList[types.size()]; for (int i = 0; i < channels.length; i++) { channels[i] = ObjectArrayList.wrap(new Block[1024], 0); } estimatedSize = calculateEstimatedSize(); }
@Override public ObjectList<String> metricNames() { return ObjectArrayList.wrap(new String[]{"indelAccuracy", "#indelCorrect", "#indelPredicted", "#indelTrue", "tp", "fp", "fn","indelF1"}); }
@Override public ObjectList<String> metricNames() { return ObjectArrayList.wrap(new String[]{"accuracy","correct","n"}); }
/** * Wraps a given array into an array list. * * <p> * Note it is guaranteed that the type of the array returned by * {@link #elements()} will be the same (see the comments in the class * documentation). * * @param a * an array to wrap. * @return a new array list wrapping the given array. */ public static <K> ObjectArrayList<K> wrap(final K a[]) { return wrap(a, a.length); } /**
public PagesIndex(List<Type> types, int expectedPositions) { this.types = ImmutableList.copyOf(requireNonNull(types, "types is null")); this.valueAddresses = new LongArrayList(expectedPositions); //noinspection rawtypes channels = (ObjectArrayList<Block>[]) new ObjectArrayList[types.size()]; for (int i = 0; i < channels.length; i++) { channels[i] = ObjectArrayList.wrap(new Block[1024], 0); } }
private int[] assignSelectedIndices(String[] inputNames, Set<String> inputNamesToExport) { if (inputNamesToExport == null) { inputNamesToExport = new ObjectArraySet<>(); inputNamesToExport.addAll(ObjectArrayList.wrap(inputNames)); } int[] inputIndicesSelected = new int[inputNames.length]; if (!inputNamesToExport.isEmpty()) { // the none keyword makes it possible to export no inputs. inputNamesToExport.remove("none"); inputIndicesSelected = new int[inputNamesToExport.size()]; Arrays.fill(inputIndicesSelected, -1); int i = 0; for (int j = 0; j < inputNames.length; j++) { if (inputNamesToExport.contains(inputNames[j])) { inputIndicesSelected[i++] = j; } } for (int index : inputIndicesSelected) { if (index == -1) { System.err.printf("An argument to --export-inputs/outputs does not match actual inputs/outputs."); System.exit(1); } } } return inputIndicesSelected; }
private PagesIndex( OrderingCompiler orderingCompiler, JoinCompiler joinCompiler, FunctionRegistry functionRegistry, boolean groupByUsesEqualTo, List<Type> types, int expectedPositions, boolean eagerCompact) { this.orderingCompiler = requireNonNull(orderingCompiler, "orderingCompiler is null"); this.joinCompiler = requireNonNull(joinCompiler, "joinCompiler is null"); this.functionRegistry = requireNonNull(functionRegistry, "functionRegistry is null"); this.groupByUsesEqualTo = groupByUsesEqualTo; this.types = ImmutableList.copyOf(requireNonNull(types, "types is null")); this.valueAddresses = new LongArrayList(expectedPositions); this.eagerCompact = eagerCompact; //noinspection rawtypes channels = (ObjectArrayList<Block>[]) new ObjectArrayList[types.size()]; for (int i = 0; i < channels.length; i++) { channels[i] = ObjectArrayList.wrap(new Block[1024], 0); } estimatedSize = calculateEstimatedSize(); }
private PagesIndex( OrderingCompiler orderingCompiler, JoinCompiler joinCompiler, FunctionRegistry functionRegistry, boolean groupByUsesEqualTo, List<Type> types, int expectedPositions, boolean eagerCompact) { this.orderingCompiler = requireNonNull(orderingCompiler, "orderingCompiler is null"); this.joinCompiler = requireNonNull(joinCompiler, "joinCompiler is null"); this.functionRegistry = requireNonNull(functionRegistry, "functionRegistry is null"); this.groupByUsesEqualTo = groupByUsesEqualTo; this.types = ImmutableList.copyOf(requireNonNull(types, "types is null")); this.valueAddresses = new LongArrayList(expectedPositions); this.eagerCompact = eagerCompact; //noinspection rawtypes channels = (ObjectArrayList<Block>[]) new ObjectArrayList[types.size()]; for (int i = 0; i < channels.length; i++) { channels[i] = ObjectArrayList.wrap(new Block[1024], 0); } estimatedSize = calculateEstimatedSize(); }
@Override protected Class<?>[] getSignatureTypes(final Method method) { Class<?>[] signatureTypes = super.getSignatureTypes(method); if (this.needsInstance(method)) { final ObjectArrayList<Class<?>> paramList = ObjectArrayList.wrap(signatureTypes); paramList.ensureCapacity(paramList.size() + 1); paramList.add(0, method.getDeclaringClass()); signatureTypes = paramList.elements(); } return signatureTypes; }
/** Creates a new replicated document factory. * * @param documentFactory the factory that will be replicated. * @param numberOfCopies the number of copies. * @param fieldName the names to be given to the fields of the new factory. */ private ReplicatedDocumentFactory( final DocumentFactory documentFactory, final int numberOfCopies, final String[] fieldName ) { this.documentFactory = documentFactory; this.numberOfCopies = numberOfCopies; this.fieldName = fieldName; if ( numberOfFields() != fieldName.length ) throw new IllegalArgumentException( "The number of field names (" + fieldName.length + ") is not equal to the number of fields in the replicated factory (" + numberOfFields() + ")" ); field2Index = new Object2IntOpenHashMap<String>( fieldName.length, .5f ); field2Index.defaultReturnValue( -1 ); for( int i = 0; i < fieldName.length; i++ ) field2Index.put( fieldName[ i ], i ); if ( field2Index.size() != fieldName.length ) throw new IllegalArgumentException( "The field name array " + ObjectArrayList.wrap( fieldName ) + " contains duplicates" ); }
/** Creates a new replicated document factory. * * @param documentFactory the factory that will be replicated. * @param numberOfCopies the number of copies. * @param fieldName the names to be given to the fields of the new factory. */ private ReplicatedDocumentFactory( final DocumentFactory documentFactory, final int numberOfCopies, final String[] fieldName ) { this.documentFactory = documentFactory; this.numberOfCopies = numberOfCopies; this.fieldName = fieldName; if ( numberOfFields() != fieldName.length ) throw new IllegalArgumentException( "The number of field names (" + fieldName.length + ") is not equal to the number of fields in the replicated factory (" + numberOfFields() + ")" ); field2Index = new Object2IntOpenHashMap<String>( fieldName.length, .5f ); field2Index.defaultReturnValue( -1 ); for( int i = 0; i < fieldName.length; i++ ) field2Index.put( fieldName[ i ], i ); if ( field2Index.size() != fieldName.length ) throw new IllegalArgumentException( "The field name array " + ObjectArrayList.wrap( fieldName ) + " contains duplicates" ); }
/** Creates a new replicated document factory. * * @param documentFactory the factory that will be replicated. * @param numberOfCopies the number of copies. * @param fieldName the names to be given to the fields of the new factory. */ private ReplicatedDocumentFactory( final DocumentFactory documentFactory, final int numberOfCopies, final String[] fieldName ) { this.documentFactory = documentFactory; this.numberOfCopies = numberOfCopies; this.fieldName = fieldName; if ( numberOfFields() != fieldName.length ) throw new IllegalArgumentException( "The number of field names (" + fieldName.length + ") is not equal to the number of fields in the replicated factory (" + numberOfFields() + ")" ); field2Index = new Object2IntOpenHashMap<String>( fieldName.length, .5f ); field2Index.defaultReturnValue( -1 ); for( int i = 0; i < fieldName.length; i++ ) field2Index.put( fieldName[ i ], i ); if ( field2Index.size() != fieldName.length ) throw new IllegalArgumentException( "The field name array " + ObjectArrayList.wrap( fieldName ) + " contains duplicates" ); }
/** Creates a new replicated document factory. * * @param documentFactory the factory that will be replicated. * @param numberOfCopies the number of copies. * @param fieldName the names to be given to the fields of the new factory. */ private ReplicatedDocumentFactory( final DocumentFactory documentFactory, final int numberOfCopies, final String[] fieldName ) { this.documentFactory = documentFactory; this.numberOfCopies = numberOfCopies; this.fieldName = fieldName; if ( numberOfFields() != fieldName.length ) throw new IllegalArgumentException( "The number of field names (" + fieldName.length + ") is not equal to the number of fields in the replicated factory (" + numberOfFields() + ")" ); field2Index = new Object2IntOpenHashMap<String>( fieldName.length, .5f ); field2Index.defaultReturnValue( -1 ); for( int i = 0; i < fieldName.length; i++ ) field2Index.put( fieldName[ i ], i ); if ( field2Index.size() != fieldName.length ) throw new IllegalArgumentException( "The field name array " + ObjectArrayList.wrap( fieldName ) + " contains duplicates" ); }
@Override protected ReturnType invokeDirectly(final Method method, final Object context, final Object[] params) throws IllegalAccessException, InvocationTargetException { if (this.needsInstance(method) && context == null) return super.invokeDirectly(method, params[0], ObjectArrayList.wrap(params).subList(1, params.length) .toArray()); return super.invokeDirectly(method, context, params); } }
field2Index.defaultReturnValue( -1 ); for( int i = 0; i < this.fieldName.length; i++ ) field2Index.put( this.fieldName[ i ], i ); if ( field2Index.size() != this.fieldName.length ) throw new IllegalArgumentException( "The field name array " + ObjectArrayList.wrap( fieldName ) + " contains duplicates" );
field2Index.defaultReturnValue( -1 ); for( int i = 0; i < this.fieldName.length; i++ ) field2Index.put( this.fieldName[ i ], i ); if ( field2Index.size() != this.fieldName.length ) throw new IllegalArgumentException( "The field name array " + ObjectArrayList.wrap( fieldName ) + " contains duplicates" );
@Override protected String[] createOutputHeader() { initializeStats(""); ObjectArrayList<String> values = new ObjectArrayList<>(); values.addAll(it.unimi.dsi.fastutil.objects.ObjectArrayList.wrap(orderStats)); values.add("AUC"); values.add("[AUC95"); values.add("AUC95]"); return values.toArray(new String[0]); }
private DataSet enrichWithErrors(DataSet ds) { if (!args().errorEnrichment) { return ds; } if (queue.isEmpty()) { // no errors were collected yet. Return the un-enriched dataset. return ds; } int size = this.args().numErrorsAdded; INDArray inputs = Nd4j.zeros(size, featureCalculator.numberOfFeatures()); INDArray labels = Nd4j.zeros(size, labelMapper.numberOfLabels()); int i = 0; for (ErrorRecord errorRecord : queue.getRandomSample(size)) { // we are going to call nextRecord directly, without checking hasNextRecord, because we have // determined how many times we can call (in size). We should get the exception if we were // wrong in our estimate of size. // fill in features and labels for a given record i: Nd4j.copy(errorRecord.features.get(new PointIndex(0)), inputs.get(new PointIndex(i))); Nd4j.copy(errorRecord.label, labels.get(new PointIndex(i))); i++; } DataSet errorDataSet = new DataSet(inputs, labels); array[0] = ds; array[1] = errorDataSet; final DataSet enrichedDataset = DataSet.merge(ObjectArrayList.wrap(array)); return enrichedDataset; }