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

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