from evoml.subsampling import BasicSegmenter_FEMPO, BasicSegmenter_FEGT, BasicSegmenter_FEMPT

df = pd.read_csv('datasets/ozone.csv')

df.head(2)

X, y = df.iloc[:,:-1], df['output']

print(BasicSegmenter_FEGT.__doc__)

from sklearn.tree import DecisionTreeRegressor
clf_dt = DecisionTreeRegressor(max_depth=3)
clf = BasicSegmenter_FEGT(base_estimator=clf_dt, statistics=True)

clf.fit(X, y)

clf.score(X, y)

EGs = clf.segments_

len(EGs)

sampled_datasets = [eg.get_data() for eg in EGs]

[sd.shape for sd in sampled_datasets]

"""
Explanation: Aim
Motive of the notebook is to give a brief overview as to how to use the evolutionary sampling powered ensemble models as part of the EvoML research project. 
Will make the notebook more verbose if time permits. Priority will be to showcase the flexible API of the new estimators which encourage research and tinkering. 
Contents

Subsampling
Subspacing

1. Subsampling - Sampling in the example space - rows will be mutated and evolved.
End of explanation
"""


from evoml.subspacing import FeatureStackerFEGT, FeatureStackerFEMPO

print(FeatureStackerFEGT.__doc__)

clf = FeatureStackerFEGT(ngen=30)

clf.fit(X, y)

clf.score(X, y)

## Get the Hall of Fame individual
hof = clf.segment[0]

sampled_datasets = [eg.get_data() for eg in hof]

[data.columns.tolist() for data in sampled_datasets]

## Original X columns
X.columns

"""
Explanation: 2. Subspacing - sampling in the domain of features - evolving and mutating columns
End of explanation
"""


