Comments (6)
I don't think CountVectorizer
has serde
support but it should be pretty easy to add. Can you post your code snippet just to be sure?
from linfa.
Sure !
This is the code Im using to "export" a model using ciborium
, this method has worked successfully with linfa-svm .
// In the winequality SVM example after "fiting" the SVM model
let model_value = cbor!(model).unwrap();
let mut vec_model = Vec::new();
let _cebor_writer = ciborium::ser::into_writer(&model_value, &mut vec_model);
//Esporting it to a .cbor file
let path: &Path = Path::new("./model.cbor");
fs::write(path, vec_model).unwrap();
Then, you can import the model and use it, like this :
//Reading the .cbor file and converting it to a ciborium value
let mut file = File::open("./model.cbor").unwrap();
let mut data: Vec<u8> = Vec::new();
file.read_to_end(&mut data).unwrap();
let model_value = ciborium::de::from_reader::<Value, _>(&data[..]).unwrap();
//Creating again the model, but its already trained
let model: Svm<f64, bool> = model_value.deserialized().unwrap();
println!("{}", model);
This really works with ease (with the SVM-model), but the way I find out that a model doesn't support serde serialization is by trying to pass it to the cbor!
macro, when a model does not support serialization, the following error appears:
the trait bound `<MODELNAME>: serde::ser::Serialize` is not satisfied
the following other types implement trait `serde::ser::Serialize`:
&'a T
&'a mut T
()
(T0, T1)
. . .
from linfa.
I just cloned your repository with the addition of serde support, thank you very much!
I tried to test it inside the extra-serde
branch, my test was the same as described in the other comment, I tried to pass the CountVectorizer
through the cbor!
macro but I get the same error:
//In the countvectorization.rs example of linfa-preprocessing (inside the extra-serve branch)
let vectorizer_value = cbor!(vectorizer).unwrap();
But the following error occurs :
the trait bound `CountVectorizer: serde::ser::Serialize` is not satisfied
the following other types implement trait `serde::ser::Serialize`:
&'a T
&'a mut T
()
(T0, T1)
Maybe Im testing it wrong? If so, any other idea on how to test it without merging to the master branch?
from linfa.
Did you enable the serde
feature on the crate?
from linfa.
I just tested with the serde
feature enabled and I asserted that CountVectorizer: Serialize
holds. I'm going to merge the PR into master and you can test it from there.
from linfa.
I just tested adding the serde
to the features in Cargo.toml and it works!
Thanks a lot!
from linfa.
Related Issues (20)
- add tag and github release of version 0.7.0
- Let linfa_linear::LinearRegression support weights from a dataset
- MultiLogisticRegression panics on normalized data.
- umap for dimension reduction HOT 1
- DBSCAN returns core samples HOT 1
- How to do clustering grid search with multiple CPUs / GPUs? HOT 2
- how to save svm model data and resuse it ?
- linfa_bayes show error: records not in row-major layout HOT 1
- get the score from logistic regression prediction
- the order of classification HOT 1
- .
- what is the difference between these libarary and pure rust? HOT 1
- gradient tolerance and alpha
- get loss for each iteration
- linfa_bayes::MultinomialNb,when use predict(), program paniced!
- MeanShift: potential contribution HOT 2
- Support streaming/incremental fitting
- Fix ci HOT 1
- linfa-reduction-0.7.0 Pca<f64> without the method of 'components' and 'mean'
- Intel MKL BLAS backend download error: `linfa` release required
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from linfa.