Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Added linear learner #889

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 25, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions learning.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1716,6 +1716,65 @@
"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 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",
"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": {},
Expand Down