Published
Edited
Aug 16, 2019
Insert cell
Insert cell
regressionTree=require( 'https://bundle.run/wink-regression-tree@2.0.0' );
Insert cell
d3=require("d3")
Insert cell
rt = regressionTree();
Insert cell
cars=d3.json("https://raw.githubusercontent.com/winkjs/wink-regression-tree/master/sample-data/cars.json")
Insert cell
Insert cell
columns = [
{ name: 'model', categorical: true, exclude: true },
{ name: 'mpg', categorical: false, target: true },
{ name: 'cylinders', categorical: true, exclude: false },
{ name: 'displacement', categorical: true, exclude: false },
{ name: 'horsepower', categorical: true, exclude: false },
{ name: 'weight', categorical: true, exclude: false },
{ name: 'acceleration', categorical: true, exclude: false },
{ name: 'year', categorical: true, exclude: true },
{ name: 'origin', categorical: true, exclude: false }
];
Insert cell
treeParams = ({
minPercentVarianceReduction: 0.5,
minLeafNodeItems: 10,
minSplitCandidateItems: 30,
minAvgChildrenItems: 2
});
Insert cell
rt.defineConfig(columns, treeParams);
Insert cell
cars.forEach(row => rt.ingest(row))
Insert cell
rt.learn();
Insert cell
mean = rt.predict(input)
Insert cell
+mean.toFixed(1)
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