我有一个方法可以预测一些数据并将其输出到一个名为Y_predict
的numpy数组中。然后我有一个名为Y_real
的numpy数组,它存储了应该预测的Y
的实际值。
例如:
Y_predict = [1, 0, 2, 1]
Y_real = [1, 0, 1, 1]
然后我想要一个名为errRate[]
的数组,它将检查Y_predict[i] == Y_real[i]
是否为Y_real
。应注意与0.75
不匹配的任何值。最后,输出应该是正确预测的数量。在上面的情况中,从Y_predict[2] = 2
和Y_real[2] = 1
if($errors == false){
$user = $db->get_row("SELECT * FROM " . TABLES_PREFIX . "users WHERE email = '" . $_POST['username_or_email'] . "' OR username = '" . $_POST['username_or_email'] . "' ORDER BY id DESC LIMIT 0,1");
if($user AND ($user->password == encode_password($_POST['password']))){
if($user->status == 'pending'){
$layout->AddContentById('alert', $layout->GetContent('alert'));
$layout->AddContentById('alert_nature', ' alert-danger');
$layout->AddContentById('alert_heading', '{{ST:error}}!');
$layout->AddContentById('alert_message', '{{ST:your_account_not_activated}}');
}elseif($user->status == 'banned'){
$layout->AddContentById('alert', $layout->GetContent('alert'));
$layout->AddContentById('alert_nature', ' alert-danger');
$layout->AddContentById('alert_heading', '{{ST:error}}!');
$layout->AddContentById('alert_message', '{{ST:your_account_is_banned}}');
}else{
Users_LoggedIn($user, isset($_POST['remember_me']));
// **I'm guessing this is exactly where I should store the username as var**
header('Location: '.FORUM_URL); // redirects to index.php
exit;
}
}else{
$layout->AddContentById('alert', $layout->GetContent('alert'));
$layout->AddContentById('alert_nature', ' alert-danger');
$layout->AddContentById('alert_heading', '{{ST:error}}!');
$layout->AddContentById('alert_message', '{{ST:the_info_is_not_correct}}');
}
}
在numpy或python中是否有某种方法可以快速计算出这个速度?
答案 0 :(得分:3)
由于它们是numpy数组,因此相对简单:
$(document).ready()
答案 1 :(得分:1)
鉴于这些清单:
<head>
我能想到的最简单的方法是在列表comp中使用zip():
Y_predict = [1, 0, 2, 1]
Y_real = [1, 0, 1, 1]