sklearn.utils.shuffle 用法小技巧

news/2024/7/9 9:17:48 标签: sklearn, python, 机器学习

是可以打乱多组数据的,不局限与x,y。

python">import numpy as np
import random
from sklearn.utils import shuffle

a = np.array([1,2,3,4,5])
b = np.array([0.1,0.2,0.3,0.4,0.5])
c = np.array([-1,-2,-3,-4,-5])

a,b,c = shuffle(a,b,c)
print(a)
print(b)
print(c)

# output:
# [1 4 2 5 3]
# [0.1 0.4 0.2 0.5 0.3]
# [-1 -4 -2 -5 -3]


http://www.niftyadmin.cn/n/770303.html

相关文章

到处抄来的写作用语2

drawn from 取自 In machine learning, it is often assumed that the training and test subjects are drawn from the same distribution. bound 约束 many existing methods aim to bound the target error by the source error plus a discrepancy metric betwe…

pytorch 中的tensor.T 与tensor.data

tensor.T 是 tensor.data的转置

pytorch的shuffle功能

import torch# 原数据 x torch.arange(0, 10) print(x)# 生成随机索引 shuffle_indextorch.randperm(10)print(x[shuffle_index])

Kappa系数计算

内容整理自百度百科 kappa系数是一种衡量分类精度的指标。 公式: kpo−pe1−pek\frac{p_o-p_e}{1-p_e} k1−pe​po​−pe​​ 其中,pop_opo​是每一类正确分类的样本数量之和除以总样本数,也就是总体分类精度 。C是类别总数,TiT…

python 绘制 频谱图

效果图 t np.arange(0,time,1.0/sampling_rate) wavename morl # "cmorB-C" where B is the bandwidth and C is the center frequency. totalscal 64 # scale fc pywt.central_frequency(wavename) # central frequency cparam 2 * fc * totalscal sca…

pywt 安装

pip install PyWavelets

到处抄来的写作用语3

presentation 介绍 a presentation of the BCI-relevant manifolds As mentioned earlier 如前文所提 As mentioned earlier, the model is balabala. For simplicity 为简单起见 hotspot 热点 motor imagery (MI) electroencephalogram (EEG) signal classifi…

skleran 计算 kappa系数

from sklearn.metrics import cohen_kappa_scorekappa cohen_kappa_score(pre,true) kappa cohen_kappa_score(true,pre) # kappa统计值是对称的,所以交换y1和y2不会改变值。 详见官网