|
1716 | 1716 | "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."
|
1717 | 1717 | ]
|
1718 | 1718 | },
|
| 1719 | + { |
| 1720 | + "cell_type": "markdown", |
| 1721 | + "metadata": {}, |
| 1722 | + "source": [ |
| 1723 | + "## LINEAR LEARNER\n", |
| 1724 | + "\n", |
| 1725 | + "### Overview\n", |
| 1726 | + "\n", |
| 1727 | + "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", |
| 1728 | + "\n", |
| 1729 | + "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", |
| 1730 | + "For example : y = ax1 + bx2 + c . \n", |
| 1731 | + "\n", |
| 1732 | + "### Implementation\n", |
| 1733 | + "\n", |
| 1734 | + "Below mentioned is the implementation of Linear Learner." |
| 1735 | + ] |
| 1736 | + }, |
| 1737 | + { |
| 1738 | + "cell_type": "code", |
| 1739 | + "execution_count": null, |
| 1740 | + "metadata": {}, |
| 1741 | + "outputs": [], |
| 1742 | + "source": [ |
| 1743 | + "psource(LinearLearner)" |
| 1744 | + ] |
| 1745 | + }, |
| 1746 | + { |
| 1747 | + "cell_type": "markdown", |
| 1748 | + "metadata": {}, |
| 1749 | + "source": [ |
| 1750 | + "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", |
| 1751 | + "\n", |
| 1752 | + "### Implementation\n", |
| 1753 | + "\n", |
| 1754 | + "We will now use the Linear Learner to classify a sample with values: 5.1, 3.0, 1.1, 0.1." |
| 1755 | + ] |
| 1756 | + }, |
| 1757 | + { |
| 1758 | + "cell_type": "code", |
| 1759 | + "execution_count": 21, |
| 1760 | + "metadata": {}, |
| 1761 | + "outputs": [ |
| 1762 | + { |
| 1763 | + "name": "stdout", |
| 1764 | + "output_type": "stream", |
| 1765 | + "text": [ |
| 1766 | + "0.2404650656510341\n" |
| 1767 | + ] |
| 1768 | + } |
| 1769 | + ], |
| 1770 | + "source": [ |
| 1771 | + "iris = DataSet(name=\"iris\")\n", |
| 1772 | + "iris.classes_to_numbers()\n", |
| 1773 | + "\n", |
| 1774 | + "linear_learner = LinearLearner(iris)\n", |
| 1775 | + "print(linear_learner([5, 3, 1, 0.1]))" |
| 1776 | + ] |
| 1777 | + }, |
1719 | 1778 | {
|
1720 | 1779 | "cell_type": "markdown",
|
1721 | 1780 | "metadata": {},
|
|
0 commit comments