通过R2和RMSE比较模型

时间:2018-04-30 00:34:55

标签: r machine-learning regression cross-validation

我正在使用pls和h2o包开发模型预测,这些包导致2个模型:pls.model和h2o.model。每轮交叉验证的R平方(皮尔逊相关的平方)和RMSE如下所示: R2:

<?php
$servername = "localhost";
$username = "pass";
$password = "pass";
$dbname = "DB1";



$conn = new mysqli($servername, $username, $password, $dbname);

if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
} 

$sql = "SELECT * FROM DB1";
$res = mysqli_query($conn, $sql);

while($row = $res->fetch_assoc()) {
    echo '<button type="button" class="C1" id=';
    echo '"';
    echo $row["ID"];
    echo '" >';
    echo $row["Name"];
    echo '</button>';
    echo '<br>';
}

?>

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>

<script type="text/javascript">
$(document).ready(function(){

$(".C1").click(function(){
var Id = event.target.id;

document.getElementById("in").value = Id;
$( "#id" ).submit();

});



});

</script>



<title></title>
</head>
<body>

<form id="id" action="SASS.php" method="post">
    <input type="text" name="dingoo" id="in">


</form>
</body>
</html>  

RMSE:

i     R2.PLS     R2.H2O
1   1 0.4415108 0.6232292
2   2 0.3754088 0.6056992
3   3 0.4267580 0.6204750
4   4 0.3505282 0.6062691
5   5 0.2870766 0.5344183
6   6 0.3858786 0.5794828
7   7 0.3449946 0.5692314
8   8 0.2974582 0.5522208
9   9 0.3446449 0.5694339
10 10 0.3987684 0.5561757

我无法解释为什么pls.model具有较低的R2但较低的错误,而h2o.model具有较高的R2但较高的错误。我检查了散点图,但没有出现非线性图案。 你有没有想过这个?在这种情况下,什么应该是更好的模型?

由于 PHUONG

0 个答案:

没有答案