本文整理汇总了C#中IMLDataSet.Add方法的典型用法代码示例。如果您正苦于以下问题:C# IMLDataSet.Add方法的具体用法?C# IMLDataSet.Add怎么用?C# IMLDataSet.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMLDataSet
的用法示例。
在下文中一共展示了IMLDataSet.Add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Generate
public static void Generate(IMLDataSet training, long seed, int count, double min, double max)
{
int num;
int idealSize;
int num3;
IMLData data;
int num4;
IMLData data2;
int num5;
LinearCongruentialGenerator generator = new LinearCongruentialGenerator(seed);
goto Label_0111;
Label_0023:
if (num3 < count)
{
data = new BasicMLData(num);
num4 = 0;
while (true)
{
if (num4 < num)
{
data[num4] = generator.Range(min, max);
}
else
{
data2 = new BasicMLData(idealSize);
num5 = 0;
goto Label_004D;
}
num4++;
}
}
if ((((uint) num) - ((uint) num)) >= 0)
{
if ((((uint) num4) - ((uint) num3)) >= 0)
{
if ((((uint) seed) + ((uint) seed)) >= 0)
{
return;
}
goto Label_0111;
}
goto Label_00F5;
}
Label_0047:
num5++;
Label_004D:
if (num5 >= idealSize)
{
if ((((uint) max) + ((uint) num3)) <= uint.MaxValue)
{
BasicMLDataPair inputData = new BasicMLDataPair(data, data2);
training.Add(inputData);
num3++;
}
}
else
{
data2[num5] = generator.Range(min, max);
if (((uint) num5) >= 0)
{
goto Label_0047;
}
}
goto Label_0023;
Label_00F5:
num3 = 0;
goto Label_0023;
Label_0111:
num = training.InputSize;
idealSize = training.IdealSize;
goto Label_00F5;
}
示例2: Generate
/// <summary>
/// Generate random training into a training set.
/// </summary>
/// <param name="training">The training set to generate into.</param>
/// <param name="seed">The seed to use.</param>
/// <param name="count">How much data to generate.</param>
/// <param name="min">The low random value.</param>
/// <param name="max">The high random value.</param>
public static void Generate(IMLDataSet training,
long seed,
int count,
double min, double max)
{
var rand
= new LinearCongruentialGenerator(seed);
int inputCount = training.InputSize;
int idealCount = training.IdealSize;
for (int i = 0; i < count; i++)
{
IMLData inputData = new BasicMLData(inputCount);
for (int j = 0; j < inputCount; j++)
{
inputData[j] = rand.Range(min, max);
}
IMLData idealData = new BasicMLData(idealCount);
for (int j = 0; j < idealCount; j++)
{
idealData[j] = rand.Range(min, max);
}
var pair = new BasicMLDataPair(inputData,
idealData);
training.Add(pair);
}
}
示例3: LoadCompany
/// <summary>
/// Called to load training data for a company. This is how the training data is actually created.
/// To prepare input data for recognition use the CreateData method. The training set will be
/// added to. This allows the network to learn from multiple companies if this method is called
/// multiple times.
/// </summary>
/// <param name="symbol">The ticker symbol.</param>
/// <param name="training">The training set to add to.</param>
/// <param name="from">Beginning date</param>
/// <param name="to">Ending date</param>
public void LoadCompany(String symbol, IMLDataSet training, DateTime from, DateTime to)
{
IMarketLoader loader = new YahooFinanceLoader();
TickerSymbol ticker = new TickerSymbol(symbol);
IList<MarketDataType> dataNeeded = new List<MarketDataType>();
dataNeeded.Add(MarketDataType.AdjustedClose);
dataNeeded.Add(MarketDataType.Close);
dataNeeded.Add(MarketDataType.Open);
dataNeeded.Add(MarketDataType.High);
dataNeeded.Add(MarketDataType.Low);
List<LoadedMarketData> results = (List<LoadedMarketData>)loader.Load(ticker, dataNeeded, from, to);
results.Sort();
for (int index = PredictWindow; index < results.Count - EvalWindow; index++)
{
LoadedMarketData data = results[index];
// determine bull or bear position, or neither
bool bullish = false;
bool bearish = false;
for (int search = 1; search <= EvalWindow; search++)
{
LoadedMarketData data2 = results[index + search];
double priceBase = data.GetData(MarketDataType.AdjustedClose);
double priceCompare = data2.GetData(MarketDataType.AdjustedClose);
double diff = priceCompare - priceBase;
double percent = diff / priceBase;
if (percent > BullPercent)
{
bullish = true;
}
else if (percent < BearPercent)
{
bearish = true;
}
}
IMLDataPair pair = null;
if (bullish)
{
pair = CreateData(results, index, true);
}
else if (bearish)
{
pair = CreateData(results, index, false);
}
if (pair != null)
{
training.Add(pair);
}
}
}