Ivane,为了正确地将 GA 应用于文档分类:
- 您必须将问题简化为可以进化的组件系统。
- 您不能对单个文档进行文档分类的 GA 训练。
所以你描述的步骤是正确的,但我会给你一些改进:
- 拥有足够数量的训练数据:您需要一组已经分类且足够多样化的文档,以涵盖您可能遇到的文档范围。
- 训练您的 GA 以正确分类这些文档的子集,即训练数据集。
- 在每一代,根据验证数据集测试您最好的样本,如果验证准确度开始下降,则停止训练。
所以你想做的是:
prevValidationFitness = default;
currentValidationFitness = default;
bestGA = default;
while(currentValidationFitness.IsBetterThan( prevValidationFitness ) )
{
    prevValidationFitness = currentValidationFitness;
    // Randomly generate a population of GAs
    population[] = randomlyGenerateGAs();
    // Train your population on the training data set
    bestGA = Train(population);
    // Get the validation fitness fitness of the best GA 
    currentValidationFitness = Validate(bestGA);
    // Make your selection (i.e. half of the population, roulette wheel selection, or random selection)
    selection[] = makeSelection(population);
    // Mate the specimens in the selection (each mating involves a crossover and possibly a mutation)
    population = mate(selection);
}
每当您获得一份新文档(以前未分类的文档)时,您现在可以使用您最好的 GA 对其进行分类:
category = bestGA.Classify(document);
所以这不是万能的解决方案,但它应该给你一个不错的开始。波兹德拉维,基里尔