Public
Edited
Apr 12, 2023
2 forks
Insert cell
Insert cell
viewof constructionType = Inputs.select(["Steel Frame","Wood Frame","Mass","Metal Building"], {label: "Construction Type"})
Insert cell
viewof infiltrationRate = Inputs.range([1, 1], {step: 1, label: "Infiltration Rate"})
Insert cell
viewof locations = Inputs.select(["office","circulations","atrium"], {label: "Locations"})
Insert cell
viewof grossFloorArea = Inputs.range([0, 255], {step: 1, label: "Gross Floor Area"})
Insert cell
viewof hvac = Inputs.select(["Ideal Air","VAV All Air","Radiant w/ DOAS"], {label: "HVAC System Type"})
Insert cell
viewof heatRecoveryEfficiency = Inputs.range([0, 100], {step: 1, label: "Heat Recovery Efficiency"})
Insert cell
viewof economizer = Inputs.radio(["Yes", "No"], {label: "Economizer"})
Insert cell
viewof ventilation = Inputs.select(["Min Outdoor Air","5X Min","10X Min","VOC Biofilter","Full Biofilter"], {label: "Ventilation Type"})
Insert cell
viewof bioType = Inputs.select(["1 Hot Humid","2 Hot Dry","3 Marine","4 Mixed Humid","5 Mixed Dry","6 Cold","7 Very Cold","8 Subarctic"], {label: "Climate Zone"})
Insert cell
viewof climateZone = Inputs.select(["1 Hot Humid","2 Hot Dry","3 Marine","4 Mixed Humid","5 Mixed Dry","6 Cold","7 Very Cold","8 Subarctic"], {label: "Climate Zone"})
Insert cell
viewof tempSet = Inputs.range([0, 100], {step: 1, label: "Temperature Setpoint"})
Insert cell
viewof bioPower = Inputs.range([0, 100], {step: 1, label: "Biofilter Power"})
Insert cell
viewof metabolicRate = Inputs.range([1, 4], {step: 1, label: "Metabolic Rate"})
Insert cell
viewof occSched = Inputs.radio(["Typical", "Sparse","Dense"], {label: "Occupancy Schedule"})
Insert cell
viewof program = Inputs.select(["Office","Hotel","Apartment","Hospital"], {label: "Program"})
Insert cell
viewof actLvl = Inputs.range([0, 100], {step: 1, label: "Activity Level (Mets)"})
Insert cell
viewof wwRatio = Inputs.range([0, 1], {step: .01, label: "Window to Wall Ratio"})
Insert cell
btn = DOM.download(serialize(textOb), "userSettings", "Save Inputs")
Insert cell
viewof clicks = Inputs.button("Click me")
Insert cell
textOb
Insert cell
viewof infiltrationRate.value
Insert cell
viewof clicks2 = Inputs.button("Set Inputs")
Insert cell
clicks2
Insert cell
viewof name = Inputs.text({placeholder: "File Name"})
Insert cell
name
Insert cell
name1 = []
Insert cell
name1[name1.length-1]
Insert cell
{
if(clicks2>0){
textOb.run
//name.run
name1.push(constructionType)
//name1.length=0
//clicks2.value=0
console.log("click")
}

return textOb[1].value
}
Insert cell
btn2=DOM.download(serialize(textOb))
Insert cell
dashboard = html`<div class='dashboardOuter' style='height:800px;width:1200px'>

<div class="topText" style="position:absolute;left:20px;top:00px;width:500px">
<h3 > BIPS</p>
<h3 > Project Name: AERA New York</p>
</div>

<div class="inputsLabel" style="position:absolute;left:20px;top:100px">
<h3 > Model Inputs</h3>
</div>



<div class="inputViews" style="position:absolute;left:50px;top:135px;width:330px;">
${viewof ventilation}
${viewof climateZone}
${viewof program}
${viewof constructionType}
${viewof hvac}
${viewof metabolicRate}
${viewof heatRecoveryEfficiency}


${viewof infiltrationRate}
${viewof wwRatio}
${viewof economizer}


</div>



<div class="download" style="position:absolute;left:175px;top:100px;height:50px;width:100px">
${viewof clicks2}
</div>

<div class="download" style="position:absolute;left:255px;top:100px;height:50px;width:100px">

${btn}
</div>

<div class="download" style="position:absolute;left:555px;top:100px;height:50px;width:400px">

<p>Predicted C02: ${predictedC02} ppm<br>
Predicted AVG C02: ${predictedVOC} ppb<br>
Predicted Formaldehyde: ${predictedFormald} ppb<br>
Predicted Benzene: ${predictedBenzene} ppb


</p>
</div>



</div>

`
Insert cell
/*function serialize (data) {
let s = JSON.stringify(data);
return new Blob([s], {type: "application/json"})
}*/
Insert cell
viewof infiltrationRate2 = Inputs.range([0, 255], {step: 1, label: "Infiltration Rate2"})
Insert cell
function serialize1 (data){
console.log("hello")
textOb

//serialize(data)
//return jkd
}
Insert cell
import {serialize} from "@palewire/saving-json"
Insert cell
button = (data, filename = 'data.csv') => {
if (!data) throw new Error('Array of data required as first argument');

let downloadData;
if (filename.includes('.csv')) {
downloadData = new Blob([d3.csvFormat(data)], { type: "text/csv" });
} else {
downloadData = new Blob([JSON.stringify(data, null, 2)], {
type: "application/json"
});
}

const size = (downloadData.size / 1024).toFixed(0);
const button = DOM.download(
downloadData,
filename,
`Download ${filename} (~${size} KB)`
);
return button;
}
Insert cell
rf = import('https://cdn.skypack.dev/ml-random-forest@2.1.0?min')
Insert cell
Insert cell
fullDataSet = FileAttachment("500 - Sheet2@1.csv").csv()
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
trainingSetFormatted = formattedData.map((d) => d.slice(0, 10));
Insert cell
avgVOCtraining = formattedData.map((d) => d[12])
Insert cell
predictionsFormatted = formattedData.map((d) => d[13])
Insert cell
regression = new rf.RandomForestRegression(options)
Insert cell
regressionVOC = new rf.RandomForestRegression(options)
Insert cell
a = await regression.train(trainingSetFormatted, predictionsFormatted);
Insert cell
VOCtrained2 = await regressionVOC.train(trainingSetFormatted, avgVOCtraining);
Insert cell
result = a, regression.predict(trainingSetFormatted);
Insert cell
regressionFormald = new rf.RandomForestRegression(options)
Insert cell
formaldtraining = formattedData.map((d) => d[10])
Insert cell
formaldTrain = await regressionFormald.train(trainingSetFormatted, formaldtraining);
Insert cell
formald = formaldTrain, regressionFormald.predict(userInputs);
Insert cell
predictedFormald = round(formald,0)
Insert cell
regressionBenzene = new rf.RandomForestRegression(options)
Insert cell
benzenetraining = formattedData.map((d) => d[11])
Insert cell
benzeneTrain = await regressionBenzene.train(trainingSetFormatted, benzenetraining);
Insert cell
benzene = benzeneTrain, regressionBenzene.predict(userInputs);
Insert cell
predictedBenzene = round(benzene,0)
Insert cell
//resultVOC = VOCtrained, regression.predict(trainingSetFormatted);
Insert cell
co2 = a, regression.predict(userInputs);
Insert cell
predictedC02 = round(co2,0)
Insert cell
resultVOC = VOCtrained2, regressionVOC.predict(userInputs);
Insert cell
predictedVOC = round(resultVOC,0)
Insert cell
round = (n, places) => {
if (!places) return Math.round(n);
const d = 10 ** places;
return Math.round(n * d) / d;
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more