我正在研究一些产生以下结果的KMeans代码。
foreach ($barang as $item) {
if ($mana_outstok <> '') {
$pesan = 'The product is not enough!';
$msg = [
'validasi' => $pesan
];
echo json_encode($msg);
} else {
$data = [
'c_price' => $item['qty'] * $item['barang_harjul'],
'qty' => $item['qty']
];
// $cid = implode($c_cart_id);
$where = [
'c_cart_id' => $c_cart_id,
'barang_id' => $item['barang_id']
];
$this->db->where($where);
$this->db->update('tbl_cart_detail', $data);
}
}
因此,在质心行上,出现此错误:
e.preventDefault();
$.ajax({
url: "<?php echo base_url(); ?>toko/cart/updatecart",
method: "POST",
data: {
c_cart_id: c_cart_id,
barang_id: barang_id,
qty: qty,
barang_harjul: barang_harjul
},
success: function(data) {
if (data.validasi) {
Swal.fire({
icon: 'error',
title: 'Oops...',
text: $pesan,
});
} else {
console.log(data);
}
}
});
// window.location.reload();
此外,当我查看数据时,也会看到以下内容:
# computing K-Means with K = 5 (5 clusters)
centroids,_ = kmeans(data,5)
# assign each sample to a cluster
idx,_ = vq(data,centroids)
这是所有金融股票数据。我的变量名为idx,我试图像这样绘制它。
cannot unpack non-iterable KMeans object
那给了我一个完全空白的情节。
所以,我这里有2个问题:
KMeans(algorithm='auto', copy_x=True,
init=KMeans(algorithm='auto', copy_x=True, init=5, max_iter=300,
n_clusters=array([[ 1.16081512e-02, 2.85525825e-01],
[ 1.49568108e-02, 2.49657983e-01],
[ 5.22185587e-01, 2.69694864e-01],
[ 1.64087910e-01, 3.07132892e-01],
[ 3.50376069e-01, 2.84015985e-01],
[-3.24139574e-01, 5.31442620e-01],
[ 1.08532783e-01, 1.97567928e-01],
[ 8.2751088...
[-2.12946095e-01, 1.88162364e-01],
[ 1.85284372e-01, 2.08285115e-01],
[ 8.87439716e-02, 3.26685279e-01],
[-5.02299728e-02, 2.59064238e-01],
[-5.87074489e-02, 1.80408830e-01],
[ 2.56515988e-01, 2.27288998e-01],
[ 6.88178287e-02, 2.81140072e-01],
[ 4.30796526e-01, 2.15103414e-01]]),
n_init=10, n_jobs=None, precompute_distances='auto', random_state=None,
tol=0.0001, verbose=0)