我正在尝试重新创建以下示例https://github.com/dotnet/machinelearning/blob/master/docs/samples/Microsoft.ML.Samples/Dynamic/SsaSpikeDetectorTransform.cs 但我不断收到错误消息,即DataOperations不包含ReadFromEnumerable方法的定义。 我还收到一个错误,指出CreateEnumerable方法不存在,但我怀疑它与ReadFromEnumerable错误有关。
我已经复制了整个命名空间和代码,以防万一我错过了一些东西,但是错误仍然发生。
从Enumerable方法读取
var ml = new MLContext();
//Generate sample series data with a recurring pattern and a spike within the pattern
const int SeasonalitySize = 5;
const int TrainingSeasons = 3;
const int TrainingSize = SeasonalitySize * TrainingSeasons;
var data = new List<SsaSpikeData>();
for (int i = 0; i < TrainingSeasons; i++)
for (int j = 0; j < SeasonalitySize; j++)
data.Add(new SsaSpikeData(j));
//This is a spike
data.Add(new SsaSpikeData(100));
for (int i = 0; i < SeasonalitySize; i++)
data.Add(new SsaSpikeData(i));
// Convert data to IDataView.
var dataView = ml.Data.ReadFromEnumerable(data); //This is where the error occurs
CreateEnumerable方法
var predictionColumn = ml.CreateEnumerable<SsaSpikePrediction>(transformedData, reuseRowObject: false);
答案 0 :(得分:2)
就像dlatikay所说的,这是版本不匹配。 我提供的示例来自仍处于预览状态的版本。 对于ML.NET 0.9.0和更早版本,您需要使用CreateStreamingDataView。 要使ReadFromEnumerable和CreateEnumerable正常运行,您可以从此处https://dotnet.myget.org/feed/dotnet-core/package/nuget/Microsoft.ML/0.11.0-preview-27404-5
下载ML.NET 0.10.0和0.11.0预览包。