1.1 - 8.10 - Histogram Example: AutoBin ('Sturges') - Teradata Vantage

Teradata Vantage™ - Machine Learning Engine Analytic Function Reference

Product
Teradata Vantage
Release Number
1.1
8.10
Release Date
October 2019
Content Type
Programming Reference
Publication ID
B700-4003-079K
Language
English (United States)

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 cars_sturges_out;

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

Output

 output_table                      output_columns                              
 --------------------------------- ------------------------------------------- 
 specified in OutputTable argument bin bin_start bin_end bin_count bin_percent
SELECT * FROM cars_sturges_out ORDER BY 1;
 bin bin_start bin_end bin_count bin_percent 
 --- --------- ------- --------- ----------- 
   0      50.0   100.0         9       28.13
   1     100.0   150.0         8          25
   2     150.0   200.0         8          25
   3     200.0   250.0         5       15.63
   4     250.0   300.0         1        3.13
   5     300.0   350.0         1        3.13

Download a zip file of all examples and a SQL script file that creates their input tables from the attachment in the left sidebar.