小编nkh*_*uyu的帖子

(Python - sklearn)如何通过gridsearchcv将参数传递给自定义的ModelTransformer类

下面是我的管道,似乎我不能通过使用ModelTransformer类将参数传递给我的模型,我从链接中获取它(http://zacstewart.com/2014/08/05/pipelines-of- featureunions-of-pipelines.html)

错误信息对我有意义,但我不知道如何解决这个问题.知道如何解决这个问题吗?谢谢.

# define a pipeline
pipeline = Pipeline([
('vect', DictVectorizer(sparse=False)),
('scale', preprocessing.MinMaxScaler()),
('ess', FeatureUnion(n_jobs=-1, 
                     transformer_list=[
     ('rfc', ModelTransformer(RandomForestClassifier(n_jobs=-1, random_state=1,  n_estimators=100))),
     ('svc', ModelTransformer(SVC(random_state=1))),],
                     transformer_weights=None)),
('es', EnsembleClassifier1()),
])

# define the parameters for the pipeline
parameters = {
'ess__rfc__n_estimators': (100, 200),
}

# ModelTransformer class. It takes it from the link
(http://zacstewart.com/2014/08/05/pipelines-of-featureunions-of-pipelines.html)
class ModelTransformer(TransformerMixin):
    def __init__(self, model):
        self.model = model
    def fit(self, *args, **kwargs):
        self.model.fit(*args, **kwargs)
        return self
    def transform(self, X, **transform_params):
        return DataFrame(self.model.predict(X))

grid_search = GridSearchCV(pipeline, parameters, n_jobs=-1, …
Run Code Online (Sandbox Code Playgroud)

machine-learning parameter-passing python-2.7 scikit-learn cross-validation

18
推荐指数
1
解决办法
4955
查看次数

Microsoft Cosmos DB(DocumentDB API)与Cosmos DB(表API)

Microsoft Cosmos DB包括DocumentDB API,Table API等.我有大约10 TB的数据,并希望有一个快速的键值查找(很少更新和写入,大多数是读取).添加Microsoft Cosmos DB的链接:https: //docs.microsoft.com/en-us/azure/cosmos-db/

  1. 那么我该如何在DocumentDB API和Table API之间做出选择呢?
  2. 或者我应该何时选择DocumentDB API?我什么时候应该选择Table API?
  3. 使用DcoumentDB API存储10 TB数据是一个好习惯吗?

azure nosql azure-cosmosdb

9
推荐指数
2
解决办法
3755
查看次数

sklearn Pipeline和DataFrameMapper有什么区别?

Sklearn Pipeline:http://scikit-learn.org/stable/modules/generated/sklearn.pipeline.Pipeline.html

DataFrameMapper:https://github.com/paulgb/sklearn-pandas

他们之间有什么区别?

在我看来,sklearn管道具有更多功能,但DataFrameMapper对我来说更加干净.

pipeline scikit-learn sklearn-pandas

6
推荐指数
1
解决办法
4898
查看次数

pytorch中的torch.Tensor()和torch.empty()有什么区别?

我已经尝试了如下。在我看来,它们是相同的。pytorch中的torch.Tensor()和torch.empty()有什么区别?

在此处输入图片说明

python torch pytorch tensor

5
推荐指数
2
解决办法
6585
查看次数

SQL Where子句有多个字段

我有一张桌子如下.

id          date         value

1           2011-10-01   xx

1           2011-10-02   xx
...

1000000     2011-10-01   xx
Run Code Online (Sandbox Code Playgroud)

然后我有1000个ID,每个人都有一个约会.我想执行以下操作:

SELECT id, date, value
FROM the table
WHERE (id, date) IN ((id1, <= date1), (id2, <= date2), (id1000, <= date1000))
Run Code Online (Sandbox Code Playgroud)

实现上述查询的最佳方法是什么?

sql sql-server where-clause where-in sql-in

1
推荐指数
1
解决办法
219
查看次数