A "Best of the Best Practices" (BOBP) guide to developing in Python.
- "Build tools for others that you want to be built for you." - Kenneth Reitz
- "Simplicity is alway better than functionality." - Pieter Hintjens
| // train split | |
| let (x_train, x_test, y_train, y_test) = train_test_split(&xmatrix.unwrap(), &y, 0.3, true); | |
| // model | |
| let linear_regression = LinearRegression::fit(&x_train, &y_train, Default::default()).unwrap(); | |
| // predictions | |
| let preds = linear_regression.predict(&x_test).unwrap(); | |
| // metrics | |
| let mse = mean_squared_error(&y_test, &preds); | |
| println!("MSE: {:?}", mse); |
| let target_array = target.unwrap().to_ndarray::<Float64Type>().unwrap(); | |
| // create a vec type and populate with y values | |
| let mut y: Vec<f64> = Vec::new(); | |
| for val in target_array.iter(){ | |
| y.push(*val); | |
| } |
| let target_array = target.unwrap().to_ndarray::<Float64Type>().unwrap(); | |
| // create a vec type and populate with y values | |
| let mut y: Vec<f64> = Vec::new(); | |
| for val in target_array.iter(){ | |
| y.push(*val); | |
| } |
| pub fn convert_features_to_matrix(in_df: &DataFrame) -> Result<DenseMatrix<f64>>{ | |
| /* function to convert feature dataframe to a DenseMatrix, readable by smartcore*/ | |
| let nrows = in_df.height(); | |
| let ncols = in_df.width(); | |
| // convert to array | |
| let features_res = in_df.to_ndarray::<Float64Type>().unwrap(); | |
| // create a zero matrix and populate with features | |
| let mut Xmatrix: DenseMatrix<f64> = BaseMatrix::zeros(nrows, ncols); | |
| // populate the matrix |
| { "@context": { | |
| "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#", | |
| "rdfs": "http://www.w3.org/2000/01/rdf-schema#", | |
| "owl": "http://www.w3.org/2002/07/owl#", | |
| "express": "http://example.com/express#", | |
| "defines": { | |
| "@reverse": "rdfs:isDefinedBy" | |
| }, | |
| "propertyOf": { | |
| "@id": "rdfs:domain", |
| #include <stdio.h> | |
| #include <assert.h> | |
| #include <msgpack.h> | |
| typedef struct some_struct { | |
| uint32_t a; | |
| uint32_t b; | |
| float c; | |
| } some_struct; |