小编tud*_*dou的帖子

Scikitlearn Column Transformer 错误:使用剩余关键字时,列顺序对于拟合和变换必须相等

我有一个使用 ColumnTransformer 的带有管道的简单模型

我能够训练模型并将模型保存为泡菜

当我加载泡菜并预测实时数据时,我收到以下关于 ColumnTransformer 的错误

使用剩余关键字时,列顺序对于拟合和变换必须相等

训练数据和用于预测的数据具有完全相同的列数,例如 50。我不确定该列的“排序”如何改变。

为什么列的排序对于 columntransformer 很重要?如何解决这个问题?有没有办法在运行柱式变压器后确保“排序”?

谢谢。

   pipeline = Pipeline([
        ('RepalceInf', ReplaceInf()),
        ('impute_30_100', ColumnTransformer(
            [
                ('oneStdNorm', OneStdImputer(), self.cont_feature_strategy_dict['FEATS_30_100']),
            ],
            remainder='passthrough'
        )),
        ('regress_impute', IterativeImputer(random_state=0, estimator=self.cont_estimator)),
        ('replace_outlier', OutlierReplacer(quantile_range=(1, 99))),
        ('scaler', StandardScaler(with_mean=True))
    ])



class OneStdImputer(TransformerMixin, BaseEstimator):
def __init__(self):
    """
    Impute the missing data with random value in the range of mean +/- one standard deviation
    This is a simplified implementation without sparse/dense fit and check.
    """
    self.mean = None
    self.std = None

def fit(self, X, y=None): …
Run Code Online (Sandbox Code Playgroud)

python-3.x scikit-learn

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

无法使用 python 3.8 构建 opencv-python

操作系统:ubuntu 我可以从命令行安装 opencv-python 。但是,当我尝试安装带有 opencv-python 依赖项的自建包时,它无法构建:

Building wheels for collected packages: opencv-python
  Building wheel for opencv-python (PEP 517): started
  Building wheel for opencv-python (PEP 517): finished with status 'error'
  ERROR: Complete output from command /usr/local/bin/python /usr/local/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py build_wheel /tmp/tmp7jntqv2r:
  ERROR: Not searching for unused variables given on the command line.
  CMake Error: CMake was unable to find a build program corresponding to "Ninja".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
  -- Configuring incomplete, errors occurred! …
Run Code Online (Sandbox Code Playgroud)

opencv python-3.x

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

迭代 dictionary.items() 与 list(dictionary.items()) 之间的区别

有什么区别(目标是提取k,v值)

for k,v in example_dict.items():
    print(k,v)
    do_something
Run Code Online (Sandbox Code Playgroud)

对比

for k,v in list(example_dict.items()):
    print(k,v)
    do_something
Run Code Online (Sandbox Code Playgroud)

结果看起来一样

python

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

标签 统计

python-3.x ×2

opencv ×1

python ×1

scikit-learn ×1