Histogram Example 1: AutoBin ('Sturges') - Teradata Vantage

Machine Learning Engine Analytic Function Reference

Product
Teradata Vantage
Release Number
8.00
1.0
Published
May 2019
Language
English (United States)
Last Update
2019-11-22
dita:mapPath
blj1506016597986.ditamap
dita:ditavalPath
blj1506016597986.ditaval
dita:id
B700-4003
lifecycle
previous
Product Category
Teradata Vantageā„¢

Input

The InputTable, cars_hist, has the cylinder (cyl) and horsepower (hp) data for different car models. The examples compute the histograms on the hp column.

InputTable: cars_hist
id name cyl hp
1 Mazda RX4 6 110
2 Mazda RX4 Wag 6 110
3 Datsun 710 4 93
4 Hornet 4 Drive 6 110
5 Hornet Sportabout 8 175
6 Valiant 6 105
7 Duster 360 8 245
8 Merc 240D 4 62
9 Merc 230 4 95
10 Merc 280 6 123
11 Merc 280C 6 123
12 Merc 450SE 8 180
13 Merc 450SL 8 180
14 Merc 450SLC 8 180
15 Cadillac Fleetwood 8 205
16 Lincoln Continental 8 215
17 Chrysler Imperial 8 230
18 Fiat 128 4 66
19 Honda Civic 4 52
20 Toyota Corolla 4 65
21 Toyota Corona 4 97
22 Dodge Challenger 8 150
23 AM CJavelin 8 150
24 Camaro Z28 8 245
25 Pontiac Firebird 8 175
26 Fiat X1-9 4 66
27 Porsche 914-2 4 91
28 Lotus Europa 4 113
29 Ford Pantera L 8 264
30 Ferrari Dino 6 175
31 Maserati Bora 8 335
32 Volvo 142E 4 109

SQL Call

DROP TABLE IF EXISTS cars_sturges_out;

SELECT * FROM Histogram (
  ON cars_hist AS InputTable
  OUT TABLE OutputTable (cars_sturges_out)
  USING
  AutoBin ('Sturges')
  TargetColumn ('hp')
) AS dt;

Output

output_table output_columns
specified in OutputTable argument bin bin_start bin_end bin_count bin_percent

This query returns the following table:

SELECT * FROM cars_sturges_out ORDER BY 1;
cars_sturges_out
bin bin_start bin_end bin_count bin_percent
0 50 100 9 28.13
1 100 150 8 25.00
2 150 200 8 25.00
3 200 250 5 15.63
4 250 300 1 3.13
5 300 350 1 3.13