Ensmble - Learning - ML - 5 - Jupyter Notebook
Ensmble - Learning - ML - 5 - Jupyter Notebook
Ensmble - Learning - ML - 5 - Jupyter Notebook
In [2]: df = pd.read_csv('car_data.csv')
In [3]: df.head()
Out[3]:
vhigh vhigh.1 2 2.1 small low unacc
In [4]: df.shape
Out[4]: (1727, 7)
In [5]: df.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 1727 entries, 0 to 1726
Data columns (total 7 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 vhigh 1727 non-null object
1 vhigh.1 1727 non-null object
2 2 1727 non-null object
3 2.1 1727 non-null object
4 small 1727 non-null object
5 low 1727 non-null object
6 unacc 1727 non-null object
dtypes: object(7)
memory usage: 94.6+ KB
localhost:8888/notebooks/BE_PRACTICALS/Ensmble_Learning_ML_5.ipynb 1/7
10/1/24, 11:26 PM Ensmble_Learning_ML_5 - Jupyter Notebook
In [6]: df.describe()
Out[6]:
vhigh vhigh.1 2 2.1 small low unacc
unique 4 4 4 3 3 3 4
In [7]: df.isna().sum()
Out[7]: vhigh 0
vhigh.1 0
2 0
2.1 0
small 0
low 0
unacc 0
dtype: int64
Out[8]:
buying maint doors persons lug_boot safety class
localhost:8888/notebooks/BE_PRACTICALS/Ensmble_Learning_ML_5.ipynb 2/7
10/1/24, 11:26 PM Ensmble_Learning_ML_5 - Jupyter Notebook
buying
high 432
med 432
low 432
vhigh 431
Name: count, dtype: int64
maint
high 432
med 432
low 432
vhigh 431
Name: count, dtype: int64
doors
3 432
4 432
5more 432
2 431
Name: count, dtype: int64
persons
4 576
more 576
2 575
Name: count, dtype: int64
lug_boot
med 576
big 576
small 575
Name: count, dtype: int64
safety
med 576
high 576
low 575
Name: count, dtype: int64
class
unacc 1209
acc 384
good 69
vgood 65
Name: count, dtype: int64
In [10]: df['class'].unique()
localhost:8888/notebooks/BE_PRACTICALS/Ensmble_Learning_ML_5.ipynb 3/7
10/1/24, 11:26 PM Ensmble_Learning_ML_5 - Jupyter Notebook
In [13]: x_train.head()
Out[13]:
buying maint doors persons lug_boot safety
In [14]: x_train.shape
Out[14]: (1381, 6)
In [15]: x_test.shape
Out[15]: (346, 6)
In [16]: x_train.dtypes
localhost:8888/notebooks/BE_PRACTICALS/Ensmble_Learning_ML_5.ipynb 4/7
10/1/24, 11:26 PM Ensmble_Learning_ML_5 - Jupyter Notebook
Collecting category_encoders
Downloading category_encoders-2.6.3-py2.py3-none-any.whl.metadata (8.0 k
B)
Requirement already satisfied: numpy>=1.14.0 in c:\python310\lib\site-pack
ages (from category_encoders) (1.23.5)
Requirement already satisfied: scikit-learn>=0.20.0 in c:\python310\lib\si
te-packages (from category_encoders) (1.3.1)
Requirement already satisfied: scipy>=1.0.0 in c:\python310\lib\site-packa
ges (from category_encoders) (1.11.3)
Requirement already satisfied: statsmodels>=0.9.0 in c:\python310\lib\site
-packages (from category_encoders) (0.14.3)
Requirement already satisfied: pandas>=1.0.5 in c:\python310\lib\site-pack
ages (from category_encoders) (2.1.1)
Requirement already satisfied: patsy>=0.5.1 in c:\python310\lib\site-packa
ges (from category_encoders) (0.5.6)
Requirement already satisfied: python-dateutil>=2.8.2 in c:\python310\lib
\site-packages (from pandas>=1.0.5->category_encoders) (2.8.2)
Requirement already satisfied: pytz>=2020.1 in c:\python310\lib\site-packa
ges (from pandas>=1.0.5->category_encoders) (2023.3.post1)
Requirement already satisfied: tzdata>=2022.1 in c:\python310\lib\site-pac
kages (from pandas>=1.0.5->category_encoders) (2023.3)
Requirement already satisfied: six in c:\python310\lib\site-packages (from
patsy>=0.5.1->category_encoders) (1.16.0)
Requirement already satisfied: joblib>=1.1.1 in c:\python310\lib\site-pack
ages (from scikit-learn>=0.20.0->category_encoders) (1.3.2)
Requirement already satisfied: threadpoolctl>=2.0.0 in c:\python310\lib\si
te-packages (from scikit-learn>=0.20.0->category_encoders) (3.2.0)
Requirement already satisfied: packaging>=21.3 in c:\python310\lib\site-pa
ckages (from statsmodels>=0.9.0->category_encoders) (23.0)
Downloading category_encoders-2.6.3-py2.py3-none-any.whl (81 kB)
---------------------------------------- 0.0/81.9 kB ? eta -:--:--
----------------------------------- ---- 71.7/81.9 kB 2.0 MB/s eta 0:0
0:01
---------------------------------------- 81.9/81.9 kB 1.5 MB/s eta 0:0
0:00
Installing collected packages: category_encoders
Successfully installed category_encoders-2.6.3
localhost:8888/notebooks/BE_PRACTICALS/Ensmble_Learning_ML_5.ipynb 5/7
10/1/24, 11:26 PM Ensmble_Learning_ML_5 - Jupyter Notebook
0.9479768786127167
0.953757225433526
0.953757225433526
safety 0.293866
persons 0.238120
buying 0.201061
maint 0.125037
lug_boot 0.081547
doors 0.060370
dtype: float64
localhost:8888/notebooks/BE_PRACTICALS/Ensmble_Learning_ML_5.ipynb 6/7
10/1/24, 11:26 PM Ensmble_Learning_ML_5 - Jupyter Notebook
0.9263157894736842
In [ ]:
localhost:8888/notebooks/BE_PRACTICALS/Ensmble_Learning_ML_5.ipynb 7/7