亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

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

ErrorException(E_NOTICE)未定義變量:actualLabels

ErrorException(E_NOTICE)未定義變量:actualLabels

PHP
弒天下 2022-06-17 17:08:58
幫助,我的代碼中出現錯誤“ErrorException (E_NOTICE) Undefined variable: actualLabels”$title = "Data Confusion Matrix";$testing_data = DataTesting::count();$klasifikasi = Klasifikasi::with('sentimen')->get();foreach($klasifikasi as $kelas){    $predictedLabels[] = $kelas->sentimen->kategori;    $testing = DataTesting::where('id_testing',$kelas->id_testing)->first();    $twitter = TwitterStream::with('sentimen')->where('id_crawling',$testing->id_crawling)->first();    $actualLabels[] = $twitter->sentimen->kategori; } $getPrecision = new ControllerConfusionMatrix($actualLabels, $predictedLabels); $accuracy = ControllerConfusionMatrix::score($actualLabels, $predictedLabels); $recall = $getPrecision->getRecall(); $precision = $getPrecision->getPrecision();
查看完整描述

2 回答

?
胡子哥哥

TA貢獻1825條經驗 獲得超6個贊

將此行添加到代碼的開頭:$actualLabels = []; 您收到錯誤,因為當$klasifikasi為空時,則不會執行循環內的語句。所以$actualLabels沒有創建變量。在這種情況下,您會得到(E_NOTICE) Undefined variable: actualLabels. 希望你能理解。



查看完整回答
反對 回復 2022-06-17
?
互換的青春

TA貢獻1797條經驗 獲得超6個贊

定義Array()


$predictedLabels = array();

$actualLabels = array();

            foreach($klasifikasi as $kelas){

                $predictedLabels[] = $kelas->sentimen->kategori;

                $testing = DataTesting::where('id_testing',$kelas->id_testing)->first();

                $twitter = TwitterStream::with('sentimen')->where('id_crawling',$testing->id_crawling)->first();

                $actualLabels[] = $twitter->sentimen->kategori;

            }


查看完整回答
反對 回復 2022-06-17
  • 2 回答
  • 0 關注
  • 203 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號