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

com.expleague.ml.data.set.VecDataSet Maven / Gradle / Ivy

package com.expleague.ml.data.set;


import com.expleague.commons.math.vectors.Mx;
import com.expleague.commons.math.vectors.Vec;
import com.expleague.commons.util.ArrayTools;
import com.expleague.ml.Vectorization;
import com.expleague.ml.data.stats.OrderByFeature;
import com.expleague.ml.meta.FeatureMeta;

/**
 * User: solar
 * Date: 26.12.10
 * Time: 17:36
 */
public interface VecDataSet extends DataSet {
  Mx data();
  int xdim();
  int[] order(final int featureIndex);
  Vectorization vec();
  FeatureMeta fmeta(int findex);

  abstract class Stub extends DataSet.Stub implements VecDataSet {
    private final Vectorization vec;

    public Stub(final VecDataSet parent) {
      super(parent);
      vec = parent != null ? parent.vec() : null;
    }

    public Stub(final DataSet parent, final Vectorization vec) {
      super(parent);
      this.vec = vec;
    }

    @Override
    public final Vec at(final int i) {
      return data().row(i);
    }

    @Override
    public final int length() {
      return data().rows();
    }

    @Override
    public final int xdim() {
      return data().columns();
    }

    @Override
    public int[] order(final int featureIndex) {
      final int[] result = ArrayTools.sequence(0, length());
      ArrayTools.parallelSort(data().col(featureIndex).toArray(), result);
      return result;
    }

    @Override
    public Vectorization vec() {
      return vec;
    }

    @Override
    public final FeatureMeta fmeta(final int findex) {
      return vec().meta(findex);
    }

    @Override
    public Class elementType() {
      return Vec.class;
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy