遗传编程 - 适应度函数

发布于 2024-11-01 17:24:11 字数 370 浏览 1 评论 0原文

假设我有一组训练示例,其中 A_i 是一个属性,结果是二进制的(是或否):

A1,             A2,             A3,             Outcome
red             dark            large           yes
green           dark            small           yes
orange          bright          large           no

我知道我必须定义适应度函数。但这个问题到底是为了什么?在我的实际问题中,有 10 个参数和 100 个训练示例,但这是一个类似的问题。

Let's say I have a set of training examples where A_i is an attribute and the outcome is binary (yes or no):

A1,             A2,             A3,             Outcome
red             dark            large           yes
green           dark            small           yes
orange          bright          large           no

I know I have to define the fitness function. But what is it for this problem? In my actual problem there are 10 parameters and 100 training examples but this is a similar problem.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

北凤男飞 2024-11-08 17:24:11

我认为这里的困惑来自于这样一个事实:通常适应度函数会返回一些标量,有时是离散的标量,但从来不会是二进制的是/否(或真/假)。从这个意义上说,这看起来更像是用神经网络(或可能是贝叶斯逻辑)解决的“分类”问题。话虽如此,你当然可以设计一个遗传算法来进化任何类型的分类器,并且适应度函数基本上可以用总评估的正确分类来表达。

另一种纯粹的遗传算法方法(可能与问题更相关)是将整个分类规则集编码为遗传算法的给定个体。从这个意义上说,适应度函数可以表示为一个标量,表示手头给定的候选解决方案有多少个是/否分类,等等。类似的方法可以在本文中找到:使用实值遗传:进化 R,de 集的算法
分类

示例(编码的可能方法之一):

A1,             A2,             A3,             Outcome
red             dark            large           yes
green           dark            small           yes
orange          bright          large           no

编码:红色 = 000、深色 = 001、大 = 010、绿色 = 011、小 = 100、橙色 = 101、亮 = 111 等。
结果:是 = 1,否 = 0

染色体:

A1,             A2,             A3,             Outcome
000             001             010             1
011             001             100             1
101             111             010             0

以上所有内容都会转化为候选解决方案:

000001010-1/011001100-1/101111010-0

您将生成一组随机的解决方案,并通过测试适应性(规则集中的正确分类/总分类)以您喜欢的方式进化它们)整个规则集(在这里小心选择你的交叉策略!)。

我还建议您听一下二元独奏,让您进入心情。

注意:我非常怀疑这是否适用于仅由 3 条规则组成的规则集,对于 GA 来说不够广度。

I think the confusion here is coming from the fact that usually fitness functions give you back some scalar, sometimes on a discrete scale, but never a binary yes/no (or true/false). In this sense, this looks more like a 'classification' problem to be solved with neural nets (or possibly bayesian logic). Said so, you could certainly devise a GA to evolve whatever kind of classifier, and the fitness function would basically be expressed in terms of correct classifications over total evaluations.

Another pure GA approach to this - probably more relevant to the question - is to encode the whole classification rule set as a given individual for the genetic algorithm. In this sense, the fitness function could be expressed as a scalar representing how many yes/no classifications the given candidate solution at hand gets right over the total, and so forth. A similar approach can be found in this paper Using Real-Valued Genetic: Algorithms to Evolve R,de Sets for
Classification
.

Example (one of the possible ways to encode this):

A1,             A2,             A3,             Outcome
red             dark            large           yes
green           dark            small           yes
orange          bright          large           no

Encoding: red = 000, dark = 001, large = 010, green = 011, small = 100, orange = 101, bright = 111, etc.
Outcome: yes = 1, no = 0

Chromosome:

A1,             A2,             A3,             Outcome
000             001             010             1
011             001             100             1
101             111             010             0

All of the above gets translated into a candidate solution as:

000001010-1/011001100-1/101111010-0

You will generate a random bunch of these and evolve them whichever way you like by testing fitness (correct classification/ total classifications in the ruleset) of the entire rule set (be careful picking your cross-over strategy here!).

I also suggest you listen to a binary solo, to get you in the mood.

NOTE: I highly doubt this would work with a rule-set composed by only 3 rules, not enough breadth for the GA.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文