3
我正在使用Weka作爲更長的管道的一部分,因此,我無法將所有數據寫入文件或數據庫中,只是爲了創建一個Instances
對象。我可以在飛行中做的是創建一個Instance
對象列表。如何在列表<Instance>中在Weka中創建`Instances`?
從this page of their API我可以看到,Instances
實現List<Instance>
,但Weka的似乎並不具有公共構造函數,將採取一個List<Instance>
作爲參數。我試圖粗鑄件以及:
List<Instance> instanceList;
while (...) { // some conditional loop
Instance inst = ... // more code where I am populating an individual instance
instanceList.add(inst);
}
Instances instances = (Instances) instanceList;
在上面的最後一行,理念的IntelliJ表明我,我可能會遇到一個ClassCastException
警告。我如何安全地從我的個人Instance
對象中創建Instances
?
我試過使用該構造函數,但它最終沒有做我想要的。這是一個相當詳細的問題,所以我把它作爲一個[單獨的問題在SO](http://stackoverflow.com/questions/20768607/using-stringtowordvector-in-weka-with-internal-data-structures) –
什麼你的意思是「不是你想要的?」它創建一個空的實例列表,這是你需要的,然後你將它們添加到它。這正是你寫的問題所要求的! –
正如我在評論中提到的那樣,這是一個相當詳細的問題。我的意思是「我不想要什麼」本身就是一個完整的問題(我已經鏈接到這個問題)。 –