rust
This commit is contained in:
commit
ef79c30e8c
|
|
@ -0,0 +1 @@
|
|||
/target
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,12 @@
|
|||
[package]
|
||||
name = "barclays"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
lazy_static = "1.4.0"
|
||||
ndarray = "0.15.6"
|
||||
polars = { version = "0.38.3", features = ["ndarray"] }
|
||||
smartcore = { version = "0.3.2", features = ["ndarray-bindings"] }
|
||||
|
|
@ -0,0 +1 @@
|
|||
pub mod model;
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
pub mod preprocessing;
|
||||
|
||||
use std::collections::HashMap;
|
||||
use lazy_static::lazy_static;
|
||||
use polars::prelude::*;
|
||||
use smartcore::linalg::basic::matrix::DenseMatrix;
|
||||
|
||||
lazy_static! {
|
||||
static ref CATEGORICAL_COLUMNS: Vec<&'static str> = vec![
|
||||
"person_home_ownership",
|
||||
"loan_intent",
|
||||
"loan_grade",
|
||||
"cb_person_default_on_file",
|
||||
];
|
||||
|
||||
static ref HOME_OWNERSHIP_VALUES: HashMap<&'static str, u32> = HashMap::from([
|
||||
("RENT", 1),
|
||||
("MORTGAGE", 2),
|
||||
("OWN", 3),
|
||||
("OTHER", 4),
|
||||
]);
|
||||
|
||||
static ref INTENT_VALUES: HashMap<&'static str, u32> = HashMap::from([
|
||||
("EDUCATIONAL", 1),
|
||||
("MEDICAL", 2),
|
||||
("VENTURE", 3),
|
||||
("PERSONAL", 4),
|
||||
("DEBTCONSOLIDATION", 5),
|
||||
]);
|
||||
|
||||
static ref GRADE_VALUES: HashMap<&'static str, u32> = HashMap::from([
|
||||
("A", 1),
|
||||
("B", 2),
|
||||
("C", 3),
|
||||
("D", 4),
|
||||
("E", 5),
|
||||
]);
|
||||
|
||||
static ref DEFAULT_FILE_VALUES: HashMap<&'static str, u32> = HashMap::from([
|
||||
("Y", 1),
|
||||
("N", 2),
|
||||
]);
|
||||
}
|
||||
|
||||
pub fn init_default_predictor() {
|
||||
let data = CsvReader::from_path("credit_risk_dataset.csv")
|
||||
.unwrap()
|
||||
.finish()
|
||||
.unwrap()
|
||||
.to_ndarray::<Float64Type>(IndexOrder::Fortran)
|
||||
.unwrap();
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
use smartcore::{metrics::distance::euclidian::Euclidian, neighbors::knn_regressor::{KNNRegressor, KNNRegressorParameters}};
|
||||
use ndarray::{Array1,Array2};
|
||||
|
||||
pub struct KNNImputer {
|
||||
model: KNNRegressor<f64,f64,Array2<f64>,Array1<f64>,Euclidian<f64>>
|
||||
}
|
||||
|
||||
impl KNNImputer {
|
||||
pub fn new(dataframe: ndarray::Array2<f64>, target_column: usize) -> Self {
|
||||
let true_values: Array1<f64> = dataframe.column(target_column).to_vec().into();
|
||||
KNNImputer {
|
||||
model: KNNRegressor::fit(&dataframe, &true_values.into(), Default::default()).unwrap(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn impute(&self) -> bool {
|
||||
//TODO: Predict value,
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue