Exemple #1
0
    }


model = KerasClassifier(build_fn=build_network, verbose=1)
hyperparameters = create_hyperparameters()
kfold_cv = KFold(n_splits=5, shuffle=True)

search = RandomizedSearchCV(estimator=model,
                            param_distributions=hyperparameters,
                            n_iter=10,
                            verbose=1,
                            cv=kfold_cv)

search.fit(x_train, x_train)

loss, acc = search.evaluate(x_test, x_test)
print(loss, acc)

print('Best parameter : ', search.best_params_)
print('Best estimator : ', search.best_estimator_)
print('Accuracy : ', search.score(x_test, x_test))
'''
# 숫자들을 인코딩 /디코딩
# test set에서 숫자들을 가져왔다는 것을 유의
encoded_imgs = encoder.predict(x_test)
decoded_imgs = decoder.predict(encoded_imgs)

print(encoded_imgs)
print(decoded_imgs)
print(encoded_imgs.shape) # (10000, 32)
print(decoded_imgs.shape) # (10000, 784)
Exemple #2
0
               'max_features':max_features,
               'bootstrap':bootstrap}

pprint(random_grid)

# 

from sklearn.ensemble import RandomForestRegressor 
rf = RandomForestRegressor(random_state = 42)

rf_random = RandomizedSearchCV(estimator = rf_r, param_distributions = random_grid,
                                 n_iter=100, cv = 3, verbose = 2, 
                                 random_state = 42, n_jobs = -1,
                                 scoring = 'neg_mean_absolute_error')

rf_random.evaluate(test_x_scaled_hhb, y_test_hhb)


# error Cannot clone object '<class 'sklearn.ensemble._forest.RandomForestRegressor'>'\
# (type <class 'abc.ABCMeta'>): 
# it does not seem to be a scikit-learn estimator as it does not implement a 'get_params' methods.


--------------------------------------------------
x_scaled_hhb
test_x_scaled_hhb

# 평가방법 튜닝

def evaluate(model, test_x_scaled_hhb, y_test_hhb):
    predictions = model.predict(test_x_scaled_hhb)