예제 #1
0
        protected PredictionOfCurrencyDataTable GetData(string backupFileName, DateTime from, DateTime to)
        {
            var result     = new PredictionOfCurrencyDataTable(Names);
            var serializer = new Serializer();

            if (!serializer.Exists(backupFileName))
            {
                for (var i = from; i < to; i = i.Add(DataParameter.Step))
                {
                    var vector = GetRawData(i, DataParameter.Step);
                    if (vector.Length == Collectors.Count)
                    {
                        result.Add(new PredictionOfCurrencyData {
                            Date = i, Vector = vector
                        });
                    }
                }
                result = DataValueTypeConverter[DataType](result);
                result = DataProcessingMethodsConverter[DataProcessingMethods](result);
                serializer.Serialize(result, backupFileName);
            }
            else
            {
                result = serializer.Deserialize <PredictionOfCurrencyDataTable>(backupFileName);
            }
            return(result);
        }
예제 #2
0
 protected void InitMaxsAndMins(PredictionOfCurrencyDataTable table)
 {
     Maxs = new PredictionOfCurrencyDataTable(Names);
     Maxs.Add(new PredictionOfCurrencyData {
         Vector = GetMaxs(table, GetBackupName())
     });
     Mins = new PredictionOfCurrencyDataTable(Names);
     Mins.Add(new PredictionOfCurrencyData {
         Vector = GetMins(table, GetBackupName())
     });
 }
예제 #3
0
 protected void InitExpectedValuesAndDispersions(PredictionOfCurrencyDataTable table)
 {
     ExpectedValues = new PredictionOfCurrencyDataTable(Names);
     ExpectedValues.Add(new PredictionOfCurrencyData {
         Vector = GetExpectedValues(table, GetBackupName())
     });
     Dispersions = new PredictionOfCurrencyDataTable(Names);
     Dispersions.Add(new PredictionOfCurrencyData {
         Vector = GetDispersions(table, GetBackupName(), ExpectedValues[0].Vector)
     });
 }
예제 #4
0
        protected PredictionOfCurrencyDataTable Convert(PredictionOfCurrencyDataTable table,
                                                        Func <Vector, Vector> formula)
        {
            var result = new PredictionOfCurrencyDataTable(Names);

            for (var i = 0; i < table.Data.Count; i++)
            {
                result.Add(new PredictionOfCurrencyData {
                    Date   = table[i].Date,
                    Vector = formula(table[i].Vector)
                });
            }
            return(result);
        }
예제 #5
0
        protected Vector GetMins(PredictionOfCurrencyDataTable table, string backupName)
        {
            var serializer     = new Serializer();
            var backupFileName = $"BackupMins{ backupName }.json";
            var result         = new Vector(Collectors.Count);

            if (backupName == null || !serializer.Exists(backupFileName))
            {
                for (var i = 0; i < result.Length; i++)
                {
                    result[i] = table[Collectors[i].GetType().Name].Min();
                }
                serializer.Serialize(result, backupFileName);
            }
            else
            {
                result = serializer.Deserialize <Vector>(backupFileName);
            }
            return(result);
        }
예제 #6
0
        protected Vector GetDispersions(PredictionOfCurrencyDataTable table, string backupName, Vector expectedValues = null)
        {
            if (expectedValues == null)
            {
                expectedValues = GetExpectedValues(table, backupName);
            }
            var serializer     = new Serializer();
            var backupFileName = $"BackupDispersions{ backupName }.json";
            var result         = new Vector(Collectors.Count);

            if (backupName == null || !serializer.Exists(backupFileName))
            {
                for (var i = 0; i < result.Length; i++)
                {
                    result[i] = table[Collectors[i].GetType().Name].Aggregate(0.0, (x, y) => x + Math.Pow(y - expectedValues[i], 2));
                }
                serializer.Serialize(result, backupFileName);
            }
            else
            {
                result = serializer.Deserialize <Vector>(backupFileName);
            }
            return(result);
        }
예제 #7
0
 protected PredictionOfCurrencyDataTable ConvertInRelativePercentage(PredictionOfCurrencyDataTable table) =>
 ConvertRelative(table, (current, previouse) => (current - previouse) / previouse);
예제 #8
0
 protected PredictionOfCurrencyDataTable NormalizeAndScale(PredictionOfCurrencyDataTable table) =>
 Scale(Normalize(table));
예제 #9
0
 protected PredictionOfCurrencyDataTable Scale(PredictionOfCurrencyDataTable table)
 {
     InitMaxsAndMins(table);
     return(Convert(table, x => Scaling(x, Maxs[0].Vector, Mins[0].Vector)));
 }
예제 #10
0
 protected PredictionOfCurrencyDataTable Normalize(PredictionOfCurrencyDataTable table)
 {
     InitExpectedValuesAndDispersions(table);
     return(Convert(table, x => Normalize(x, ExpectedValues[0].Vector, Dispersions[0].Vector)));
 }