Пример #1
0
 public AggregateFreq(FNode M, Predicate F, Predicate G)
     : base(CellAffinity.DOUBLE, F)
 {
     this._M = M;
     this._G = G;
     this._Sig = 2;
 }
Пример #2
0
        public static Tuple<long,long> Delete(Table Data, Predicate Where)
        {

            long CurrentCount = 0;
            long NewCount = 0;

            foreach (RecordSet rs in Data.Extents)
            {

                // Append the current record count //
                CurrentCount += (long)rs.Count;

                // Delete //
                NewCount += Delete(rs, Where);

                // Push //
                Data.Push(rs);

            }

            BinarySerializer.Flush(Data);

            // Return the delta //
            return new Tuple<long,long>(CurrentCount, NewCount);

        }
Пример #3
0
        public static long Delete(RecordSet Extent, Predicate Where)
        {

            long n = 0;
            RecordSet rs = new RecordSet(Extent.Columns);
            RecordWriter w = rs.OpenWriter();
            FastReadPlan plan = new FastReadPlan(Extent, Where.NOT, new FNodeSet(Extent.Columns), w);
            plan.Execute();
            w.Close();
            n = Extent.Count - rs.Count;
            Extent._Cache = rs._Cache;
            return n;

            //long n = 0;
            //StaticRegister mem = new StaticRegister(null);
            //Where.AssignRegister(mem);
            //for (int i = Extent.Count - 1; i >= 0; i--)
            //{
            //    mem.Assign(Extent[i]);
            //    if (Where.Render())
            //    {
            //        Extent.Remove(i);
            //        n++;
            //    }

            //}
            //return n;

        }
Пример #4
0
 public AggregateMin(FNode M, Predicate F)
     : base(M.ReturnAffinity())
 {
     this._Map = M;
     this._F = F;
     this._Sig = 1;
 }
Пример #5
0
 public TableWriter(Table Data, Predicate Having)
     : base(Data.PopLastOrGrow(), Having)
 {
     this._ParentData = Data;
     this._ptrData = 0;
     this._columns = Data.Columns;
 }
Пример #6
0
 public AggregateCount(FNode M, Predicate F)
     : base(CellAffinity.INT)
 {
     this._Map = M;
     this._F = F;
     this._Sig = 1;
 }
Пример #7
0
 public AggregateStat(FNode X, FNode W, Predicate F)
     : base(X.ReturnAffinity())
 {
     this._MapX = X;
     this._MapW = W;
     this._F = F;
     this._Sig = 3;
 }
Пример #8
0
        public DeletePlan(DataSet Data, Predicate Where)
            : base()
        {

            this._data = Data;
            this._where = Where;
            this.Name = "DELETE";

        }
Пример #9
0
        public UpdatePlan(DataSet Data, Key K, FNodeSet Fields, Predicate BaseDataFilter)
            : base()
        {

            this._data = Data;
            this._keys = K;
            this._values = Fields;
            this._where = BaseDataFilter;
            this.Name = "UPDATE";

        }
Пример #10
0
 // Constructors //
 public NeuralNetworkFactory(string Name, DataSet Data, Predicate Where)
 {
     this._HiddenLayers = new List<NN_Layer>();
     this._Links = new NodeLinkMaster();
     this.DefaultRule = "irprop+";
     this.DefaultActivator = ScalarFunctionFactory.Select("BinarySigmoid");
     this.DefaultReduction = new NodeReductionLinear();
     this._SourceData = Data;
     this._Where = Where;
     this._name = Name;
 }
Пример #11
0
        // RecordSet SELECTS //
        public static RecordSet SELECT(DataSet Data, FNodeSet Nodes, Predicate Where)
        {

            RecordSet rs = new RecordSet(Nodes.Columns);
            RecordWriter w = rs.OpenWriter();
            FastReadPlan plan = new FastReadPlan(Data, Where, Nodes, w);
            plan.Execute();
            w.Close();
            return rs;

        }
Пример #12
0
        // Table SELECTS //
        public static Table SELECT(string Dir, string Name, DataSet Data, FNodeSet Nodes, Predicate Where)
        {

            Table rs = new Table(Dir, Name, Nodes.Columns);
            RecordWriter w = rs.OpenWriter();
            FastReadPlan plan = new FastReadPlan(Data, Where, Nodes, w);
            plan.Execute();
            w.Close();
            return rs;

        }
Пример #13
0
 public RowCluster(string Name, DataSet Data, Predicate Where, FNodeSet Fields, FNode Weight, int Count)
 {
     this._data = Data;
     this._where = Where;
     this._fields = Fields;
     this._count = Count;
     this._rule = new RowClusterRuleEuclid();
     this._initializer = new RowClusterInitializerSpectrum();
     this._means = this._initializer.Initialize(Data, Where, Fields, Count);
     this._weight = Weight;
     this.Name = Name;
 }
Пример #14
0
        public GeneralizedLinearModel(string Name, DataSet Data, Predicate Where, FNode Expected, FNodeSet Actual, FNode Weight, Lambda LinkFunction)
            : base(Name, Data, Where, Expected, Actual, Weight)
        {

            int val = IsCorrectLink(LinkFunction);
            if (val == -1)
                throw new Exception("Link function must have exactly one argument");
            else if (val == -2)
                throw new Exception("Link function is not differentiable");
            this._Link = LinkFunction;
 
        }
Пример #15
0
        // Constructor //
        public TableReader(Table From, Predicate Where)
            : base(From.PopFirstOrGrow())
        {
            
            this._ptrData = DEFAULT_POINTER;
            this._ParentData = From;
            this._columns = From.Columns;
            this._Where = Where;
            this._Where.AssignRegister(new StreamRegister(this));
            if (!Where.Default)
            {
                this._IsFiltered = true;
                while (!this.CheckFilter && !this.EndOfData)
                    this.Advance();
            }

        }
Пример #16
0
        public AggregatePlan(RecordWriter Output, DataSet Source, Predicate Filter, FNodeSet Keys, AggregateSet Aggregates, FNodeSet ReturnSet,
            StaticRegister BaseMem, StaticRegister ReturnMem, string TempDir)
            : base()
        {

            this._writer = Output;
            this._source = Source;
            this._filter = Filter;
            this._keys = Keys ?? new FNodeSet();
            this._aggregates = Aggregates;
            this._returnset = ReturnSet;
            this._basememory = BaseMem;
            this._returnmemory = ReturnMem;
            this._sink = TempDir ?? Source.Directory;
            this.Name = "AGGREGATE";

        }
Пример #17
0
        public static long Update(DataSet Data, Key K, FNodeSet Fields, Predicate BaseDataFilter)
        {

            // Check that the field indicies and the maps have the same length //
            if (K.Count != Fields.Count)
                throw new Exception(string.Format("Field collection passed [{0}] has fewer elements than the map collection passed [{0}]", K.Count, Fields.Count));

            // Create the total append count //
            long CountOf = 0;

            // Loop through each extent //
            foreach (RecordSet rs in Data.Extents)
            {

                // Open a stream //
                RecordReader rr = new RecordReader(rs, BaseDataFilter);

                // Create a register //
                Register mem = new StreamRegister(rr);

                // Assign the register to the fields //
                Fields.AssignRegister(mem);

                // Update the data //
                while (!rr.EndOfData)
                {
                    Update(rr.Read(), K, Fields);
                    CountOf++;
                    rr.Advance();
                }

                // 
                if (rs.IsAttached)
                    BinarySerializer.Flush(rs);

            }

            // No need to flush the data set //

            return CountOf;

        }
Пример #18
0
        public NonlinearRegressionModel(string Name, DataSet Data, Predicate Where, FNode YValue, FNode Equation, FNode Weight)
            : base(Name, Data, Where, YValue, null, Weight)
        {
            
            // Save the equation //
            this._equation = Equation;

            // Create the parameter map //
            this._map = NonlinearRegressionModel.MapParameters(this._equation);

            // Set the X nodes equal to the partial gradients //
            this._XValue = NonlinearRegressionModel.Gradients(this._equation, this._map);

            // Need to initialize the matricies and vectors since the base ctor would not because XValues were passed as null //
            this.InitializeMatricies(this._XValue.Count);

            // Set the model to not strict //
            this.IsStrict = false;

            // Allow for more itterations //
            this._MaximumIterations = 20;

        }
Пример #19
0
	    // Constructor //
	    public RecordReader(RecordSet From, Predicate Where)
	    {
		
		    this._ptrRecord = DEFAULT_POINTER;
		    this._Data = From;
		    this._Where = Where;
            
            // Assign the where to a register pointing to 'this' //
            StreamRegister reg = new StreamRegister(this);
            this._Where.Node.AssignRegister(reg);
            
            // Fix the default //
            if (!Where.Default)
		    {
			    this._IsFiltered = true;
                while (!this.CheckFilter && !this.EndOfData)
                    this.Advance();
		    }

            // This is used to handle the writer class that inherits the reader //
            if (From != null)
                this._columns = From.Columns;
	    }
Пример #20
0
 public AggregateCovariance(FNode X, FNode Y, Predicate F)
     : base(X, Y, F)
 {
 }
Пример #21
0
 public NonlinearRegressionModel(string Name, DataSet Data, Predicate Where, FNode YValue, FNode Equation)
     : this(Name, Data, Where, YValue, Equation, FNodeFactory.Value(1D))
 {
 }
Пример #22
0
        protected override void BuildSS(DataSet Data, Predicate Where)
        {

            /* * * * * * * * * * * * * * * * * * * * * * * * *
             * 
             *  SSTO = (y - avg(y)) ^ 2
             *  SSE = (y - model(y)) ^ 2
             *  SSR = (model(y) - avg(y)) ^ 2
             * 
             * * * * * * * * * * * * * * * * * * * * * * * * */

            // Create variable indicies //
            double ExpectedValue = 0;
            double ActualValue = 0;
            double WeightValue = 0;
            
            // Nodes //
            FNode actual = this._YValue.CloneOfMe();
            FNode expected = this.BoundEquation;
            FNode weight = this._WValue.CloneOfMe();
            
            // Build a register //
            StaticRegister memory = new StaticRegister(null);
            actual.AssignRegister(memory);
            expected.AssignRegister(memory);
            weight.AssignRegister(memory);

            // Reallocate cursor //
            RecordReader rc = Data.OpenReader(Where);

            // ERROR matricies //
            this._SSTO = 0;
            this._SSR = 0;
            this._SSE = 0;
            double x = 0D;
            double x2 = 0D;

            // Main Loop - Cycle through all observations //
            while (!rc.EndOfData)
            {

                // Read record //
                memory.Assign(rc.ReadNext());
                ExpectedValue = expected.Evaluate().DOUBLE;
                ActualValue = actual.Evaluate().DOUBLE;
                WeightValue = weight.Evaluate().DOUBLE;
                
                // Set errors //
                x += ActualValue * WeightValue;
                x2 += ActualValue * ActualValue * WeightValue;
                this._SSE += Math.Pow(ExpectedValue - ActualValue, 2) * WeightValue;
                this._WeightSum += WeightValue;
                this._WeightSum2 += WeightValue * WeightValue;

            }
            // end main loop //

            // Set the means //
            this._Mean = x / this._WeightSum;
            this._Variance = x2 / this._WeightSum - (this._Mean * this._Mean);
            this._SSTO = (this.IsCorrected ? x2 : this._Variance * this._WeightSum);
            this._SSR = this._SSTO - this._SSE;
                
            // Build the parameter variance //
            Cell mse = new Cell((1 - this._WeightSum2 / (this._WeightSum * this._WeightSum)) * (this._SSE / this._WeightSum));
            for (int i = 0; i < this.ParameterCount; i++)
            {
                this._ParameterVariance[i] = Cell.CheckDivide(mse, this._Design[i, i]);
            }

        }
Пример #23
0
 public AggregateCountNull(FNode M, Predicate F)
     : base(M, F)
 {
 }
Пример #24
0
        // To Methods //
        public RecordSet ToFinal(FNodeSet Fields, Predicate Filter)
        {

            RecordSet rs = new RecordSet(Fields.Columns);
            RecordWriter w = rs.OpenWriter();

            this.WriteToFinal(w, Fields);

            return rs;

        }
Пример #25
0
 public abstract RecordReader OpenReader(Predicate P);
Пример #26
0
 public AggregateFreq(Predicate G)
     : this(Predicate.TrueForAll, G)
 {
 }
Пример #27
0
 public AggregateFreq(Predicate F, Predicate G)
     : this(new FNodeValue(null, Cell.OneValue(CellAffinity.DOUBLE)), F, G)
 {
 }
Пример #28
0
 public AggregateCorrelation(FNode X, FNode Y, Predicate F)
     : base(X, Y, F)
 {
 }
Пример #29
0
 public RecordWriter(RecordSet Data, Predicate Having)
     : base(Data, Having)
 {
 }
Пример #30
0
 public AggregateFreq(FNode M, Predicate G)
     : this(M, Predicate.TrueForAll, G)
 {
 }