我是新手,但我发现golearn项目在github上有很多明星,所以我决定尝试一下简单的分类问题。但是/xxx/../../thirdparty/boost/1.60.0/dist/boost/range/value_type.hpp:26:70: error: no type named 'type' in
'boost::range_iterator<local::boo<boost::range_detail::filtered_range<(lambda at
/xxx/Tests.cpp:221:49), std::vector<int, std::allocator<int> > > >, void>'
struct range_value : iterator_value< typename range_iterator<T>::type >
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
/xxx/../../thirdparty/boost/1.60.0/dist/boost/range/adaptor/replaced.hpp:122:40: note: in instantiation of template class
'boost::range_value<local::boo<boost::range_detail::filtered_range<(lambda at
/xxx/Tests.cpp:221:49), std::vector<int, std::allocator<int> > > > >' requested
here
BOOST_DEDUCED_TYPENAME range_value<SinglePassRange>::type>& f)
^
/xxx/Tests.cpp:222:37: note: while substituting deduced template arguments into
function template 'operator|' [with SinglePassRange = local::boo<boost::range_detail::filtered_range<(lambda at
/xxx/Tests.cpp:221:49), std::vector<int, std::allocator<int> > > >]
auto f = boo<decltype(filtered)>{} | xs;
方法出现了第一次尝试指针问题,我不确定它是否是golearn绑定中的错误,或者是否与错误的设置有关。
这是代码的简化版本:
Train
这是我得到的输出:
package main
import (
_ "github.com/sjwhitworth/golearn/base"
liblinear "github.com/sjwhitworth/golearn/linear_models"
)
func main() {
labels, features := getFeatures()
vocabulary := createVocabulary(features)
words_matrix := countedMatrix(features, vocabulary)
fmt.Println("labels:", labels)
fmt.Println("words matrix:", words_matrix)
solver_type := liblinear.L2R_LR_DUAL
C := 10.0
eps := 0.01
bias := -1.0
parameter := liblinear.NewParameter(solver_type, C, eps)
problem := liblinear.NewProblem(words_matrix, categories, bias)
model := liblinear.Train(problem, parameter)
prediction_vector := countedVector(tokenize("something to predict here"), vocabulary)
fmt.Println("prediction vector:", prediction_vector)
prediction := liblinear.Predict(model, prediction_vector)
fmt.Println("prediction:", prediction)
}
我应该报告问题或修复代码(如果可以修复,请帮助我)