Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make SVC multiclass #224

Open
1 task done
Mec-iS opened this issue Nov 3, 2022 · 0 comments
Open
1 task done

Make SVC multiclass #224

Mec-iS opened this issue Nov 3, 2022 · 0 comments
Labels
good first issue Good for newcomers
Milestone

Comments

@Mec-iS
Copy link
Collaborator

Mec-iS commented Nov 3, 2022

I'm submitting a

  • feature request.

Current Behaviour:

smartcore::svm::svc only works with 2 classes [-1, 1]

Expected Behaviour:

we should support n number of classes. Use Iris dataset as example. See this intro blogpost

        use crate::dataset::iris::load_dataset as iris_load;

        // Load Iris dataset
        let iris_dataset = iris_load();

        // Turn Iris dataset into NxM matrix
        // Input data
        let x: DenseMatrix<f32> = DenseMatrix::new(
            iris_dataset.num_samples,      // num rows
            iris_dataset.num_features,     // num columns
            iris_dataset.data,             // data as Vec
            false,                         // column_major
        );
        // These are our target class labels
        let y: Vec<u32> = iris_dataset.target;

        let y_hat = SVC::fit(
            &x,
            &y,
            &SVCParameters::default()
                .with_c(1.0)
                .with_kernel(&Kernels::rbf().with_gamma(0.7)),
        )
        .and_then(|lr| lr.predict(&x))
        .unwrap();

        println!("{:?}", &y_hat);
@Mec-iS Mec-iS added the good first issue Good for newcomers label Nov 3, 2022
@Mec-iS Mec-iS added this to the v0.5 milestone Nov 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant