# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.model_selection import cross_val_score
from sklearn.ensemble import RandomForestClassifier,BaggingClassifier
from sklearn.tree import DecisionTreeClassifier

df = pd.read_csv("clslowbwt.csv")
df.shape

df.head()

X = df.iloc[:,1:-2]
print(X.shape)

X.head()

y=df.iloc[:,-1]

print(y.shape)

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=.3, random_state =1)

# +
dt = DecisionTreeClassifier(max_depth=None, min_samples_split=2,random_state=0)
scores = cross_val_score(dt, X_train, y_train)
print(scores.mean())                             

rfc = RandomForestClassifier(n_estimators=100, max_depth=None,min_samples_split=2, random_state=0)
scores = cross_val_score(rfc,X_train, y_train)
print(scores.mean())                             
# -

eclf = BaggingClassifier(base_estimator= dt)

scores = cross_val_score(eclf,X_train, y_train)
print(scores.mean())

StarcoderdataJupyterScriptsDedupFiltered