Linear Regression Example | Teradata Vantage - Linear Regression Example - Teradata Vantage

Machine Learning Engine Analytic Function Reference

Product
Teradata Vantage
Release Number
9.02
9.01
2.0
1.3
Published
February 2022
Language
English (United States)
Last Update
2022-02-10
dita:mapPath
rnn1580259159235.ditamap
dita:ditavalPath
ybt1582220416951.ditaval
dita:id
B700-4003
lifecycle
previous
Product Category
Teradata Vantageā„¢

This example uses the LinRegInternal and LinReg functions to find the coefficients of the variables that determine the selling price of a home in a given neighborhood. The response variable, SellingPrice (the selling price of the house in dollars) is modeled on these independent (predictor) variables:

  • House size (in square feet)
  • Lot size (in square feet)
  • Number of bedrooms
  • Whether the kitchen counter is granite (0 or 1)
  • Whether the bathrooms are upgraded (0 or 1)

Input

housing_data
housesize lotsize bedrooms granite upgradedbathroom sellingprice
2397 14156 4 1 0 189900
2200 9600 4 0 1 195000
4032 10150 5 0 1 197900
3529 9191 6 0 0 205000
3247 10061 5 1 1 224900
2983 9365 5 0 1 230000
3536 19994 6 1 1 325000
3198 9669 5 1 1  

The LinRegInternal function skips the last row of housing_data because it contains a NULL value.

SQL Call

SELECT * FROM LinReg (
  ON LinRegInternal (
  ON housing_data
  ) PARTITION BY 1
) AS dt;

Output

 coefficient_name value_col           
 ---------------- ------------------- 
 Intercept        -21739.296665036818
 housesize        -26.930783509145726
 lotsize             6.33452410459345
 bedrooms           44293.76058418322
 granite            7140.676293495372
 upgradedbathroom   43179.19988882635

Download a zip file of all examples and a SQL script file that creates their input tables.