sklearn API 参数解析 —— CART

sklearn API 参数解析 —— CART,第1张

CART是分类与回归树(Classification and Regression Trees, CART),是一棵二叉树,可用于回归与分类。

下面是 分类树 :

class  sklearntreeDecisionTreeClassifier ( criterion=’gini’ ,  splitter=’best’ ,  max_depth=None ,  min_samples_split=2 ,  min_samples_leaf=1 ,  min_weight_fraction_leaf=00 ,  max_features=None ,  random_state=None ,  max_leaf_nodes=None ,  min_impurity_decrease=00 ,  min_impurity_split=None ,  class_weight=None ,  presort=False )

Parameters:

1)criterion  : string, optional (default=”gini”)

The function to measure the quality of a split Supported criteria are “gini” for the Gini impurity and “entropy” for the information gain

衡量生成树的纯度,可选择基尼系数 'gini',或者信息熵 'entropy'

节点 t 的基尼系数与信息熵计算公式:

                 

                  

2)splitter  : string, optional (default=”best”)

The strategy used to choose the split at each node Supported strategies are “best” to choose the best split and “random” to choose the best random split

分裂点选择,有两种方式可选择,'best' 与 'random'。

(???)

3)max_depth  : int or None, optional (default=None)

The maximum depth of the tree If None, then nodes are expanded until all leaves are pure or until all leaves contain less than min_samples_split samples

设置决策树的最大深度。如果为None,停止条件为:

1)所有叶子节点不纯度为0

2)叶子节点包含样本个数低于 ' min_samples_split '

4)min_samples_split  : int, float, optional (default=2)

The minimum number of samples required to split an internal node:

If int, then consider min_samples_split as the minimum number

If float, then min_samples_split is a fraction and ceil(min_samples_split  n_samples) are the minimum number of samples for each split

Changed in version 018: Added float values for fractions

内部节点包含的最少样本数,可输入整数或者小数;即如果内部节点包含样本书低于这个值,则不再分裂,直接作为叶子节点。

如果输入整数 d, min_samples_split = d;

如果输入小数 f ,  min_samples_split = f N; N为样本总数 。

5)min_samples_leaf  : int, float, optional (default=1)

The minimum number of samples required to be at a leaf node A split point at any depth will only be considered if it leaves at least min_samples_leaf training samples in each of the left and right branches This may have the effect of smoothing the model, especially in regression

If int, then consider min_samples_leaf as the minimum number

If float, then min_samples_leaf is a fraction and ceil(min_samples_leaf  n_samples) are the minimum number of samples for each node

Changed in version 018: Added float values for fractions

叶子节点包含的最少样本数。

如果一个节点分裂后,左右子节点包含样本书低于 min_samples_leaf ,则不可以分裂 。

6)min_weight_fraction_leaf  : float, optional (default=0)

The minimum weighted fraction of the sum total of weights (of all the input samples) required to be at a leaf node Samples have equal weight when sample_weight is not provided

叶子节点包含样本的最小权重值。

7)max_features  : int, float, string or None, optional (default=None)

The number of features to consider when looking for the best split:

If int, then consider max_features features at each split

If float, then max_features is a fraction and int(max_features  n_features)features are considered at each split

If “auto”, then max_features=sqrt(n_features)

If “sqrt”, then max_features=sqrt(n_features)

If “log2”, then max_features=log2(n_features)

If None, then max_features=n_features

Note: the search for a split does not stop until at least one valid partition of the node samples is found, even if it requires to effectively inspect more than max_features features

节点分裂时考虑的最大特征数量。

8)random_state  : int, RandomState instance or None, optional (default=None)

If int, random_state is the seed used by the random number generator; If RandomState instance, random_state is the random number generator; If None, the random number generator is the RandomState instance used by nprandom

随机种子/随机生成器。

9)max_leaf_nodes  : int or None, optional (default=None)

Grow a tree with max_leaf_nodes in best-first fashion Best nodes are defined as relative reduction in impurity If None then unlimited number of leaf nodes

叶子节点最大个数。

10)min_impurity_decrease  : float, optional (default=0)

A node will be split if this split induces a decrease of the impurity greater than or equal to this value

The weighted impurity decrease equation is the following:

N_t  / N    (impurity  -  N_t_R  /  N_t    right_impurity  

                                 -   N_t_L  /  N_t    left_impurity)

where N is the total number of samples, N_t is the number of samples at the current node, N_t_L is the number of samples in the left child, and N_t_R is the number of samples in the right child

N, N_t, N_t_R and N_t_L all refer to the weighted sum, if sample_weight is passed

New in version 019

不纯度最小减少值,即分裂节点时必须满足减少的不纯度大于这个值。

如果设置了样本权重,N, N_t, N_t_R and N_t_L指的是加权和,否则只是样本计数。

11)min_impurity_split  : float, (default=1e-7)

Threshold for early stopping in tree growth A node will split if its impurity is above the threshold, otherwise it is a leaf

Deprecated since version 019: min_impurity_split has been deprecated in favor of min_impurity_decrease in 019 The default value of min_impurity_split will change from 1 e-7 to 0 in 023 and it will be removed in 025 Use min_impurity_decrease instead

节点停止分裂的不纯度阈值。与上一参数作用相同。025版本后删除。

12)class_weight  : dict, list of dicts, “balanced” or None, default=None

Weights associated with classes in the form {class_label: weight} If not given, all classes are supposed to have weight one For multi-output problems, a list of dicts can be provided in the same order as the columns of y

Note that for multioutput (including multilabel) weights should be defined for each class of every column in its own dict For example, for four-class multilabel classification weights should be [{0: 1, 1: 1}, {0: 1, 1: 5}, {0: 1, 1: 1}, {0: 1, 1: 1}] instead of [{1:1}, {2:5}, {3:1}, {4:1}]

The “balanced” mode uses the values of y to automatically adjust weights inversely proportional to class frequencies in the input data as n_samples / (n_classes  npbincount(y))

For multi-output, the weights of each column of y will be multiplied

Note that these weights will be multiplied with sample_weight (passed through the fit method) if sample_weight is specified

设置类别权重,参数 dict, list of dicts,'balanced'  或者 'None'

输入list, list of dict,手动设置类别权重。

输入 'balanced', 模型利用公式 n_samples / (n_classes  npbincount(y)) 对每个类别样本数量自动调整权重,使得每个类别的权重相同。即某个类别样本数量少,单个样本权重就大;类别样本数量多,单个样本权重就小。最终所有类别的权重都一样。当样本分布不均时,可以这样 *** 作。

输入 'None', 默认样本权重都一样。

13)presort  : bool, optional (default=False)

Whether to presort the data to speed up the finding of best splits in fitting For the default settings of a decision tree on large datasets, setting this to true may slow down the training process When using either a smaller dataset or a restricted depth, this may speed up the training

是否对样本进行预分类。

即节点寻找最优分裂点之前,对样本进行预排序,加快找到最优分裂点;由于增加了一步 *** 作,数据集小的时候可以加快速度;但数据集大的时候反而会减慢速度。

Attributes:

1)classes_  : array of shape = [n_classes] or a list of such arrays

The classes labels (single output problem), or a list of arrays of class labels (multi-output problem)

标签列表

2)feature_importances_  : array of shape = [n_features]

Return the feature importances

特征重要系数

3)max_features_  : int,

The inferred value of max_features

特征数量

4)n_classes_  : int or list

The number of classes (for single output problems), or a list containing the number of classes for each output (for multi-output problems)

5)n_features_  : int

The number of features when fit is performed

训练时用到的特征数量

(???)

6)n_outputs_  : int

The number of outputs when fit is performed

7)tree_  : Tree object

The underlying Tree object Please refer to help(sklearntree_treeTree) for attributes of Tree object and  Understanding the decision tree structure  for basic usage of these attributes

返回决策树对象(sklearntree_treeTree)

混排(Shuffling) 混排算法所做的正好与 sort 相反: 它打乱在一个 List 中可能有的任何排列的踪迹 也就是说 基于随机源的输入重排该 List 这样的排列具有相同的可能性(假设随机源是公正的) 这个算法在实现一个碰运气的游戏中是非常有用的 例如 它可被用来混排代表一副牌的 Card 对象的一个 List 另外 在生成测试案例时 它也是十分有用的 这个 *** 作有两种形式 第一种只采用一个 List 并使用默认随机源 第二种要求调用者提供一个 Random 对象作为随机源 这个算法的一些实际代码曾在 List 课程中被作为例子使用 常规数据 *** 作(Routine Data Manipulation) Collections 类为在 List 对象上的常规数据 *** 作提供了三种算法 这些算法是十分简单明了的: reverse: 反转在一个列表中的元素的顺序 fill: 用特定值覆盖在一个 List 中的每一个元素 这个 *** 作对初始化一个 List 是十分有用的 copy: 用两个参数 一个目标 List 和一个源 List 将源的元素拷贝到目标 并覆盖它的内容 目标 List 至少与源一样长 如果它更长 则在目标 List 中的剩余元素不受影响 搜索(Searching) binary search (二进制搜索)算法用二进制搜索算法在一个已排序的 List 中寻找特定元素 这个算法有两种形式 第一种采用一个 List 和一个要寻找的元素 ( 搜索键(search key) ) 这种形式假设 List 是按照它的元素的自然排序排列成上升顺序的 第二种形式除采用 List 外 还采用一个 Comparator 以及搜索键 并假设 List 是按照特定 Comparator 排列成上升顺序的 排序算法(描述见上) 可优先于 binarySearch 而被用来为List 排序 两种形式的返回值是相同的: 如果 List 包含搜索键 它的索引将被返回 如果不包括 则返回值为 ( (insertion point) ) 这里的 insertion point 被定义为一个点 从这个点该值将 入到这个 List 中 大于该值的第一个元素的位置索引 或list size() 选用这个不可否认的难看的公式是为了保证如果且仅如果搜索键被发现 则返回值将等于 它基本上是一个将布尔逻辑 ( found ) 和整数 ( index ) 综合到单一的int返回值的大杂烩 下列惯用程序对 binarySearch *** 作的两种形式均适用 它寻找特定搜索键 如果搜索键不出现 则将它插入到适当的位置: int pos = Collections binarySearch(l key); if (pos < 0) ladd(-pos-1, key); 寻找极值(Finding Extreme Values) min 和 max 算法分别返回包含在特定 Collection 中的最小和最大元素。TwwInGwIT这两个 *** 作都各有两种形式,简单形式只采用一个 Collection, 并按照元素的自然排序返回最小 (或最大) 元素;另一种形式除采用 Collection 之外,还采用一个 Comparator,并按照特定 Comparator返回最小(或最大)元素。这些就是由Java 平台提供的作用于与 List 对象相对的任意 Collection 对象上的仅有算法,就象上面提到的 fill 算法一样,这些算法都是非常简单明了的,它们是Java平台为程序员特别提供的便利工具。 lishixinzhi/Article/program/Java/Javascript/201311/25443

Random r=new Random(); //实例化一个Random类

//随机产生一个整数

Systemoutprintln("随机产生一个整数:"+rnextInt());

//随机产生一个大于等于0小于10的整数

Systemoutprintln("随机产生一个大于等于0小于10的整数:"+rnextInt(10));

Systemoutprintln("随机产生一个布尔型的值:"+rnextBoolean()); //随机产生一个布尔型的值

Systemoutprintln("随机产生一个双精度型的值:"+rnextDouble()); //随机产生一个双精度型的值

Systemoutprintln("随机产生一个浮点型的值:"+rnextFloat()); //随机产生一个浮点型的值

//随机产生一个概率密度为高斯分布的双精度值

Systemoutprintln("随机产生一个概率密度为高斯分布的双精度值:"+rnextGaussian());

由于>

美国十大社交网站有哪些呢?

北京时间8月12日消息,美国知名财经杂志《福布斯》网络版今天评出了美国十大社交媒体,其中美国手机地理位置服务商Foursquare居首,其他上榜的公司或服务还包括团购网站GroupOn、Facebook问答服务及随机视频聊天网站ChatRoulette等等。

《福布斯》指出,目前各类社交媒体网站数量正呈快速增长之势。这些社交媒体网站获得外界关注并不难,难的是多年以后一直能够保持各自市场活力。以社交书签服务网站Delicious为例,该网站曾红极一时,并被外界称为社交媒体的先行者。正因为Delicious受到网民追捧,后来雅虎将其收为己有,交易额约为2000万美元。

虽然目前Delicious业务仍在正常开展,但该网站已不再受到媒体的强烈关注,而Twitter、Foursquare等社交媒体新秀目前正如日中天。此外,社交游戏开发商Zynga已被视为互联网创业公司IPO的最佳选手。但大家无法预料的是,5年之后这些网站是否仍然会受到外界关注。从这个角度上讲,Delicious由当年大红大紫走向默默无闻的经历,值得各社交媒体网站反思。

尽管如此,有关社交媒体领域的收购活动却丝毫没有减慢迹象。上周期间,谷歌收购了社交网站工具开发商Slide。有报道称,该交易涉资金额为182亿美元。此外,还有大量交易额在1000万美元的社交媒体收购活动并没有被外界关注。

以下为《福布斯》所评选美国十大社交媒体:

1、手机地理位置服务商Foursquare

从性能上看,Foursquare是面向智能手机用户发布的移动应用程序。利用Foursquare服务,手机用户可在某个地点“签到”(check in),该地点可为全球任何城市的一家饭店、好友家庭居住地或一家商店等等。相应签到过程非常迅速。用户完成签到过程后,Foursquare将根据用户签到时的位置,向用户返回该地点附近的其他信息。

Foursquare用户群多为年轻人,他们在相应地点签到后,不但可获得积分,在某些情况下,用户还可获得虚拟勋章。如果某位用户在某个地点签到的次数最多,他将获得该地点虚拟“市长”的头衔。Foursquare今年6月透露,将于今年夏季末开通自家网络商店,以向用户销售印有Foursquare标识的T恤衫及其他产品。

2、团购网站GroupOn

Groupon总部位于芝加哥,其团购服务于一年前正式上线,目前该公司业务已扩展至美国50多个城市,同时还在加拿大开展业务。Groupon的大致服务模式是:用户在Facebook、Twitter等社交网站发布团购信息,在成员达到一定数量后,商家向团购者提供价格优惠,Groupon则按照交易规模的大小,向商家收取相应比率的交易费用。

GroupOn今年4月宣布,已完成新一轮融资,融资额为135亿美元。该网站表示,今后将把这笔资金用于两个方面:一是扩大Groupon业务规模和范围,以拉开同竞争对手的差距;二是向员工和早期投资者支付现金。Groupon此前已进入盈利阶段,目前员工量约为270名。

3、购物折扣和地理位置服务商BeThereDeals

BeThereDeals将购物折扣信息和地理位置服务混合在一起。该公司发布了针对苹果iPhone手机用户的应用程序,利用该应用程序,用户可查看自己当前所在位置,并了解自己周围有哪些商店提供折扣商品。目前BeThereDeals业务范围仅限于旧金山和纽约市,但计划今后在美国更多城市开展业务。

4、Facebook问答服务

今年4月有媒体报道称,Facebook已开始小范围测试其问答服务。一些参与了测试的Facebook用户称,该问答服务的各项功能同雅虎问答、Quora(由Facebook前CTO等员工创办)及Mahalo等类似业务非常相似。Facebook上月底宣布,已开始邀请更多用户参与该网站一项新型问答服务的测试,并承诺将尽快向所有用户开放这项服务。

用户登录Facebook网站后,可看到一个“提问”按钮,点击该按钮,就可键入自己的提问内容,其他用户可对此进行解答。Facebook表示,初期阶段仅向300万至500万用户提供这项服务,但近期内将尽快让所有用户用上该服务。Facebook特别指出,任何用户提出的问题,所有其他用户都能看到。

5、社交网站Treehouse

Facebook全球用户量已突破5亿。但用户量过于庞大,也导致部分用户认为,无法在Facebook上找到真正的朋友。正是出于这种思路,Treehouse希望成为替代Facebook的社交网站,其服务模式是:向真正能成为好友的用户群提供各类服务。但接下来的问题是:如果Treehouse用户量迅速增长,则它同样也会陷入用户量过多的怪圈。

6、商务人士微型博客服务Yammer

Yammer主要向商务和职场人士提供微型博客服务,因此可视为“商务版Twitter”。Yammer用户可发布各类信息更新,以同其他职场人士加强沟通交流。

7、维基百科(Wikipedia)

维基百科的运营机构维基媒体基金会(Wikimedia Foundation)成立于2003年,因此维基百科算不上是社交媒体新秀。但该基金会今年3月底宣布,将对维基百科进行改版。其大致思路是:简化导航系统,提高页面的易用性,使用户编辑相应词条过程更为容易。换句话说,维基百科将引入更多社交网络的元素。

此前有报道称,由于担心义务编辑人员和词条编撰者数量的下降,维基媒体基金会决定通过改版措施,以吸引更多网民参与维基百科词条的编辑工作。改版措施涉及维基百科的导航系统、编辑工具、添加链接、搜索功能及数字图书创建器等等。

8、交通信息社交服务Waze

Waze主要向驾车出行的人群提供交通流量等信息,用户可通过手机向Waze发送各类交通信息,并与好友共享。

9、随机视频聊天网站ChatRoulette

今年初有媒体报道称,17岁俄罗斯高中生安德烈·特诺夫斯基(Andrey Ternovskiy)因创建随机视频聊天网站Chatroulette而走红网络。据悉,Chatroulette提供的服务十分简单:为电脑带有摄像头的用户随机配对,使用户与全球范围内从未谋面的陌生人进行视频对话。

虽然Chatroulette的服务模式非常简单,但该网站的流量一直呈增长之势,原因就是网民喜欢与陌生人进行视频聊天。

10、Facebook游戏浓缩版Cow Clicker

Cow Clicker是模仿Facebook网站上各类社交游戏基本玩法的游戏,该游戏由一名外部开发者所编写,最初目的是为了嘲讽Facebook网站上的各类社交游戏。

以上就是关于sklearn API 参数解析 —— CART全部的内容,包括:sklearn API 参数解析 —— CART、java api混排算法、java如何获取随机数等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/web/9636463.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-30
下一篇2023-04-30

发表评论

登录后才能评论

评论列表(0条)

    保存