matlab 机器学习相关函数、api

  • matlab 对数据集的默认组织方式是,XRd×N
    • d:行数,表示特征向量的长度;
    • N:列数,表示样本的数目;

1. 模型、预测、mse

% 加载 matlab 内置数据到内存
X = abalone_dataset;

% 模型定义
ae = trainAutoencoder(X);

% 训练集上的预测,对于自编码器而言,就是重构;
X_rec = predict(ae, X);

% 损失函数
mse_loss = mse(X-X_rec);

2. integer labels ⇒ categorical labels

  • categorical()
>> integer_labels = randi([0, 9], 10, 1);
>> label_names = 
'airplane'
'automobile'
'bird'
'cat'
'deer'
'dog'
'frog'
'horse'
'ship'
'truck'

>> categorical(integer_labels, 0:9, label_names)

3. categorical ⇒ numeric

c = categorical({'Male','Female','Female','Male','Female'});
n = grp2idx(c); 
原文地址:https://www.cnblogs.com/mtcnn/p/9421858.html