예제 #1
0
 def test_fit(self):
     pipe = Pipeline(self.rf_pipe)
     tmp = pipe.fit(self.data.df_devices, self.data.df_activities)
예제 #2
0
파일: sequential.py 프로젝트: tcsvn/pyadlml
"""
Example: Cross Validation
"""
ts = TimeSeriesSplit(n_splits=5)
scores = []
# cross validation on train set
for train_int, val_int in ts.split(X_train):
    steps = [('enc', BinaryEncoder(encode='raw')),
             ('lbl', TrainOrEvalOnlyWrapper(LabelEncoder(idle=True))),
             ('drop_val', TrainOnlyWrapper(CVSubset(train_int))),
             ('drop_train', EvalOnlyWrapper(CVSubset(val_int))),
             ('drop_time_idx', DropTimeIndex()),
             ('classifier', RandomForestClassifier(random_state=42))]

    pipe = Pipeline(steps).train()
    pipe.fit(X_train, y_train)

    # evaluate
    pipe = pipe.eval()
    scores.append(pipe.score(X_train, y_train))

print('scores of the pipeline: {}'.format(str(scores)))
print('mean score: {:.3f}'.format(np.array(scores).mean()))
"""
Simple Example Gridsearch
"""
from pyadlml.model_selection import GridSearchCV

param_grid = {
    'encode_devices__encode': ['changepoint', 'raw', 'lastfired'],
}