Public
Edited
Mar 28, 2024
Insert cell
Insert cell
rf = import('https://cdn.skypack.dev/ml-random-forest@2.1.0?min')
Insert cell
trainingSet = formattedData.map((d) => d.slice(0, 5));
Insert cell
predictions = formattedData.map((d) => d[5])
Insert cell
options = ({
seed: 3,
maxFeatures: 5,
replacement: false,
nEstimators: 100
})
Insert cell
regression = new rf.RandomForestRegression(options)
Insert cell
a = await regression.train(trainingSet, predictions);
Insert cell
result3 = a, regression.predict([[numericData[0],numericData[1],numericData[2],125,numericData[3]]]);
Insert cell
numericData[3]
Insert cell
viewof endofLife = Inputs.select([null].concat("Landfill","Recycle","Reuse"), {label: "End of Life"})
Insert cell
viewof pctRecovered = Inputs.select(["0%","50%","100%"], {label: "Percent Recovered"})
Insert cell
viewof dist = Inputs.range([100, 1000], {step: 1, label: "Distance Traveled"})
Insert cell
viewof quant = Inputs.range([100, 1000], {step: 1, label: "Quantity"})
Insert cell
viewof set = Inputs.button("Set Data")
Insert cell
viewof dist.value
Insert cell
numericData = {

var data =[]
var eol
var rcvrd
var distance
var quantity
if(viewof endofLife.value=="Landfill"){eol = 1}
if(viewof endofLife.value=="Recycle"){eol = 2}
if(viewof endofLife.value=="Reuse"){eol = 3}
if(viewof pctRecovered.value=="0%"){rcvrd = 1}
if(viewof pctRecovered.value=="50%"){rcvrd = 2}
if(viewof pctRecovered.value=="100%"){rcvrd = 3}

distance = viewof dist.value
quantity = viewof quant.value
data.push(quantity)
data.push(rcvrd)
data.push(distance)
data.push(eol)
data.push(set)
return data
}
Insert cell
a, regression.featureImportance()
Insert cell
a, regression.toJSON()
Insert cell
Glass- Systems Protypting - Sheet1@1.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
spMaterialsForMachineLearningSheet3

Insert cell
fullDataSet = {
return spMaterialsForMachineLearningSheet3
}
Insert cell
formattedData = {

var fullSet = []

for (let i = 0; i < fullDataSet.length; i++) {

var currentLine = [Number(fullDataSet[i].col1),Number(fullDataSet[i].col2),Number(fullDataSet[i].col3),Number(fullDataSet[i].col4),Number(fullDataSet[i].col5),Number(fullDataSet[i].result)]

fullSet.push(currentLine)
}

return fullSet
}
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more