Python - 决策树和处理唯一标签/功能(Python - Decision Trees and Handling Unique Labels/features)
不确定标题是否完全正确,对此感到抱歉。 我是机器学习的新手,我正在使用Scikit和决策树。
这就是我想要做的; 我希望获取所有输入并包含一个独特的功能,即客户端ID。 现在,客户端ID是唯一的,无法以特征在决策树分析中的正常方式进行总结。 现在发生的事情是树正在将客户端ID作为任何其他整数值,然后将其分支,例如,客户端ID小于430的路径与430以上的路径不同。这不正确而不是我想要的去做。 我想做的是让决策树理解不能以这种方式分析特定字段,每个客户端都有自己的分支。 这可能与决策树有关吗?
我确实有一些解决方法,其中一个是为每个客户开发独特的决策树,但培训这将是一场噩梦。 我还可以做另一种解决方法,并且假设我们有800个客户端,我会用一个字段创建800个功能,但这也很疯狂。
Not sure if the title makes complete sense so sorry about that. I'm new to Machine Learning and I'm using Scikit and decision trees.
Here's what I want to do; I want to take all of my inputs and include a unique feature which is a client ID. Now, the client ID is unique and can't be summed up in the normal way a feature would in decision tree analysis. What's happening now is that the tree is taking the client ID's as any other integer value and then branching it saying for instance, client ID's less than 430 go in a different path than those over 430. This isn't correct and not what I want to do. What I want to do is make the decision tree understand that the specific field can't be analyzed in such a way and each client will have their own branch. Is this possible with decision trees?
I do have a couple workarounds, one of which would be to develop unique decision trees for each client but training this would be a nightmare. I could also do another workaround, and lets say we have 800 clients, I would create 800 features with a bit field, but this is also crazy.
原文:https://stackoverflow.com/questions/42373494
相关问答
更多-
[C ++ 11标准。] 12.1.5。 如果类X没有用户声明的构造函数,则没有参数的构造函数被隐式声明为默认值(8.4)。 12..1 ......“如果它们使用得太多,那么实现将隐式定义它们”...... 因此,如果你删除apple::apple() ,实现可能不会创建apple::apple()除非它实际被调用,因此不需要引用fruit::fruit() 。 如上所述,代码不会调用apple::apple() 。 [ C++11 standard.] 12.1.5. If there is no us ...
-
这适用于本机C ++,因为它使用链接器。 如果没有人要求,会对缺少的成员实施感到满意。 但是这在托管代码中不起作用,它不使用链接器。 您的类定义将复制到程序集元数据中,并且绑定会在运行时动态发生。 这要求所有声明的成员都有一个表示,否则元数据将不完整,并且不支持,因为这会破坏反射。 即使是私人会员。 没有什么特别难以解决的, {}对于私有构造函数来说是一个非常好的实现。 This works in native C++ because it uses a linker. Which is happy wit ...
-
C ++类的默认构造函数(C++ Classes default constructor)[2022-06-28]
这个问题将有助于理解这种行为 this question will be helpful to understand this behavior -
= default告诉编译器使用默认实现。 这也意味着您无法提供自己的 。 如果您不希望编译器创建一个,只需删除= default : class Fraction { // ... Fraction(const Fraction&); // NO =default }; 顺便说一句,“默认构造函数”是在您不提供任何参数时调用的构造函数,例如 Fraction my_frac; // default constructor called 如果要禁用默认构造函数,请使用=delete : clas ...
-
它与移动构造函数无关。它与默认构造函数有关。 尝试这个: class Y { public: Y(const Y&) {} }; struct hasY { hasY() = default; hasY(hasY&&) = default; Y mem; }; hasY hy; // This will cause an error because there is no default constructor 现在,如果添加默认构造函数: Y(){} ,则错误将消失。 ...
-
我认为你问的是错误的问题,而不是试图禁止初始化,你应该这样做,即拼写你的ctor: Foo(int a) : x((a==0) ? Bar(12,'a', 34) : Bar(13)) {} 这不会导致任何副本或移动(请参阅此处 ),并且不会产生任何惯用。 I think you are asking the wrong question, instead of trying to inhibit initialization, you should just do it, i.e. spell your ...
-
禁用默认构造的集中方法是使默认构造函数不可访问。 你写道:“我想知道是否有解决方案来防止程序员编写代码(隐式或不是)使用默认拷贝构造函数,如果对象不是POD。” 大概你的意思是你希望编译器对任何非POD对象的默认构造做出反应。 对不起,没有与编译器无关的方式。 原因:诸如智能指针和容器(如std::vector很多非POD类依赖于缺省构造才有用。 g ++编译器有一个选项-Weffc++来警告违反Scott Meyers的Effective C ++指南 ,但据我所知 - 我可能是错的 - 这不包括你的情况 ...
-
C ++ - 为什么默认构造函数甚至在私有继承中也能工作(C++ - Why does the default constructor work even in private inheritance)[2023-05-18]
没有涉及虚拟继承,所以不能由C来构造A.因此,C的构造函数调用B的构造函数,B又调用A的构造函数。没有任何假定的访问说明符违规。 对于虚拟继承的情况,我们注意到从成员初始化列表中省略的子对象的构造由 [class.base.init / 9] 在非委托构造函数中,如果给定的可能构造的子对象不是由mem-initializer-id指定的(包括没有mem-initializer-list的情况,因为构造函数没有ctor-initializer),那么 ... ... 否则,实体默认初始化。 所以上面的子句似乎 ... -
复制C ++中没有默认构造函数的成员的构造函数(Copy constructor for class that has member without default constructor in C++)[2023-10-09]
如果您的Subset()类具有复制构造函数,那么您可以执行以下操作: std::vector::const_iterator it ; // use iterators for ( it = other.subsets.begin() ; it != other.subsets.end() ; ++it ) subset.push_back( new Subset( *it )) ; // add a copy of original subset. 如果您的Subset()没 ... -
为什么COM类需要构造函数?(Why COM classes need constructor? How to use COM class without registration?)[2022-03-03]
它与COM无关,只是框架以这种方式构建,并且DirectShow BaseClasses中的构造函数参数是将所有内容组合在一起所必需的 - 类,祖先,实例化工厂。 使用COM类而不注册可能是也可能不可能。 我怀疑你可能有兴趣在没有注册的情况下使用DirectShow过滤器,并且有一篇关于该主题的好文章: 使用没有注册的过滤器 。 It has nothing to do with COM, it is just the framework is built this way and constructor ...