ProblemCharacteristics

Struct ProblemCharacteristics 

Source
pub struct ProblemCharacteristics {
    pub n_samples: usize,
    pub n_features: usize,
    pub n_classes: usize,
    pub dimensionality_ratio: f64,
    pub sparsity: f64,
    pub condition_number: f64,
    pub class_imbalance: f64,
    pub task_type: TaskType,
    pub domain: ProblemDomain,
}
Expand description

Problem characteristics extracted from dataset and task definition

Fields§

§n_samples: usize

Number of samples in the dataset

§n_features: usize

Number of features per sample

§n_classes: usize

Number of classes (for classification) or 1 (for regression)

§dimensionality_ratio: f64

Dimensionality ratio (features/samples)

§sparsity: f64

Data sparsity (fraction of zero elements)

§condition_number: f64

Feature correlation matrix condition number

§class_imbalance: f64

Class imbalance ratio (max_class_count / min_class_count)

§task_type: TaskType

Task type

§domain: ProblemDomain

Problem domain

Implementations§

Source§

impl ProblemCharacteristics

Source

pub fn from_dataset(x: &Array2<f64>, y: &Array1<usize>) -> Self

Extract problem characteristics from dataset

Examples found in repository?
examples/hybrid_automl_demo.rs (line 42)
24fn main() {
25    println!("\n╔══════════════════════════════════════════════════════════╗");
26    println!("║  Quantum-Classical Hybrid AutoML Decision Engine        ║");
27    println!("║  Intelligent Algorithm Selection & Configuration        ║");
28    println!("╚══════════════════════════════════════════════════════════╝\n");
29
30    // Create the AutoML engine
31    let engine = HybridAutoMLEngine::new();
32
33    // ========================================================================
34    // Scenario 1: Small Dataset - Drug Discovery
35    // ========================================================================
36
37    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
38    println!("Scenario 1: Small High-Dimensional Dataset (Drug Discovery)");
39    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
40
41    let small_dataset = generate_synthetic_dataset(200, 50, 2);
42    let mut chars1 = ProblemCharacteristics::from_dataset(&small_dataset.0, &small_dataset.1);
43    chars1.domain = ProblemDomain::DrugDiscovery;
44
45    println!("Problem Characteristics:");
46    println!("  Samples: {}", chars1.n_samples);
47    println!("  Features: {}", chars1.n_features);
48    println!("  Classes: {}", chars1.n_classes);
49    println!("  Dimensionality ratio: {:.3}", chars1.dimensionality_ratio);
50    println!("  Sparsity: {:.2}%", chars1.sparsity * 100.0);
51    println!("  Class imbalance: {:.2}", chars1.class_imbalance);
52    println!("  Domain: {:?}\n", chars1.domain);
53
54    let constraints1 = create_quantum_available_constraints();
55
56    match engine.analyze_and_recommend(&chars1, &constraints1) {
57        Ok(recommendation) => {
58            print_recommendation(&recommendation, "Scenario 1");
59        }
60        Err(e) => println!("Error: {e}"),
61    }
62
63    // ========================================================================
64    // Scenario 2: Large Dataset - Finance
65    // ========================================================================
66
67    println!("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
68    println!("Scenario 2: Large Low-Dimensional Dataset (Finance)");
69    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
70
71    let large_dataset = generate_synthetic_dataset(10000, 15, 2);
72    let mut chars2 = ProblemCharacteristics::from_dataset(&large_dataset.0, &large_dataset.1);
73    chars2.domain = ProblemDomain::Finance;
74
75    println!("Problem Characteristics:");
76    println!("  Samples: {}", chars2.n_samples);
77    println!("  Features: {}", chars2.n_features);
78    println!("  Classes: {}", chars2.n_classes);
79    println!("  Dimensionality ratio: {:.3}", chars2.dimensionality_ratio);
80    println!("  Sparsity: {:.2}%", chars2.sparsity * 100.0);
81    println!("  Class imbalance: {:.2}", chars2.class_imbalance);
82    println!("  Domain: {:?}\n", chars2.domain);
83
84    let constraints2 = create_quantum_available_constraints();
85
86    match engine.analyze_and_recommend(&chars2, &constraints2) {
87        Ok(recommendation) => {
88            print_recommendation(&recommendation, "Scenario 2");
89        }
90        Err(e) => println!("Error: {e}"),
91    }
92
93    // ========================================================================
94    // Scenario 3: Multi-class Classification - Computer Vision
95    // ========================================================================
96
97    println!("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
98    println!("Scenario 3: Multi-class Classification (Computer Vision)");
99    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
100
101    let multiclass_dataset = generate_synthetic_dataset(5000, 784, 10);
102    let mut chars3 =
103        ProblemCharacteristics::from_dataset(&multiclass_dataset.0, &multiclass_dataset.1);
104    chars3.domain = ProblemDomain::ComputerVision;
105
106    println!("Problem Characteristics:");
107    println!("  Samples: {}", chars3.n_samples);
108    println!("  Features: {} (28×28 images)", chars3.n_features);
109    println!("  Classes: {}", chars3.n_classes);
110    println!("  Dimensionality ratio: {:.3}", chars3.dimensionality_ratio);
111    println!("  Sparsity: {:.2}%", chars3.sparsity * 100.0);
112    println!("  Class imbalance: {:.2}", chars3.class_imbalance);
113    println!("  Domain: {:?}\n", chars3.domain);
114
115    let constraints3 = create_classical_only_constraints();
116
117    match engine.analyze_and_recommend(&chars3, &constraints3) {
118        Ok(recommendation) => {
119            print_recommendation(&recommendation, "Scenario 3");
120        }
121        Err(e) => println!("Error: {e}"),
122    }
123
124    // ========================================================================
125    // Scenario 4: Constrained Resources - Edge Computing
126    // ========================================================================
127
128    println!("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
129    println!("Scenario 4: Resource-Constrained Environment (Edge Device)");
130    println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
131
132    let edge_dataset = generate_synthetic_dataset(1000, 30, 2);
133    let mut chars4 = ProblemCharacteristics::from_dataset(&edge_dataset.0, &edge_dataset.1);
134    chars4.domain = ProblemDomain::General;
135
136    println!("Problem Characteristics:");
137    println!("  Samples: {}", chars4.n_samples);
138    println!("  Features: {}", chars4.n_features);
139    println!("  Classes: {}", chars4.n_classes);
140    println!("  Dimensionality ratio: {:.3}", chars4.dimensionality_ratio);
141    println!("  Domain: {:?}\n", chars4.domain);
142
143    let constraints4 = create_edge_device_constraints();
144
145    println!("Resource Constraints:");
146    println!("  Max latency: 10ms");
147    println!("  Max cost per inference: $0.0001");
148    println!("  Max training time: 60s");
149    println!("  Power limit: 10W\n");
150
151    match engine.analyze_and_recommend(&chars4, &constraints4) {
152        Ok(recommendation) => {
153            print_recommendation(&recommendation, "Scenario 4");
154        }
155        Err(e) => println!("Error: {e}"),
156    }
157
158    // ========================================================================
159    // Comparison Summary
160    // ========================================================================
161
162    println!("\n\n╔══════════════════════════════════════════════════════════╗");
163    println!("║  Decision Summary Across Scenarios                      ║");
164    println!("╚══════════════════════════════════════════════════════════╝\n");
165
166    println!("┌─────────────┬────────────────────┬──────────────────────────┐");
167    println!("│ Scenario    │ Recommended        │ Reasoning                │");
168    println!("├─────────────┼────────────────────┼──────────────────────────┤");
169    println!("│ 1. Drug     │ Quantum (QSVM)     │ High-dim, small sample  │");
170    println!("│ Discovery   │                    │ Quantum kernel advantage │");
171    println!("├─────────────┼────────────────────┼──────────────────────────┤");
172    println!("│ 2. Finance  │ Classical (XGBoost)│ Large sample, low-dim    │");
173    println!("│             │                    │ Classical more efficient │");
174    println!("├─────────────┼────────────────────┼──────────────────────────┤");
175    println!("│ 3. Vision   │ Classical (CNN)    │ Many samples, no quantum │");
176    println!("│             │                    │ devices available        │");
177    println!("├─────────────┼────────────────────┼──────────────────────────┤");
178    println!("│ 4. Edge     │ Classical (RF)     │ Latency & power          │");
179    println!("│ Device      │                    │ constraints critical     │");
180    println!("└─────────────┴────────────────────┴──────────────────────────┘");
181
182    println!("\n\n╔══════════════════════════════════════════════════════════╗");
183    println!("║  Key Insights                                            ║");
184    println!("╚══════════════════════════════════════════════════════════╝\n");
185
186    println!("1. 🔬 Quantum Advantages:");
187    println!("   • High-dimensional feature spaces (features >> samples)");
188    println!("   • Complex kernel functions (non-linear separability)");
189    println!("   • Small to medium datasets (< 10,000 samples)");
190    println!("   • Domain-specific problems (chemistry, materials)");
191
192    println!("\n2. ⚡ Classical Advantages:");
193    println!("   • Large datasets (> 10,000 samples)");
194    println!("   • Low-dimensional feature spaces");
195    println!("   • Strict latency requirements (< 10ms)");
196    println!("   • Cost-sensitive applications");
197
198    println!("\n3. 🤝 Hybrid Approaches:");
199    println!("   • Quantum feature engineering + classical training");
200    println!("   • Ensemble methods combining both paradigms");
201    println!("   • Quantum-enhanced hyperparameter optimization");
202
203    println!("\n4. 💡 Production Considerations:");
204    println!("   • Always include probability calibration");
205    println!("   • Monitor performance drift over time");
206    println!("   • Have classical fallback for quantum unavailability");
207    println!("   • Optimize batch sizes for throughput");
208    println!("   • Enable caching for repeated inference patterns");
209
210    println!("\n✨ Hybrid AutoML demonstration complete! ✨\n");
211}

Trait Implementations§

Source§

impl Clone for ProblemCharacteristics

Source§

fn clone(&self) -> ProblemCharacteristics

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ProblemCharacteristics

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V