コード例 #1
0
ファイル: MarketMLDataSet.cs プロジェクト: neismit/emds
 public override void AddDescription(TemporalDataDescription desc)
 {
     if (!(desc is MarketDataDescription))
     {
         throw new MarketError("Only MarketDataDescription objects may be used with the MarketNeuralDataSet container.");
     }
     base.AddDescription(desc);
 }
コード例 #2
0
 /// <summary>
 /// Get data between two points in raw form.
 /// </summary>
 /// <param name="desc">The data description.</param>
 /// <param name="index">The index to get data from.</param>
 /// <returns>The requested data.</returns>
 private double GetDataRaw(TemporalDataDescription desc,
     int index)
 {
     TemporalPoint point = _points[index - 1];
     return point[desc.Index];
 }
コード例 #3
0
 /// <summary>
 /// Get data between two points in percent form.
 /// </summary>
 /// <param name="desc">The data description.</param>
 /// <param name="index">The index to get data from.</param>
 /// <returns>The requested data.</returns>
 private double GetDataPercentChange(TemporalDataDescription desc,
     int index)
 {
     if (index == 0)
     {
         return 0.0;
     }
     TemporalPoint point = _points[index];
     TemporalPoint previousPoint = _points[index - 1];
     double currentValue = point[desc.Index];
     double previousValue = previousPoint[desc.Index];
     return (currentValue - previousValue)/previousValue;
 }
コード例 #4
0
 /// <summary>
 /// Get data between two points in delta form.
 /// </summary>
 /// <param name="desc">The data description.</param>
 /// <param name="index">The index to get data from.</param>
 /// <returns>The requested data.</returns>
 private double GetDataDeltaChange(TemporalDataDescription desc,
     int index)
 {
     if (index == 0)
     {
         return 0.0;
     }
     TemporalPoint point = _points[index];
     TemporalPoint previousPoint = _points[index - 1];
     return point[desc.Index]
            - previousPoint[desc.Index];
 }
コード例 #5
0
        /// <summary>
        /// Format data according to the type specified in the description.
        /// </summary>
        /// <param name="desc">The data description.</param>
        /// <param name="index">The index to format the data at.</param>
        /// <returns>The formatted data.</returns>
        private double FormatData(TemporalDataDescription desc,
            int index)
        {
            var result = new double[1];

            switch (desc.DescriptionType)
            {
                case TemporalDataDescription.Type.DeltaChange:
                    result[0] = GetDataDeltaChange(desc, index);
                    break;
                case TemporalDataDescription.Type.PercentChange:
                    result[0] = GetDataPercentChange(desc, index);
                    break;
                case TemporalDataDescription.Type.Raw:
                    result[0] = GetDataRaw(desc, index);
                    break;
                default:
                    throw new TemporalError("Unsupported data type.");
            }

            if (desc.ActivationFunction != null)
            {
                desc.ActivationFunction.ActivationFunction(result, 0, 1);
            }

            return result[0];
        }
コード例 #6
0
        /// <summary>
        /// Add a data description.
        /// </summary>
        /// <param name="desc">The data description to add.</param>
        public virtual void AddDescription(TemporalDataDescription desc)
        {
            if (_points.Count > 0)
            {
                throw new TemporalError(
                    "Can't add anymore descriptions, there are "
                    + "already temporal points defined.");
            }

            int index = _descriptions.Count;
            desc.Index = index;

            _descriptions.Add(desc);
            CalculateNeuronCounts();
        }
コード例 #7
0
 /// <summary>
 /// Generates a temporal data set with a given double serie or a any number of double series , making your inputs.
 /// uses Type percent change.
 /// </summary>
 /// <param name="windowsize">The windowsize.</param>
 /// <param name="predictsize">The predictsize.</param>
 /// <param name="inputserie">The inputserie.</param>
 /// <returns></returns>
 public static TemporalMLDataSet GenerateTrainingWithPercentChangeOnSerie(int windowsize, int predictsize, params double[][] inputserie)
 {
     TemporalMLDataSet result = new TemporalMLDataSet(windowsize, predictsize);
     TemporalDataDescription desc = new TemporalDataDescription(TemporalDataDescription.Type.PercentChange, true,
                                                                true);
     result.AddDescription(desc);
     foreach (double[] t in inputserie)
     {
         for (int j = 0; j < t.Length; j++)
         {
             TemporalPoint point = new TemporalPoint(1);
             point.Sequence = j;
             point.Data[0] = t[j];
             result.Points.Add(point);
         }
         result.Generate();
         return result;
     }
     return null;
 }
コード例 #8
0
ファイル: TemporalMLDataSet.cs プロジェクト: neismit/emds
 public virtual void AddDescription(TemporalDataDescription desc)
 {
     if (this._x6fa2570084b2ad39.Count <= 0)
     {
         int count = this._x6849a3dfb0329317.Count;
         if (((uint) count) <= uint.MaxValue)
         {
             desc.Index = count;
             this._x6849a3dfb0329317.Add(desc);
             this.CalculateNeuronCounts();
             return;
         }
     }
     throw new TemporalError("Can't add anymore descriptions, there are already temporal points defined.");
 }
コード例 #9
0
ファイル: MarketDataDescription.cs プロジェクト: neismit/emds
 public MarketDataDescription(TickerSymbol ticker, MarketDataType dataType, TemporalDataDescription.Type type, bool input, bool predict)
     : this(ticker, dataType, type, null, input, predict)
 {
 }
コード例 #10
0
ファイル: TemporalMLDataSet.cs プロジェクト: neismit/emds
 private double xea9b27496fd731f6(TemporalDataDescription x3253f43e16d3c2a3, int xc0c4c459c6ccbd00)
 {
     double num;
     double num2;
     if (xc0c4c459c6ccbd00 == 0)
     {
         return 0.0;
     }
     TemporalPoint point = this._x6fa2570084b2ad39[xc0c4c459c6ccbd00];
     TemporalPoint point2 = this._x6fa2570084b2ad39[xc0c4c459c6ccbd00 - 1];
     do
     {
         num = point[x3253f43e16d3c2a3.Index];
         num2 = point2[x3253f43e16d3c2a3.Index];
     }
     while ((((uint) num) | 3) == 0);
     return ((num - num2) / num2);
 }
コード例 #11
0
 /// <summary>
 /// Get data between two points in raw form.
 /// </summary>
 /// <param name="desc">The data description.</param>
 /// <param name="index">The index to get data from.</param>
 /// <returns>The requested data.</returns>
 private double GetDataRaw(TemporalDataDescription desc,
                           int index)
 {
     // Note: The reason that we subtract 1 from the index is because we are always one ahead.
     // This allows the DELTA change formatter to work.  DELTA change requires two timeslices,
     // so we have to be one ahead.  RAW only requires one, so we shift backwards.
     TemporalPoint point = _points[index-1];
     return point[desc.Index];
 }
コード例 #12
0
ファイル: TemporalMLDataSet.cs プロジェクト: neismit/emds
 private double xb45e1635c92024eb(TemporalDataDescription x3253f43e16d3c2a3, int xc0c4c459c6ccbd00)
 {
     if (xc0c4c459c6ccbd00 == 0)
     {
         return 0.0;
     }
     TemporalPoint point = this._x6fa2570084b2ad39[xc0c4c459c6ccbd00];
     TemporalPoint point2 = this._x6fa2570084b2ad39[xc0c4c459c6ccbd00 - 1];
     return (point[x3253f43e16d3c2a3.Index] - point2[x3253f43e16d3c2a3.Index]);
 }
コード例 #13
0
ファイル: TemporalMLDataSet.cs プロジェクト: neismit/emds
        private double x8c7fc30b887213d1(TemporalDataDescription x3253f43e16d3c2a3, int xc0c4c459c6ccbd00)
        {
            double[] d = new double[1];
            switch (x3253f43e16d3c2a3.DescriptionType)
            {
                case TemporalDataDescription.Type.Raw:
                    d[0] = this.x0f80f6735d6ae7a3(x3253f43e16d3c2a3, xc0c4c459c6ccbd00);
                    break;

                case TemporalDataDescription.Type.PercentChange:
                    d[0] = this.xea9b27496fd731f6(x3253f43e16d3c2a3, xc0c4c459c6ccbd00);
                    if (0 == 0)
                    {
                        break;
                    }
                    goto Label_009C;

                case TemporalDataDescription.Type.DeltaChange:
                    d[0] = this.xb45e1635c92024eb(x3253f43e16d3c2a3, xc0c4c459c6ccbd00);
                    break;

                default:
                    goto Label_009C;
            }
            Label_001C:
            if (x3253f43e16d3c2a3.ActivationFunction != null)
            {
                x3253f43e16d3c2a3.ActivationFunction.ActivationFunction(d, 0, 1);
                if (((uint) xc0c4c459c6ccbd00) < 0)
                {
                    goto Label_001C;
                }
            }
            Label_009C:
            return d[0];
        }
コード例 #14
0
ファイル: TemporalMLDataSet.cs プロジェクト: neismit/emds
 private double x0f80f6735d6ae7a3(TemporalDataDescription x3253f43e16d3c2a3, int xc0c4c459c6ccbd00)
 {
     TemporalPoint point = this._x6fa2570084b2ad39[xc0c4c459c6ccbd00 - 1];
     return point[x3253f43e16d3c2a3.Index];
 }
コード例 #15
0
        public IMLDataSet GenerateTraining()
        {
            var result = new TemporalMLDataSet(WindowSize, 1);

            var desc = new TemporalDataDescription(TemporalDataDescription.Type.Raw, true, true);
            result.AddDescription(desc);

            for (int year = TrainStart; year < TrainEnd; year++)
            {
                var point = new TemporalPoint(1) { Sequence = year };
                point.Data[0] = _normalizedSunspots[year];
                result.Points.Add(point);
            }

            result.Generate();

            return result;
        }
コード例 #16
0
ファイル: MarketDataDescription.cs プロジェクト: neismit/emds
 public MarketDataDescription(TickerSymbol ticker, MarketDataType dataType, TemporalDataDescription.Type type, IActivationFunction activationFunction, bool input, bool predict)
     : base(activationFunction, type, input, predict)
 {
     this._x96e4701dec47675e = ticker;
     this._xd2f3d36b96df4542 = dataType;
 }
コード例 #17
0
ファイル: NetworkUtility.cs プロジェクト: jongh0/MTree
 /// <summary>
 ///     Generates a temporal data set with a given double serie.
 ///     uses Type percent change.
 /// </summary>
 /// <param name="inputserie">The inputserie.</param>
 /// <param name="windowsize">The windowsize.</param>
 /// <param name="predictsize">The predictsize.</param>
 /// <returns></returns>
 public static TemporalMLDataSet GenerateTrainingWithPercentChangeOnSerie(double[] inputserie, int windowsize,
                                                                          int predictsize)
 {
     var result = new TemporalMLDataSet(windowsize, predictsize);
     var desc = new TemporalDataDescription(TemporalDataDescription.Type.PercentChange, true, true);
     result.AddDescription(desc);
     for (int index = 0; index < inputserie.Length - 1; index++)
     {
         var point = new TemporalPoint(1) {Sequence = index};
         point.Data[0] = inputserie[index];
         result.Points.Add(point);
     }
     result.Generate();
     return result;
 }
コード例 #18
0
ファイル: Stage1NeuralNetwork.cs プロジェクト: ifzz/QuantSys
        public IMLDataSet GenerateTraining()
        {
            var result = new TemporalMLDataSet(WindowSize, 1);
            var desc = new TemporalDataDescription(TemporalDataDescription.Type.Raw, true, true);
            result.AddDescription(desc);

            for (int i = WindowSize; i < _normalizedTrainingData.Length; i++)
            {
                var point = new TemporalPoint(1) {Sequence = i};
                point.Data[0] = _normalizedTrainingData[i];
                result.Points.Add(point);
            }
            result.Generate();
            return result;
        }