Comments (1)
Thanks to your interests.
Although there is no official support for weight, but you can capture weight vector via closure.
For example, let's do linear regression with additional error term.
- Data :
y = 2*x + 1 + eps_true
- Model :
y_i = w_0 + w_1 * x_i + eps_i
#[macro_use]
extern crate peroxide;
use peroxide::fuga::*;
fn main() {
// Generate Data
let x = seq(1, 10, 1);
let eps_true = rnorm!(10, 0, 1);
let y = x.fmap(|t| 2f64 * t + 1f64).add_v(&eps_true);
let data = cbind(x.into(), y.into());
// Generate Normal error (eps ~ N(0, 1^2))
let eps_guess = rnorm!(10, 0, 1);
// Optimize with new error
let mut opt = Optimizer::new(data, |x, w| linear_regression(x, w, &eps_guess));
let p = opt.set_init_param(c!(1, 1))
.set_max_iter(50)
.set_method(LevenbergMarquardt)
.optimize();
p.print();
opt.get_error().print();
}
// Linear regression with error: y_i = w_0 + w_1 * x_i + epsilon_i
fn linear_regression(x: &Vec<f64>, w: Vec<Number>, epsilon: &Vec<f64>) -> Option<Vec<Number>> {
Some(
x.iter()
.map(|&t| Number::from_f64(t))
.zip(epsilon.iter().map(|&t| Number::from_f64(t)))
.map(|(t, eps)| w[0] + w[1] * t + eps)
.collect()
)
}
Maybe add additional argument can make some confusion. For this reason, it is cautious to accept your good suggestion.
If you have more question or suggestion, then please let me know.
from peroxide.
Related Issues (20)
- Taylor mode automatic differentiation HOT 3
- Uniform random generator behaviour HOT 2
- Add support of root-finding HOT 3
- DataFrame documentation is missing on docs.rs HOT 2
- New general DataFrame
- Native implementation of QR, SVD
- Support Complex number HOT 4
- More Numerical Integrations
- Multivariate Automatic Differentiation
- `quantile` may panic HOT 2
- Optimization after refactoring to AD in 0.30 - example failing HOT 10
- Whole new numerical computations
- Faster polynomial multiplication HOT 3
- Adaptive Differential Equation Solvers HOT 4
- Cholesky decomposition HOT 3
- LM Algorithm: Unbounded lambda HOT 4
- Length bug in `linspace`
- Print in ODE when stop condition is reached HOT 4
- Blas linkage HOT 3
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 peroxide.