Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
phillipahereza committed Mar 27, 2017
0 parents commit 00b86e8
Show file tree
Hide file tree
Showing 12 changed files with 1,363 additions and 0 deletions.
Binary file added .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.pptx
197 changes: 197 additions & 0 deletions .ipynb_checkpoints/LinearRegression-checkpoint.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"deletable": true,
"editable": true
},
"source": [
"# Wine Quality Dataset using Linear Regression\n",
"\n",
"###### The dataset included is related to red vinho verde wine samples, from the north of Portugal. The goal is to model wine quality based on physicochemical tests\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import warnings\n",
"# conventional way to import pandas \n",
"import pandas as pd\n",
"from sklearn.linear_model import LinearRegression\n",
"from sklearn.model_selection import train_test_split\n",
"from sklearn.metrics import accuracy_score\n",
"\n",
"warnings.filterwarnings(action=\"ignore\", module=\"scipy\", message=\"^internal gelsd\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Load the dataset"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"wine = pd.read_csv('winequality-red.csv', delimiter=';')\n",
"\n",
"# display the first 10 rows of the dataset\n",
"wine.head(10)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## What are the features of this dataset and what value are we predicting?\n",
"##### In otherwords, what is the X of this dataset and y of the dataset"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"y = wine['quality']\n",
"x = wine.drop('quality', axis=1)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Display the features"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"x.head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Split the dataset\n",
"#### Ideally we are supposed to split the data into the training, testing and validation sets but for this tutorial we shall limit ourselves to the training and test data set"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"x_train, x_test, y_train, y_test = train_test_split(x,y)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Training our model\n",
"```python\n",
"class sklearn.linear_model.LinearRegression(fit_intercept=True, normalize=False, copy_X=True, n_jobs=1)\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"linearRegressor = LinearRegression()\n",
"linearRegressor.fit(x_train, y_train)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# predict the quality of the wine in the test split\n",
"y_predict = linearRegressor.predict(x_test)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Determining how our model has performed\n",
"```python\n",
"accuracy_score(y_true, y_pred, normalize=True, sample_weight=None)\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"accuracy_score(y_test.values, y_predict)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.10"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading

0 comments on commit 00b86e8

Please sign in to comment.