标签: pipeline

redis.clients.jedis.exceptions.JedisDataException: 请在调用此方法之前关闭管道或多块

我想要页面 zrange,得到错误:请在调用此方法之前关闭管道或多块。,如何解决这个问题(我的集群不支持多命令https://github.com/CodisLabs/codis/blob/master/doc/unsupported_cmds .md)?

runWithPipeline(new JedisPipelinedCallback() {
  @Override
  public void execute(Pipeline pipeline) {
    int offset = 0;
    boolean finished = false;

    do {
      // need to paginate the keys
      Set<byte[]> rawKeys = pipeline.zrange(rawKnownKeysKey, (offset) * PAGE_SIZE, (offset + 1) * PAGE_SIZE - 1).get();
      finished = rawKeys.size() < PAGE_SIZE;
      offset++;
      if (!rawKeys.isEmpty()) {
        List<byte[]> regionedKeys = new ArrayList<byte[]>();
        for (byte[] rawKey : rawKeys) {
          regionedKeys.add(getRegionedKey(rawRegion, rawKey));
        }

        pipeline.del(regionedKeys.toArray(new byte[regionedKeys.size()][]));
      }
      pipeline.sync();
    } while (!finished);

    pipeline.del(rawKnownKeysKey);
  }
});
Run Code Online (Sandbox Code Playgroud)

// 创建 {@link …

pipeline redis jedis

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

为什么 sklearn Pipeline 调用 transform() 的次数比 fit() 多这么多?

经过大量阅读和检查不同verbose参数设置下的pipeline.fit()操作后,我仍然很困惑为什么我的管道会多次访问某个步骤的transform方法。

下面是一个简单的例子pipelinefitGridSearchCV使用3倍交叉验证,但PARAM栅与只有一组hyperparams的。所以我预计三个运行通过管道。双方step1step2fit叫了三次,符合市场预期,但每一步transform叫了好几次。为什么是这样?下面的最小代码示例和日志输出。

# library imports
import pandas as pd
from sklearn import datasets
from sklearn.model_selection import KFold
from sklearn.linear_model import LogisticRegression
from sklearn.base import TransformerMixin, BaseEstimator
from sklearn.pipeline import Pipeline

# Load toy data
iris = datasets.load_iris()
X = pd.DataFrame(iris.data, columns = iris.feature_names)
y = pd.Series(iris.target, name='y')

# Define a couple trivial pipeline steps
class mult_everything_by(TransformerMixin, BaseEstimator):

    def __init__(self, multiplier=2):
        self.multiplier = …
Run Code Online (Sandbox Code Playgroud)

python pipeline machine-learning scikit-learn

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

为什么此汇编代码块在管道中有2个停顿而不是1个?

为了详细说明主要问题,为什么第三行在已经回写了Register2之后的时钟周期执行一次执行?我以为它应该只有1个档位在管道中。但是我不对。LOAD和STORE标签是否只是某种质量,我们必须暂停一个额外的周期?我有点困惑。这是代码块:

ADD R2, #4
LSL R4, #5
LDR R1, [R2]
LDR R3, [R2]
SUB R5, #2
SUB R6, #3
Run Code Online (Sandbox Code Playgroud)

我们必须制作一个5阶段的管道图来显示数据危害。在图片中,它有2个危险。

5阶段流水线过程的图像

由正确答案的朋友发送的过去任务的图像。

我要添加来自同一任务的另一个问题的代码。评论内部是正确的过程。

@ CLOCK CYCLE      1     2     3     4      5     6      7     8
STR R2, [R5]     @IF -> ID -> EX -> MEM -> WB
STR R3, [R6]     @      IF -> ID -> EX  -> MEM -> WB
MUL R4, R1, R2   @            IF -> ID  -> NOP -> EX -> MEM -> WB
Run Code Online (Sandbox Code Playgroud)

这个只有一个档位。

assembly arm pipeline cpu-architecture risc

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

GridSearch 中的 sklearn 逻辑回归参数

只是想知道如何将参数分成一组并将其传递给 gridsearch?因为我想将惩罚 l1 和 l2 传递给网格搜索,并将相应的求解器 newton-cg 传递给 L2。

但是,当我运行下面的代码时,gridsearch 将首先使用 newton-cg 运行 l1 并导致错误 msg ValueError:Solver newton-cg 仅支持 l2 惩罚,得到了 l1 惩罚。

谢谢

 param_grid = [

  {'penalty':['l1','l2'] ,
   'solver' : ['newton-cg', 'lbfgs', 'liblinear', 'sag', 'saga']
  }

 ]
Run Code Online (Sandbox Code Playgroud)

pipeline machine-learning scikit-learn logistic-regression

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

GridSearchCV 在管道中将 fit_params 传递给 XGBRegressor 会产生“ValueError:需要超过 1 个值才能解包”

无论内容如何,​​将 fit_params 传递到包含 XGBRegressor 的管道都会返回错误

训练数据集已经过热编码,并被拆分以用于管道

train_X, val_X, train_y, val_y = train_test_split(final_train, y, random_state = 0)
Run Code Online (Sandbox Code Playgroud)

创建一个 Imputer -> XGBRegressor 管道。设置 XGBRegressor 的参数和拟合参数

pipe = Pipeline(steps=[("Imputer", Imputer()),
                      ("XGB", XGBRegressor())])

xgb_hyperparams = {'XGB__n_estimators': [1000, 2000, 3000],
                   'XGB__learning_rate': [0.01, 0.03, 0.05, 0.07],
                   'XGB__max_depth': [3, 4, 5]}

fit_parameters = {'XGB__early_stopping_rounds': 5,
              'XGB__eval_metric': 'mae',
              'XGB__eval_set': [(val_X, val_y)],
              'XGB__verbose': False}

grid_search = GridSearchCV(pipe,
                          xgb_hyperparams,
                          #fit_params=fit_parameters,
                          scoring='neg_mean_squared_error',
                          cv=5,
                          n_jobs=1,
                          verbose=3)

grid_search.fit(train_X, train_y, fit_params=fit_parameters)
Run Code Online (Sandbox Code Playgroud)

这会产生以下输出:

Fitting 5 folds for each of 36 candidates, totalling 180 fits
[CV] …
Run Code Online (Sandbox Code Playgroud)

python pipeline scikit-learn grid-search xgboost

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

为什么 aws cli 不会正确地使缓存无效 - AWS Cloudfront

我创建了一个 Jenkins 作业,每次部署我的前端项目时都会使缓存无效。问题是,虽然 AWS 网站显示缓存无效,但当作业完成时,缓存并未完全清除,因此我需要通过 AWS 网站手动使其无效...

我使用的自动使缓存无效的方法是通过aws 容器,我在其中执行以下命令:

  • aws cloudfront create-invalidation --distribution-id ${DISTRIBUTION_ID} --paths /* > output.json

输出文件将包含一个 json,我可以在其中获取不同的键:值。我使用的其中两个是IdStatus。创建失效后,我执行以下另一个管道步骤:

  • aws cloudfront get-invalidation --distribution-id ${DISTRIBUTION_ID} --id ${id_invalidator} > status_invalidation.json

使用之前的命令,我每 50 秒(通过 a sleep 50)向API 请求一次失效状态。当验证返回“Status = Completed”时,作业就完成了。此条件在 while 循环内。

有人知道为什么会这样吗?

pipeline amazon-web-services jenkins amazon-cloudfront aws-cli

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

scikit 管道中的链式转换

我正在使用 scikit 管道在数据集上创建预处理。我有一个包含四个变量的数据集:['monetary', 'frequency1', 'frequency2', 'recency']我想预处理除recency. 要预处理,我首先要获取日志,然后进行标准化。但是,当我从管道中获取转换后的数据时,会得到 7 列(3 个日志、3 个标准化、新近度)。有没有办法链接转换,这样我就可以获得日志,并且在日志执行标准化后只能获得 4 个特征数据集?

def create_pipeline(df):
    all_but_recency = ['monetary', 'frequency1','frequency2']

    # Preprocess
    preprocessor = ColumnTransformer(
        transformers=[
            ( 'log', FunctionTransformer(np.log), all_but_recency ),
            ( 'standardize', preprocessing.StandardScaler(), all_but_recency ) ],
        remainder='passthrough')

    # Pipeline
    estimators = [( 'preprocess', preprocessor )]
    pipe = Pipeline(steps=estimators)

    print(pipe.set_params().fit_transform(df).shape)
Run Code Online (Sandbox Code Playgroud)

提前致谢

python pipeline scikit-learn

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

管道中的函数式编程和python pandas数据帧

我想知道哪种函数式编程的最佳实践是编写一系列函数来处理熊猫数据框-或任何其他可变输入类型-作为函数的输入。

这里有两个想法,但是希望有更好的东西:)

想法#1-不进行功能编程而是节省内存

def foo(df, param):
    df['col'] = df['col'] + param

def pipeline(df):
    foo(df, 1)
    foo(df, 2)
    foo(df, 3)
Run Code Online (Sandbox Code Playgroud)

想法#2-更多的功能编程,但是通过执行.copy()浪费了内存

def foo(df, param):
    df = df.copy()
    df['col'] = df['col'] + param
    return df

def pipeline(df):
    df1 = foo(df, 1)
    df2 = foo(df1, 2)
    df3 = foo(df2, 3)
Run Code Online (Sandbox Code Playgroud)

python functional-programming pipeline dataframe pandas

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

使用最佳参数构建模型时 GridsearchCV 最佳得分下降

我正在尝试使用网格搜索 CV 为我的逻辑回归估计器找到一组最佳超参数,并使用管道构建模型:

我的问题是当尝试使用我获得的最佳参数 grid_search.best_params_来构建逻辑回归模型时,准确度与我得到的不同

grid_search.best_score_ 
Run Code Online (Sandbox Code Playgroud)

这是我的代码

x=tweet["cleaned"]
y=tweet['tag']

X_train, X_test, Y_train, Y_test = model_selection.train_test_split(x, y, test_size=.20, random_state=42)

pipeline = Pipeline([
('vectorizer',TfidfVectorizer()),
('chi', SelectKBest()),
('classifier', LogisticRegression())])

grid = {
'vectorizer__ngram_range': [(1, 1), (1, 2),(1, 3)],
'vectorizer__stop_words': [None, 'english'],
'vectorizer__norm': ('l1', 'l2'),
'vectorizer__use_idf':(True, False), 
'vectorizer__analyzer':('word', 'char', 'char_wb'),
'classifier__penalty': ['l1', 'l2'],
'classifier__C': [1.0, 0.8],
'classifier__class_weight': [None, 'balanced'],
'classifier__n_jobs': [-1],
'classifier__fit_intercept':(True, False),
}

grid_search = GridSearchCV(pipeline, param_grid=grid, scoring='accuracy', n_jobs=-1, cv=10)
grid_search.fit(X_train,Y_train)
Run Code Online (Sandbox Code Playgroud)

当我获得最高分和婴儿车时使用

print(grid_search.best_score_)
print(grid_search.best_params_)
Run Code Online (Sandbox Code Playgroud)

结果是

0.7165160230073953 
{'classifier__C': 1.0, 'classifier__class_weight': None, 'classifier__fit_intercept': True, …
Run Code Online (Sandbox Code Playgroud)

pipeline machine-learning scikit-learn grid-search

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

使用索引器和编码器时 PySpark 管道错误

我正在使用来自 UCI银行数据来模板化一个项目。我正在他们的文档站点上关注 PySpark 教程(抱歉,找不到链接了)。在管道中运行时,我不断收到错误消息。我已经加载了数据,转换了特征类型,并完成了分类和数字特征的流水线操作。我希望对代码的任何部分提供任何反馈,但特别是在我收到错误的地方,以便我可以继续进行此构建。先感谢您!

样本数据

+---+---+----------+-------+---------+-------+-------+-------+----+-------+---+-----+--------+--------+-----+--------+--------+-------+
| id|age|       job|marital|education|default|balance|housing|loan|contact|day|month|duration|campaign|pdays|previous|poutcome|deposit|
+---+---+----------+-------+---------+-------+-------+-------+----+-------+---+-----+--------+--------+-----+--------+--------+-------+
|  1| 59|    admin.|married|secondary|     no|   2343|    yes|  no|unknown|  5|  may|    1042|       1|   -1|       0| unknown|    yes|
|  2| 56|    admin.|married|secondary|     no|     45|     no|  no|unknown|  5|  may|    1467|       1|   -1|       0| unknown|    yes|
|  3| 41|technician|married|secondary|     no|   1270|    yes|  no|unknown|  5|  may|    1389|       1|   -1|       0| unknown|    yes|
|  4| 55|  services|married|secondary|     no|   2476|    yes|  no|unknown|  5|  may|     579|       1|   -1|       0| unknown|    yes|
|  5| 54| …
Run Code Online (Sandbox Code Playgroud)

python pipeline apache-spark pyspark apache-spark-ml

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