pub struct Options {
pub exponent_coefficient: f64,
pub angle_coefficient: f64,
pub num_lockon: usize,
pub samples_per_rotation: f64,
pub range: Range<f64>,
pub turns: f64,
}
regression
only.Expand description
Options for the spiral.
This also implements most estimator traits.
These all use the manhattan distance as their fitness function.
The estimators have O(n)
runtime performance and O(1)
size performance.
Polynomial estimator only supports degrees 1 & 2.
See module-level documentation for more info about concepts.
The
Self::range
limit samples on the spiral. This causes a upper limit for coefficients and a lower “precision” cutoff. You can increaseSelf::exponent_coefficient
if you know your data will have large numbers. The algorithm will increase the size of the spiral of a line outside the spiral is found.
Use a graphing tool (e.g. Desmos) and plot r=ae^(kθ)
.
a is Self::exponent_coefficient
.
k is Self::angle_coefficient
.
To keep the same “size” of the spiral, you have to multiply both ends of Self::range
with the factor of Self::angle_coefficient
.
§Performance
The methods are O(1)*O(fitness_function)
where O(fitness_function)
is the time
complexity of your fitness_function
. That’s often O(n)
as you’d probably in some way
sum up the points relative to the model.
The following options affect the performance as follows (roughly, no coefficients)
O(num_lockon * samples_per_rotation * range.length)
.
Keep in mind you should probably not lower Self::angle_coefficient
bellow 0.15
if you don’t increase the Self::range
.
Fields§
§exponent_coefficient: f64
The initial scale of the spiral.
This gets adjusted when locking on.
angle_coefficient: f64
The “density” of the spiral.
num_lockon: usize
How many lockons we are allowed to do. This is a max value.
samples_per_rotation: f64
The count of samples per each rotation in the spiral.
range: Range<f64>
The range of angles to test.
turns: f64
The turns of the 3d spiral when using three_variable_optimization
.
Frequency of turns per sphere. Is unnecessary to turn up when
Self::samples_per_rotation
is low.
Implementations§
source§impl Options
impl Options
sourcepub fn new(level: u8) -> Self
pub fn new(level: u8) -> Self
Create a new set of options with good defaults.
level
is allowed to be in the range [1..=9].
Higher values are more “precise” - they take longer but are also way
(especially level>4
) more likely to return good results.
Expect a 2-4x increase in runtime per increment of level
.
§Panics
Panics if !(1..=9).contains(level)
.
Trait Implementations§
source§impl CosecantEstimator for Options
impl CosecantEstimator for Options
source§fn model_cosecant(
&self,
predictors: &[f64],
outcomes: &[f64],
max_frequency: f64,
) -> CosecantCoefficients
fn model_cosecant( &self, predictors: &[f64], outcomes: &[f64], max_frequency: f64, ) -> CosecantCoefficients
source§fn boxed_cosecant(self) -> Box<dyn CosecantEstimator>where
Self: Sized + 'static,
fn boxed_cosecant(self) -> Box<dyn CosecantEstimator>where
Self: Sized + 'static,
source§impl CosineEstimator for Options
impl CosineEstimator for Options
source§fn model_cosine(
&self,
predictors: &[f64],
outcomes: &[f64],
max_frequency: f64,
) -> CosineCoefficients
fn model_cosine( &self, predictors: &[f64], outcomes: &[f64], max_frequency: f64, ) -> CosineCoefficients
source§fn boxed_cosine(self) -> Box<dyn CosineEstimator>where
Self: Sized + 'static,
fn boxed_cosine(self) -> Box<dyn CosineEstimator>where
Self: Sized + 'static,
source§impl CotangentEstimator for Options
impl CotangentEstimator for Options
source§fn model_cotangent(
&self,
predictors: &[f64],
outcomes: &[f64],
max_frequency: f64,
) -> CotangentCoefficients
fn model_cotangent( &self, predictors: &[f64], outcomes: &[f64], max_frequency: f64, ) -> CotangentCoefficients
source§fn boxed_cotangent(self) -> Box<dyn CotangentEstimator>where
Self: Sized + 'static,
fn boxed_cotangent(self) -> Box<dyn CotangentEstimator>where
Self: Sized + 'static,
source§impl ExponentialEstimator for Options
impl ExponentialEstimator for Options
source§fn model_exponential(
&self,
predictors: &[f64],
outcomes: &[f64],
) -> ExponentialCoefficients
fn model_exponential( &self, predictors: &[f64], outcomes: &[f64], ) -> ExponentialCoefficients
source§fn boxed_exponential(self) -> Box<dyn ExponentialEstimator>where
Self: Sized + 'static,
fn boxed_exponential(self) -> Box<dyn ExponentialEstimator>where
Self: Sized + 'static,
source§impl LinearEstimator for Options
impl LinearEstimator for Options
source§fn model_linear(
&self,
predictors: &[f64],
outcomes: &[f64],
) -> LinearCoefficients
fn model_linear( &self, predictors: &[f64], outcomes: &[f64], ) -> LinearCoefficients
source§fn boxed_linear(self) -> Box<dyn LinearEstimator>where
Self: Sized + 'static,
fn boxed_linear(self) -> Box<dyn LinearEstimator>where
Self: Sized + 'static,
source§impl LogisticEstimator for Options
impl LogisticEstimator for Options
source§fn model_logistic(
&self,
predictors: &[f64],
outcomes: &[f64],
) -> LogisticCoefficients
fn model_logistic( &self, predictors: &[f64], outcomes: &[f64], ) -> LogisticCoefficients
source§fn boxed_logistic(self) -> Box<dyn LogisticEstimator>where
Self: Sized + 'static,
fn boxed_logistic(self) -> Box<dyn LogisticEstimator>where
Self: Sized + 'static,
source§impl PolynomialEstimator for Options
impl PolynomialEstimator for Options
source§fn model_polynomial(
&self,
predictors: &[f64],
outcomes: &[f64],
degree: usize,
) -> PolynomialCoefficients
fn model_polynomial( &self, predictors: &[f64], outcomes: &[f64], degree: usize, ) -> PolynomialCoefficients
PolynomialCoefficients
from predictors
and outcomes
.
Also takes a degree
of the target polynomial. Some estimators may panic when degree
is out of their range. Read moresource§fn boxed_polynomial(self) -> Box<dyn PolynomialEstimator>where
Self: Sized + 'static,
fn boxed_polynomial(self) -> Box<dyn PolynomialEstimator>where
Self: Sized + 'static,
source§impl PowerEstimator for Options
impl PowerEstimator for Options
source§fn model_power(&self, predictors: &[f64], outcomes: &[f64]) -> PowerCoefficients
fn model_power(&self, predictors: &[f64], outcomes: &[f64]) -> PowerCoefficients
source§fn boxed_power(self) -> Box<dyn PowerEstimator>where
Self: Sized + 'static,
fn boxed_power(self) -> Box<dyn PowerEstimator>where
Self: Sized + 'static,
source§impl SecantEstimator for Options
impl SecantEstimator for Options
source§fn model_secant(
&self,
predictors: &[f64],
outcomes: &[f64],
max_frequency: f64,
) -> SecantCoefficients
fn model_secant( &self, predictors: &[f64], outcomes: &[f64], max_frequency: f64, ) -> SecantCoefficients
source§fn boxed_sesecant(self) -> Box<dyn SecantEstimator>where
Self: Sized + 'static,
fn boxed_sesecant(self) -> Box<dyn SecantEstimator>where
Self: Sized + 'static,
source§impl SineEstimator for Options
impl SineEstimator for Options
source§fn model_sine(
&self,
predictors: &[f64],
outcomes: &[f64],
max_frequency: f64,
) -> SineCoefficients
fn model_sine( &self, predictors: &[f64], outcomes: &[f64], max_frequency: f64, ) -> SineCoefficients
source§fn boxed_sine(self) -> Box<dyn SineEstimator>where
Self: Sized + 'static,
fn boxed_sine(self) -> Box<dyn SineEstimator>where
Self: Sized + 'static,
source§impl TangentEstimator for Options
impl TangentEstimator for Options
source§fn model_tangent(
&self,
predictors: &[f64],
outcomes: &[f64],
max_frequency: f64,
) -> TangentCoefficients
fn model_tangent( &self, predictors: &[f64], outcomes: &[f64], max_frequency: f64, ) -> TangentCoefficients
source§fn boxed_tangent(self) -> Box<dyn TangentEstimator>where
Self: Sized + 'static,
fn boxed_tangent(self) -> Box<dyn TangentEstimator>where
Self: Sized + 'static,
impl StructuralPartialEq for Options
Auto Trait Implementations§
impl Freeze for Options
impl RefUnwindSafe for Options
impl Send for Options
impl Sync for Options
impl Unpin for Options
impl UnwindSafe for Options
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.