scikit-learn - 在 sklearn 源代码中输入 cython 的 SIZE_t
问题描述
我尝试基于此实现 sklearn 的 Criterion 对象的一个子集: https ://github.com/scikit-learn/scikit-learn/blob/master/sklearn/tree/_criterion.pyx#L54 。
但是,当我尝试在我的 jupyter 笔记本中运行代码时,它收到一条错误消息,提示
TypeError: object of type 'NoneType' has no len()并且有一些**^**
指针指向我在 init 函数中的参数类型,如下所示:
cdef int init(self, const DOUBLE_t[:, ::1] y, DOUBLE_t* sample_weight,
double weighted_n_samples, SIZE_t* samples,
SIZE_t start, SIZE_t end):
我尝试将类型SIZE_t 更改为 size_t并将DOUBLE_t 更改为 double,并且错误消失了。但我不确定为什么源代码中包含 SIZE_t 和 DOUBLE_t,以及在我的代码中仅使用 size_t 和 double 作为类型是否安全。谢谢。
可能这与 C 类型有某种关系,但我不确定。
解决方案
推荐阅读
- neo4j - Neo4j 查找具有多个跃点和相同模式的节点之间的路径
- python - 如何使用 BeautifulSoup 提取带有 data-reactid 的 span 内容?
- javascript - TypeError:无法读取未定义的属性“toString”,地图未加载
- android - 如何通过点击图像或卡片在应用程序中打开任何 URL?
- java - Apache Spark Java 设置内存大小
- c# - 在 UWP C# 中从路径绘制图形
- mysql - 如何计算 MySQL 表列中不同元素的总数?
- c - 为什么 C 语言允许用户创建名称与预先存在的库函数相同的宏?
- python - Creating python library with dynamic settings based on the source where I import it
- python - Flask is not finding folders and files in Python