第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Scikit-learn Pipeline:測試集的預測大小等于訓練集的大小

Scikit-learn Pipeline:測試集的預測大小等于訓練集的大小

慕森卡 2022-06-02 17:59:43
我正在嘗試對測試數(shù)據(jù)集進行預測。我正在使用帶有 MLPRegressor 的 Sklearn 管道。但是,即使我使用“test.csv”,我也只是從訓練集中獲得預測的大小。我在哪里可以修改以獲得長度與測試數(shù)據(jù)相同的預測?train_pipeline.py# Read training datadata = pd.read_csv(data_path, sep=';', low_memory=False, parse_dates=parse_dates)# Fill all None recordsdata[config.TARGET] = data[config.TARGET].fillna(0)# data[config.TARGET] = data[config.TARGET].apply(lambda x: split_join_string(x) if (type(x) == str and len(x.split('.')) > 0) else x)# Divide train and testX_train, X_test, y_train, y_test = train_test_split(    data[config.FEATURES],    data[config.TARGET],    test_size=0.1,    random_state=0)  # we are setting the seed here# Transform the targety_train = y_train.apply(lambda x: np.log(float(x)) if x != 0 else 0)y_test = y_test.apply(lambda x: np.log(float(x)) if x != 0 else 0)data_test = pd.concat([X_test, y_test], axis=1)# Save the dataset to a '.csv' file without indexdata_test.to_csv(data_path_test, sep=';', index=False)pipeline.order_pipe.fit(X_train[config.FEATURES],                        y_train)save_pipeline(pipeline_to_persist=pipeline.order_pipe)預測.pydef make_prediction(*, input_data) -> dict:    """Make a prediction using the saved model pipeline."""    data = pd.DataFrame(input_data)    validated_data = validate_inputs(input_data=data)    prediction = _order_pipe.predict(validated_data[config.FEATURES])    output = np.exp(prediction)    #score = _order_pipe.score(validated_data[config.FEATURES], validated_data[config.TARGET])    results = {'predictions': output, 'version': _version}    _logger.info(f'Making predictions with model version:  {_version}'            f'\nInputs:  {validated_data}'            f'\nPredictions: {results}')    return results我希望預測的大小為“test.csv”,但實際預測的大小為“train.csv”。我是否需要將測試數(shù)據(jù)集擬合或轉換為“order_pipe”以做出正確大小的預測?
查看完整描述

1 回答

?
婷婷同學_

TA貢獻1844條經(jīng)驗 獲得超8個贊

我解決了這個問題,刪除了一個導致 X_test 大小崩潰的預處理器。因此,X_test 被 X_train 取代,我無法做出正確的預測。

此外,還有另一個預處理器(使用 pd.get_dummies() 創(chuàng)建虛擬對象)插入新列并在 X_test 預測期間帶來更多問題。groupby()我還替換了那個預處理器,使用and對分類特征進行編碼map()。


查看完整回答
反對 回復 2022-06-02
  • 1 回答
  • 0 關注
  • 127 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號