我有一个使用 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) 操作系统: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) 有什么区别(目标是提取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)
结果看起来一样