DARJEELING
Machine learning and data manipulation tools for Rust
Contact
Installation
Add the following to your Cargo.toml file
darjeeling = "0.3.2"
Basic Setup
- Create a network
use ;
let input_num = 2;
let hidden_num = 2;
let answer_num = 2;
let hidden_layers = 1;
let mut net = new;
- Format your data as Inputs
use ;
// Do this for every input
let float_inputs: = vec!;
let answer_input: Types = String;
let input = new;
Inputs represent a set of floating point numbers and which answer node they should be mapped to. For example, if the input is a picture of a Bee, the float_inputs might be the hex value of every pixel, while the answer input might be "Bee". Make sure the answer is always a valid category. 3. Train your network
let learning_rate: f32 = 3.0;
let categories: = categories_str_format;
let data: = data_fmt;
let target_err_percent = 95.0;
match net.learn
If the training is successful, the model_name is returned along with the percent of the training inputs the network correctly categorized on it's last epoch, and the mean squared error of the training. 4. Test your network
// Do whatever you want with this data
match test ;
During testing, the answers in the input data should be set to None. The testing returns a vector of all the categories assigned to the data in the same order as the data.
Examples
Categorization
This program reads from a file containing all possible inputs to a binary logic gate, and all the correct answers.
Then it trains a model with 1 hidden layer. 2 nodes in its input layer, because there are two inputs. 2 Nodes for its output layer because there are two possible answers(the "brighter" one is selected a the chosen answer) And 2 nodes in its hidden layer, because I like patterns.
If this doesn't work, check the tests.ts source code for verified working code.
Hint: Try fiddling with the learning rate you're using if things aren't working properly.
Different problems work differently with different learning rates, although I recommend one of 0.5 to start.
use ;
use ;
use ;
// This isn't very important, this just reads the file you want to and format it as Inputs
Generation
This program doesn't have a large enough dataset to get interesting results. All it does is just create a network and
use ;
// A file with data
// To make sure the networked is properly trained, make sure it follows some sort of pattern
// This is just sample data, for accurate results, around 3800 datapoints are needed
// 1 2 3 4 5 6 7 8
// 3 2 5 4 7 6 1 8
// 0 2 5 4 3 6 1 8
// 7 2 3 4 9 6 1 8
// You also need to write the file input function
// Automatic file reading and formatting function coming soon
let mut data: = file;
let mut net = new;
let learning_rate = 1.0;
let model_name = net.learn.unwrap;
let new_data: = net.test.unwrap;
FAQ
Why is it called Darjeeling?
Because that's the WiFi password at the Tea Shop where I do most of my programming.
Contribution
If you want to contribute, check to todo, fork the code, and make a pull request whenever you're ready. I'm more than open to reviewing any code people want to add. I'd be happy to give any assistance to people wanting to contribute, including but not limited to teaching about Machine Learning, Rust, and how Darjeeling works. We welcome all experience levels here. Just email me if you need anything. If there's a bug that you can't/don't want to fix, open an issue.
Guidelines
- Be respectful of all kinds of people and their differences.
- Be kind.
- Be patient to people of all experience and skill levels.
TODO:
- Add Support for Polars Dataframes
- Optimize
Dataframes are now deprecated