Spaces:
Runtime error
Runtime error
Upload app.py
Browse files
app.py
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# -*- coding: utf-8 -*-
|
2 |
+
"""Untitled0.ipynb
|
3 |
+
|
4 |
+
Automatically generated by Colaboratory.
|
5 |
+
|
6 |
+
Original file is located at
|
7 |
+
https://colab.research.google.com/drive/1TrLYru7HIkMCSYavUVhf6DZ-5lYqp3zI
|
8 |
+
"""
|
9 |
+
|
10 |
+
import pandas as pd
|
11 |
+
import numpy as np
|
12 |
+
from sklearn.pipeline import Pipeline
|
13 |
+
from sklearn.compose import ColumnTransformer
|
14 |
+
from sklearn.preprocessing import StandardScaler
|
15 |
+
from sklearn.tree import DecisionTreeClassifier
|
16 |
+
|
17 |
+
df=pd.read_csv('wine_red.csv')
|
18 |
+
df.drop(['residual_sugar','pH','free_sulfur_dioxide'],axis=1,inplace=True)
|
19 |
+
X_train = df.drop('quality',axis=1)
|
20 |
+
y_train = df.pop("quality")
|
21 |
+
|
22 |
+
num_col = X_train.select_dtypes(include=['int64', 'float64']).columns
|
23 |
+
preprocessor = ColumnTransformer([("scaler", StandardScaler(), num_col)])
|
24 |
+
num_col = X_train.select_dtypes(include=['int64', 'float64']).columns
|
25 |
+
preprocessor = ColumnTransformer([("scaler", StandardScaler(), num_col)])
|
26 |
+
model = Pipeline(steps=[('preprocessor', preprocessor), ('decisiontree', DecisionTreeClassifier())])
|
27 |
+
model.fit(X_train, y_train)
|
28 |
+
|
29 |
+
model = Pipeline(steps=[('scaler', StandardScaler()),
|
30 |
+
('decisiontree', DecisionTreeClassifier())])
|
31 |
+
|
32 |
+
model.fit(X_train, y_train)
|
33 |
+
|
34 |
+
"""### Saving the model"""
|
35 |
+
|
36 |
+
import joblib
|
37 |
+
|
38 |
+
joblib.dump(model,'model.joblib')
|