當前位置: 首頁>>代碼示例>>Python>>正文


Python scikit_learn.KerasRegressor方法代碼示例

本文整理匯總了Python中keras.wrappers.scikit_learn.KerasRegressor方法的典型用法代碼示例。如果您正苦於以下問題:Python scikit_learn.KerasRegressor方法的具體用法?Python scikit_learn.KerasRegressor怎麽用?Python scikit_learn.KerasRegressor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在keras.wrappers.scikit_learn的用法示例。


在下文中一共展示了scikit_learn.KerasRegressor方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: main

# 需要導入模塊: from keras.wrappers import scikit_learn [as 別名]
# 或者: from keras.wrappers.scikit_learn import KerasRegressor [as 別名]
def main():
    house_df = pd.read_csv('./data/housing.csv', sep='\s+', header=None)
    hose_set = house_df.values
    # print(hose_set)
    x = hose_set[:, 0:13]
    y = hose_set[:, 13]
    # print(y)

    # tbcallback=callbacks.TensorBoard(log_dir='./logs',histogram_freq=0, write_graph=True, write_images=True)
    estimators = []
    estimators.append(('mlp', KerasRegressor(build_fn=build_model, epochs=512, batch_size=32, verbose=1)))
    pipeline = Pipeline(estimators)
    kfold = KFold(n_splits=10, random_state=seed)

    # results = cross_val_score(estimator, x, y, cv=kfold)
    scores = cross_val_score(pipeline, x, y, cv=kfold)
    print('\n')
    print("Results: %.2f (%.2f) MSE" % (scores.mean(), scores.std())) 
開發者ID:jarvisqi,項目名稱:deep_learning,代碼行數:20,代碼來源:hous_price.py

示例2: train

# 需要導入模塊: from keras.wrappers import scikit_learn [as 別名]
# 或者: from keras.wrappers.scikit_learn import KerasRegressor [as 別名]
def train(self):
        """
            Trains the pipeline. After training the dataset is removed
            from the object to save space.
        """
        Log.write("Size of dataset: %d" % (len(self.dataset)))
        X = np.array([precedent['facts_vector'][self.important_facts_index] for precedent in self.dataset])
        Y = np.array([precedent['outcomes_vector'][self.outcome_index]
                      for precedent in self.dataset])
        self.input_dimensions = len(X[0])
        regressor = KerasRegressor(
            build_fn=self._nn_architecture, epochs=1000, batch_size=1024, verbose=0)
        scaler = StandardScaler()
        self.model = AbstractRegressor._create_pipeline(scaler, regressor)
        self.model.fit(X, Y)
        self.test() 
開發者ID:Cyberjusticelab,項目名稱:JusticeAI,代碼行數:18,代碼來源:tenant_pays_landlord.py

示例3: test_regression_build_fn

# 需要導入模塊: from keras.wrappers import scikit_learn [as 別名]
# 或者: from keras.wrappers.scikit_learn import KerasRegressor [as 別名]
def test_regression_build_fn():
    reg = KerasRegressor(
        build_fn=build_fn_reg, hidden_dims=hidden_dims,
        batch_size=batch_size, epochs=epochs)

    assert_regression_works(reg) 
開發者ID:hello-sea,項目名稱:DeepLearning_Wavelet-LSTM,代碼行數:8,代碼來源:scikit_learn_test.py

示例4: test_regression_class_build_fn

# 需要導入模塊: from keras.wrappers import scikit_learn [as 別名]
# 或者: from keras.wrappers.scikit_learn import KerasRegressor [as 別名]
def test_regression_class_build_fn():
    class ClassBuildFnReg(object):

        def __call__(self, hidden_dims):
            return build_fn_reg(hidden_dims)

    reg = KerasRegressor(
        build_fn=ClassBuildFnReg(), hidden_dims=hidden_dims,
        batch_size=batch_size, epochs=epochs)

    assert_regression_works(reg) 
開發者ID:hello-sea,項目名稱:DeepLearning_Wavelet-LSTM,代碼行數:13,代碼來源:scikit_learn_test.py

示例5: test_regression_inherit_class_build_fn

# 需要導入模塊: from keras.wrappers import scikit_learn [as 別名]
# 或者: from keras.wrappers.scikit_learn import KerasRegressor [as 別名]
def test_regression_inherit_class_build_fn():
    class InheritClassBuildFnReg(KerasRegressor):

        def __call__(self, hidden_dims):
            return build_fn_reg(hidden_dims)

    reg = InheritClassBuildFnReg(
        build_fn=None, hidden_dims=hidden_dims,
        batch_size=batch_size, epochs=epochs)

    assert_regression_works(reg) 
開發者ID:hello-sea,項目名稱:DeepLearning_Wavelet-LSTM,代碼行數:13,代碼來源:scikit_learn_test.py

示例6: opt_regressor

# 需要導入模塊: from keras.wrappers import scikit_learn [as 別名]
# 或者: from keras.wrappers.scikit_learn import KerasRegressor [as 別名]
def opt_regressor():
    optimizer = DummyOptPro(iterations=1)
    optimizer.forge_experiment(
        model_initializer=KerasRegressor,
        model_init_params=_build_fn_regressor,
        model_extra_params=dict(
            callbacks=[ReduceLROnPlateau(patience=Integer(5, 10))],
            batch_size=Categorical([32, 64], transform="onehot"),
            epochs=10,
            verbose=0,
        ),
    )
    optimizer.go() 
開發者ID:HunterMcGushion,項目名稱:hyperparameter_hunter,代碼行數:15,代碼來源:test_keras.py


注:本文中的keras.wrappers.scikit_learn.KerasRegressor方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。