0
$\begingroup$

As it can be seen in the following piece of code, i would like to display more outputs which are inside a Module, part of a function definition. In turn this is inside a Which construct. The idea is to display besides the Show output, some PredictorMeasurementsoutputs and another line with a text output. I tried with a combination of GraphicsColumn and Row, but when doing so only a part of the Show graphical output is visible. Do you know how i can display multiple objects inside this construct, having them displayed in the correct dimensions ?

Manipulate[ (* instructions *)
Module[ (* instructions *)
Which[ (* instructions *)
flag == 6,
(*Row[{Style[Text["Predict still under \
construction"],14,Large,Bold,Red]}]*)
Pane[
 data0 = data2[[All, {xinput, youtput}]];
 (*datacombtrans=Transpose[data0];*)
 datathread = Thread[data0[[All, 1]] -> data0[[All, 2]]];
 
 visualizePrediction[data_, method_] := 
  Module[{p, predictionplot, dataplot, xs},
   dataplot = 
    ListPlot[Tooltip[List @@@ data], PlotStyle -> Red, 
     PlotLegends -> {Which[youtput == 1, label1, youtput == 2, label2,
         youtput == 3, label3, youtput == 4, label4, youtput == 5, 
        label5, youtput == 6, label6, youtput == 7, label7]}];
   xs = data[[All, 1]];
   p = Predict[data, Method -> method];
   predictionplot = 
    Plot[{p[x], p[x] + StandardDeviation[p[x, "Distribution"]], 
      p[x] - StandardDeviation[p[x, "Distribution"]]}, {x, 
      Min[xs] - 1, Max[xs] + 1}, PlotStyle -> {Black, Gray, Gray}, 
     Filling -> {2 -> {3}}, Exclusions -> False, 
     PerformanceGoal -> "Speed", 
     PlotLegends -> {"Prediction", "Confidence Interval"}];
   
   Show[predictionplot, dataplot, 
    PlotLabel -> 
     Style[Which[youtput == 1, label1, youtput == 2, label2, 
        youtput == 3, label3, youtput == 4, label4, youtput == 5, 
        label5, youtput == 6, label6, youtput == 7, label7] <> 
       " regression with " <> method, 14, Bold, Black],
    AxesLabel -> {Style[labelindex, 12, Bold, Black], 
      Style[Which[youtput == 1, label1, youtput == 2, label2, 
        youtput == 3, label3, youtput == 4, label4, youtput == 5, 
        label5, youtput == 6, label6, youtput == 7, label7], 12, Bold,
        Black]},
    ImageSize -> Large]   
        
   (*pm1=PredictorMeasurements[p,data,{"ComparisonPlot",
   "ResidualPlot","ResidualHistogram","StandardDeviation"}]*)
   
   (*,Row[{ Text[Style["Prediction at point 1000 is equal to " p[
   1000],12,Bold]]},ImageSize\[Rule]Large]*)
   ];
 
 visualizePrediction[datathread, "GradientBoostedTrees"]
 
 (*Grid[Partition[visualizePrediction[datathread,#][[1,1]]&/@{\
"LinearRegression","NearestNeighbors","RandomForest","DecisionTree"},\
2],Frame\[Rule]All,FrameStyle\[Rule]LightGray]*)
 
 ],
]
]
]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.