Surpress Jupyter Notebook魔术命令通知

时间:2018-07-20 10:39:29

标签: python jupyter-notebook

这是一个快速的方法。我正在使用%run魔术命令来运行另一个Jupyter Notebook中的OLS回归。我使用%store魔术在笔记本之间传递数据。我的代码如下:

for targs in gen_targets(d_targets.columns):
    for feats in gen_feats(feat_lst):
        X_train, X_test, y_train, y_test = train_test_split(X[feats],
                                                            y[targs],
                                                            test_size=0.2)

        model_id = analysis_id + "_" + targs +'~'+' + '.join(feats)
        %store X_train #Store X training data
        %store y_train #Store y training data
        %store model_id  #Store Model ID 
        %run OLS_Regression.ipynb #Run the Regression
        %store -r model #The regression instance (in case I want to use it)
        %store -r model_results #Summary of model results (dic)

        results = results.append(model_results, ignore_index = True)

但是,当我运行此命令时,会收到有关存储的消息。下面是一个示例

Stored 'X_train' (DataFrame)
Stored 'y_train' (Series)
Stored 'model_id' (str)
Stored 'model_results' (dict)
Stored 'model' (RegressionResultsWrapper)
Stored 'X_train' (DataFrame)
Stored 'y_train' (Series)
Stored 'model_id' (str)
Stored 'model_results' (dict)
Stored 'model' (RegressionResultsWrapper)
Stored 'X_train' (DataFrame)
Stored 'y_train' (Series)
Stored 'model_id' (str)
Stored 'model_results' (dict)

由于我的功能和目标组合可能很长,因此这使输出不堪重负。

是否可以抑制此输出?

PS:如果您认为我可以改进代码,请告诉我。我仍然在“学习” 。我知道我还没有添加模型预测检查,因此“测试”火车分割似乎是多余的,但可以使用。

非常感谢。

0 个答案:

没有答案