2 releases

0.1.1 Jan 18, 2023
0.1.0 Jan 18, 2023

#500 in Machine learning

MIT license

84KB
1.5K SLoC

profqu_neat

A crate that implements the NEAT algorithm Created according to a tutorial from Finn Eggers. I tried to implement NEAT from the official github repository, but I couldn't figure out how to do it, so I used Finn's implementation.

Then I looked on Youtube and found Finn Eggers and his tutorial really helped me with creating this library.

Doesn't allow recurrent connections in the networks.

Examples

use profqu_neat::Neat;

// Load config and create new Neat
Neat::load_config_from_file("src/config.txt");
let mut neat = Neat::new(10, 1, 1000);

// Create inputs
let input: Vec<f32> = vec![rand::random(); 10];

// Try to evolve the clients
for _iteration in 0..200 {
    for mut client in neat.iter_clients() {
        let fitness = client.calculate(&input)[0];
        client.fitness = fitness;
    }
    neat.evolve();
}

/// Get the best client
let best = neat.best_client().expect("Failed to get client");

/// Print all the data
neat.print_species();
println!("Best: {best:?}");

assert!(best.fitness > 0.8);

Dependencies

~355KB