DaalLinearRegressionModel __init__


__init__(self, name=None)

[BETA] Create a ‘new’ instance of a DAAL Linear Regression model.

Parameters:

name : unicode (default=None)

User supplied name.

Returns:

: Model

A new instance of DaalLinearRegressionNewPlugin

Linear Regression [R11] is used to model the relationship between a scalar dependent variable and one or more independent variables. The Linear Regression model is initialized, trained on columns of a frame and used to predict the value of the dependent variable given the independent observations of a frame. This model runs the DAAL implementation of Linear Regression [R12] with QR [R13] decomposition.

footnotes

[R11]https://en.wikipedia.org/wiki/Linear_regression
[R12]https://software.intel.com/en-us/daal
[R13]https://en.wikipedia.org/wiki/QR_decomposition

Examples

Consider the following model trained and tested on the sample data set in frame ‘frame’.

Consider the following frame containing two columns.

>>> frame.inspect()
[#]  x1   y
===============
[0]  0.0    0.0
[1]  1.0    2.5
[2]  2.0    5.0
[3]  3.0    7.5
[4]  4.0   10.0
[5]  5.0   12.5
[6]  6.0   13.0
[7]  7.0  17.15
[8]  8.0   18.5
[9]  9.0   23.5
>>> model = ta.DaalLinearRegressionModel()
[===Job Progress===]
>>> train_output = model.train(frame,'y',['x1'])
[===Job Progress===]
>>> train_output
{u'explained_variance': 49.275928030303035,
 u'intercept': -0.03272727272727477,
 u'mean_absolute_error': 0.5299393939393953,
 u'mean_squared_error': 0.6300969696969696,
 u'observation_columns': [u'x1'],
 u'r_2': 0.987374330660537,
 u'root_mean_squared_error': 0.7937864761363534,
 u'value_column': u'y',
 u'weights': [2.443939393939394]}
>>> test_output = model.test(frame,'y')
[===Job Progress===]
>>> test_output
{u'explained_variance': 49.275928030303035,
 u'mean_absolute_error': 0.5299393939393953,
 u'mean_squared_error': 0.6300969696969696,
 u'r_2': 0.987374330660537,
 u'root_mean_squared_error': 0.7937864761363534}
>>> predicted_frame = model.predict(frame, observation_columns = ["x1"])
[===Job Progress===]
>>> predicted_frame.inspect()
[#]  x1   y      predict_y
=================================
[0]  0.0    0.0  -0.0327272727273
[1]  1.0    2.5     2.41121212121
[2]  2.0    5.0     4.85515151515
[3]  3.0    7.5     7.29909090909
[4]  4.0   10.0     9.74303030303
[5]  5.0   12.5      12.186969697
[6]  6.0   13.0     14.6309090909
[7]  7.0  17.15     17.0748484848
[8]  8.0   18.5     19.5187878788
[9]  9.0   23.5     21.9627272727
>>> model.publish()