Professional Documents
Culture Documents
Untitled7 - Jupyter Notebook
Untitled7 - Jupyter Notebook
import numpy as np
import seaborn as sns
from sklearn.preprocessing import LabelEncoder
from sklearn.model_selection import train_test_split
from sklearn.svm import SVC
from sklearn.preprocessing import StandardScaler
Out[37]:
Waste Type Total Generated ('000 tonnes) Total Recycled ('000 tonnes) Year
Out[38]: (45, 4)
Out[39]:
Total Generated ('000 tonnes) Total Recycled ('000 tonnes) Year
Out[40]:
Waste Type Total Generated ('000 tonnes) Total Recycled ('000 tonnes) Year
41 Glass 66 7 2020
Out[42]:
Total Generated ('000 tonnes) Total Recycled ('000 tonnes) Year sortie
3 949 41 2018 15
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 45 entries, 0 to 44
Data columns (total 4 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 Total Generated ('000 tonnes) 45 non-null int64
1 Total Recycled ('000 tonnes) 45 non-null int64
2 Year 45 non-null int64
3 sortie 45 non-null int32
dtypes: int32(1), int64(3)
memory usage: 1.4 KB
Out[44]:
Total Generated ('000 tonnes) Year sortie sortie1
0 1624 2018 3 36
1 1269 2018 4 18
2 1054 2018 14 31
3 949 2018 15 14
4 763 2018 6 18
Entrée [45]: sns.scatterplot(x=df['sortie1'],y=df['sortie'], hue=df['Year'])
Entrée [50]: # Split the data into features (X) and target (y)
X = df.drop('Year', axis=1)
y = df['Year']
# Split the data into training and test sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)
print(X_train.shape, y_train.shape, X_test.shape, y_test.shape)
# Scale the features using StandardScaler
scaler = StandardScaler()
X_train = scaler.fit_transform(X_train)
X_test = scaler.transform(X_test)