zenoxygen / bayespam Goto Github PK
View Code? Open in Web Editor NEWA simple bayesian spam classifier written in Rust.
Home Page: https://crates.io/crates/bayespam
License: MIT License
A simple bayesian spam classifier written in Rust.
Home Page: https://crates.io/crates/bayespam
License: MIT License
Hi there, awesome create! Trained on some ~18k messages and works really well.
extern crate bayespam;
extern crate csv;
extern crate serde;
use bayespam::classifier::Classifier;
use serde::Deserialize;
use std::fs::File;
#[derive(Debug, Deserialize)]
struct Message {
message: String,
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
let file_path = "my_super_model.json";
// Create a new classifier with an empty model
let mut classifier = Classifier::new(file_path, true);
...
// Serialize the model and save it as JSON into a file
classifier.save(file_path);
Ok(())
}
In this example I'm training a new model:
Classifier::new(file_path, true)
classifier.save(file_path)
I didn't look too closely, but wouldn't something like this be enough:
Classifier::new(file_path)
<- default to new modelclassifier.save()
<- no need to supply pathIf I have time, I'll provide a PR.
Consider using Unicode-Segmentation crates split_at_word_bounds
function to break up into unicode words in your load_word_list
function.
Would it be possible (and a good idea?) to change the required File type to Reader here?
pub fn new_from_pre_trained(file: &mut File) -> Result<Self, io::Error> {
So something like this can be performed:
let faux_model_file = include_str!("./perform_contact_spam_filter_model.json");
let classifier = Classifier::new_from_pre_trained(&mut std::io::Cursor::new(faux_model_file)).expect("Failed to load spam filter model");
Without the need to touch the file system?
It seems like it should take something more like a &str, and then the user is responsible for however that &str gets to the function.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.