From 3309227f549fa0722cb8d4cc4117c01514111bde Mon Sep 17 00:00:00 2001 From: Charu Date: Sat, 24 Mar 2018 16:49:24 +0530 Subject: [PATCH 1/4] Added linear learner in learning.ipynb --- learning.ipynb | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/learning.ipynb b/learning.ipynb index bce7967f2..282b45bc5 100644 --- a/learning.ipynb +++ b/learning.ipynb @@ -1716,6 +1716,63 @@ "The correct output is 0, which means the item belongs in the first class, \"setosa\". Note that the Perceptron algorithm is not perfect and may produce false classifications." ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## LINEAR LEARNER\n", + "\n", + "### Overview\n", + "\n", + "Linear regression is a linear model. It is a model that assumes a linear relationship between the input variables x and the single output variable y. More specifically, that y can be calculated from a linear combination of the input variables x. Linear learner is a quite simple model as the representation of this model is a linear equation. \n", + "The linear equation assigns one scaler factor to each input value or column, called a coefficients or weights. One additional coefficient is also added, giving additional degree of freedom and is often called the intercept or the bias coefficient. For example : y = ax1 + bx2 + c . \n", + "\n", + "### Implementation\n", + "\n", + "Below mentioned is the implementation of Linear Learner." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "psource(LinearLearner)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "This algorithm first assigns some random weights to the input variables and then based on the error calculated updates the weight for each variable. Finally the prediction is made with the updated weights. \n", + "\n", + "### Implementation\n", + "\n", + "We will now use the Linear Learner to classify a sample with values: 5.1, 3.0, 1.1, 0.1." + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0.2404650656510341\n" + ] + } + ], + "source": [ + "iris = DataSet(name=\"iris\")\n", + "iris.classes_to_numbers()\n", + "\n", + "linear_learner = LinearLearner(iris)\n", + "print(linear_learner([5, 3, 1, 0.1]))" + ] + }, { "cell_type": "markdown", "metadata": {}, From 69ccee68ab0250b43e38c5df48e97a1f6b031e22 Mon Sep 17 00:00:00 2001 From: Charu Date: Sun, 25 Mar 2018 11:09:34 +0530 Subject: [PATCH 2/4] Update learning.ipynb --- learning.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/learning.ipynb b/learning.ipynb index 282b45bc5..f1ddc3967 100644 --- a/learning.ipynb +++ b/learning.ipynb @@ -1724,7 +1724,7 @@ "\n", "### Overview\n", "\n", - "Linear regression is a linear model. It is a model that assumes a linear relationship between the input variables x and the single output variable y. More specifically, that y can be calculated from a linear combination of the input variables x. Linear learner is a quite simple model as the representation of this model is a linear equation. \n", + "Linear learner is a model that assumes a linear relationship between the input variables x and the single output variable y. More specifically, that y can be calculated from a linear combination of the input variables x. Linear learner is a quite simple model as the representation of this model is a linear equation. \n", "The linear equation assigns one scaler factor to each input value or column, called a coefficients or weights. One additional coefficient is also added, giving additional degree of freedom and is often called the intercept or the bias coefficient. For example : y = ax1 + bx2 + c . \n", "\n", "### Implementation\n", From 5da8c675588e1df56dece257e4908c3c0bedc828 Mon Sep 17 00:00:00 2001 From: Charu Date: Sun, 25 Mar 2018 11:12:42 +0530 Subject: [PATCH 3/4] Update learning.ipynb --- learning.ipynb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/learning.ipynb b/learning.ipynb index f1ddc3967..275fd037d 100644 --- a/learning.ipynb +++ b/learning.ipynb @@ -1725,7 +1725,8 @@ "### Overview\n", "\n", "Linear learner is a model that assumes a linear relationship between the input variables x and the single output variable y. More specifically, that y can be calculated from a linear combination of the input variables x. Linear learner is a quite simple model as the representation of this model is a linear equation. \n", - "The linear equation assigns one scaler factor to each input value or column, called a coefficients or weights. One additional coefficient is also added, giving additional degree of freedom and is often called the intercept or the bias coefficient. For example : y = ax1 + bx2 + c . \n", + "The linear equation assigns one scaler factor to each input value or column, called a coefficients or weights. One additional coefficient is also added, giving additional degree of freedom and is often called the intercept or the bias coefficient. \n", + "For example : y = ax1 + bx2 + c \n" "\n", "### Implementation\n", "\n", From 3747a0e3fa327ceff48864273b29054fc55ca789 Mon Sep 17 00:00:00 2001 From: Charu Date: Sun, 25 Mar 2018 11:31:43 +0530 Subject: [PATCH 4/4] Update learning.ipynb --- learning.ipynb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/learning.ipynb b/learning.ipynb index 275fd037d..aecd5d2d3 100644 --- a/learning.ipynb +++ b/learning.ipynb @@ -1724,9 +1724,10 @@ "\n", "### Overview\n", "\n", - "Linear learner is a model that assumes a linear relationship between the input variables x and the single output variable y. More specifically, that y can be calculated from a linear combination of the input variables x. Linear learner is a quite simple model as the representation of this model is a linear equation. \n", - "The linear equation assigns one scaler factor to each input value or column, called a coefficients or weights. One additional coefficient is also added, giving additional degree of freedom and is often called the intercept or the bias coefficient. \n", - "For example : y = ax1 + bx2 + c \n" + "Linear Learner is a model that assumes a linear relationship between the input variables x and the single output variable y. More specifically, that y can be calculated from a linear combination of the input variables x. Linear learner is a quite simple model as the representation of this model is a linear equation. \n", + "\n", + "The linear equation assigns one scaler factor to each input value or column, called a coefficients or weights. One additional coefficient is also added, giving additional degree of freedom and is often called the intercept or the bias coefficient. \n", + "For example : y = ax1 + bx2 + c . \n", "\n", "### Implementation\n", "\n",