Code Monkey home page Code Monkey logo

bayespam's People

Contributors

hellow554 avatar zenoxygen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

bayespam's Issues

Docs Outdated & Classifier oddity

Hi there, awesome create! Trained on some ~18k messages and works really well.

  • Docs are outdated: Not a real issue, but yeah
  • Usage of the classifier is a bit verbose
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:

  1. I supply a file-path, and indicate this is a new model Classifier::new(file_path, true)
  2. Then I supply the same file-path, to save the model classifier.save(file_path)

I didn't look too closely, but wouldn't something like this be enough:

  1. Classifier::new(file_path) <- default to new model
  2. classifier.save() <- no need to supply path

If I have time, I'll provide a PR.

Reader instead of File

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.