File tree Expand file tree Collapse file tree
ClassicMachineLearning/PredictIfHouseIsExpensive
QuantumMachineLearning/PredictIfHouseIsExpensive/Host Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11using System ;
2+ using System . Diagnostics ;
23using Microsoft . ML ;
34using Microsoft . ML . Data ;
45
6+ var sw = new Stopwatch ( ) ;
7+ sw . Start ( ) ;
8+
59MLContext mlContext = new MLContext ( ) ;
610
711HouseData [ ] houseData =
4044 . CreatePredictionEngine < HouseData , Prediction > ( model )
4145 . Predict ( validationData ) ;
4246
47+ sw . Stop ( ) ;
48+
4349var size = ( validationData . Size * 1000 ) / 10.76 ;
4450var price = ( validationData . Price * 100_000 ) * 5 ;
4551
4652Console . WriteLine ( $ "Predicted price for size: { size : F2} m2 and price: { price : C2} . Is expensive? { result . IsExpensive } ") ;
53+ Console . WriteLine ( "Elapsed={0}" , sw . Elapsed ) ;
4754
4855public class HouseData
4956{
Original file line number Diff line number Diff line change 22using Microsoft . Quantum . Simulation . Simulators ;
33using PredictIfHouseIsExpensive ;
44using PredictIfHouseIsExpensive . Quantum ;
5+ using System . Diagnostics ;
56using System . Linq ;
67
8+ var sw = new Stopwatch ( ) ;
9+ sw . Start ( ) ;
10+
711HouseData [ ] houseData =
812{
913 new HouseData ( ) { Size = 1.1F , Price = 1.2F , IsExpensive = false } ,
8084 numberOfMeasurements : numberOfMeasurements
8185 ) ;
8286
87+ sw . Stop ( ) ;
88+
8389foreach ( var result in results )
8490{
8591 Console . WriteLine ( $ "Result: { result : F5} .") ;
8692}
8793
94+ Console . WriteLine ( "Elapsed={0}" , sw . Elapsed ) ;
95+
8896public class HouseData
8997{
9098 public bool IsExpensive { get ; set ; }
You can’t perform that action at this time.
0 commit comments