0

我是 DEAP 的新手,我想将我的染色体表示为一组将由 SVM 分类器测试的特征,我现在的问题是如何在染色体中表示我的 35 个特征

4

1 回答 1

1

请找到这个 Deap 文档的链接。您将在此处找到示例: https ://deap.readthedocs.io/en/master/examples/index.html

您还可以在这里找到人口的表示方法。

https://deap.readthedocs.io/en/master/tutorials/basic/part1.html

import random

from deap import base
from deap import creator
from deap import tools

creator.create("FitnessMax", base.Fitness, weights=(1.0,))
creator.create("Individual", list, fitness=creator.FitnessMax)
toolbox = base.Toolbox()

# Attribute generator
#                      define 'attr_bool' to be an attribute ('gene')
#                      which corresponds to integers sampled uniformly
#                      from the range [0,1] (i.e. 0 or 1 with equal
#                      probability)
toolbox.register("attr_bool", random.randint, 0, 1)

# Structure initializers
#                         define 'individual' to be an individual
#                         consisting of 100 'attr_bool' elements ('genes')
toolbox.register("individual", tools.initRepeat, creator.Individual,
toolbox.attr_bool, 100)

# define the population to be a list of individuals
toolbox.register("population", tools.initRepeat, list, toolbox.individual)
于 2018-03-01T11:14:58.907 回答