当前位置: 首页>>代码示例>>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;未经允许,请勿转载。