Commit
·
6e7b802
1
Parent(s):
53174cf
Create logregwine.py
Browse files- logregwine.py +21 -0
logregwine.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Import necessary modules
|
2 |
+
from sklearn import linear_model
|
3 |
+
from sklearn.cross_validation import train_test_split
|
4 |
+
|
5 |
+
# Load data
|
6 |
+
df = pd.read_csv('http://archive.ics.uci.edu/ml/machine-learning-databases/wine-quality/winequality-red.csv ' , sep = ';')
|
7 |
+
X = df.drop('quality' , 1).values #drop target variable
|
8 |
+
y1 = df['quality'].values
|
9 |
+
y = y1 <= 5 # is the rating <= 5?
|
10 |
+
|
11 |
+
# plot histograms of original target variable
|
12 |
+
# and aggregated target variable
|
13 |
+
plt.figure(figsize=(20,5));
|
14 |
+
plt.subplot(1, 2, 1 );
|
15 |
+
plt.hist(y1);
|
16 |
+
plt.xlabel('original target value')
|
17 |
+
plt.ylabel('count')
|
18 |
+
plt.subplot(1, 2, 2);
|
19 |
+
plt.hist(y)
|
20 |
+
plt.xlabel('aggregated target value')
|
21 |
+
plt.show()
|