Octave解析机器学习算法

监督学习

在监督学习中,我们有一组训练数据作为输入和一组标签或“正确答案”作为输出。 我们训练模型(机器学习算法参数),以正确地将输入映射到输出(以进行正确的预测)。 最终目的是找到此类模型参数,这些参数将成功持续纠正输入→输出映射(预测),即使对于新的输入示例也是如此。

回归

在回归问题中,我们进行实值预测。我们尝试沿着训练示例绘制一条线/平面/n 维平面。使用示例:股票价格预测、销售分析、任意数字的依赖等。

% COST function.
% It shows how accurate our model is based on current model parameters.
function [cost] = cost_function(X, y, theta, lambda)
    % Input:
    % X - input features - (m x n) matrix.
    % theta - our model parameters - (n x 1) vector.
    % y - a vector of correct output - (m x 1) vector.
    % lambda - regularization parameter.
    %
    % Output:
    % cost - number that represents the cost (error) of our model with specified parameters theta.
    %
    % Where:
    % m - number of training examples,
    % n - number of features.

    % Get the size of the trainging set.
    m = size(X, 1);

    % Get the difference between predictions and correct output values.
    differences = hypothesis(X, theta) - y;

    % Calculate regularization parameter.
    % Remember that we should not regularize the parameter theta_zero.
    theta_cut = theta(2:end, 1);
    regularization_param = lambda * (theta_cut' * theta_cut);

    % Calculate current predictions cost.
    cost = (1 / 2 * m) * (differences' * differences + regularization_param);
end
% FEATURE NORMALIZE function.
% Normalizes the features in X. Returns a normalized version of X where the mean value of 
% each feature is 0 and the standard deviation is 1.
function [X_normalized, mu, sigma] = feature_normalize(X)
    X_normalized = X;
    mu = zeros(1, size(X_normalized, 2));
    sigma = zeros(1, size(X_normalized, 2));

    % Get average values for each feature (column) in X.
    mu = mean(X_normalized);

    % Calculate the standard deviation for each feature.
    sigma = std(X_normalized);

    % Subtract mean values from each feature (column) of every example (row)
    % to make all features be spread around zero.
    X_normalized = X_normalized - mu;

    % Normalize each feature values for each example so that all features 
    % are close to [-1:1] boundaries.
    X_normalized = X_normalized ./ sigma;
end

分类

在分类问题中,我们按特定特征分割输入示例。使用示例:垃圾邮件过滤器、语言检测、查找相似文档、手写字母识别等。

示例:微芯片健康检测,使用一对多方法的手写数字识别。

无监督学习

无监督学习是机器学习的一个分支,它从没有被标记、分类或分类的测试数据中学习。 无监督学习不是响应反馈,而是识别数据中的共性,并根据每条新数据中此类共性的存在与否做出反应。

聚类

在聚类问题中,我们按未知特征分割训练样本。算法本身将决定使用什么特征进行分割。使用示例:市场细分、社交网络分析、组织计算集群、天文数据分析、图像压缩等。

示例:将数据分成三个集群。

异常检测

异常检测(也是异常值检测)是对稀有项目、事件或观察结果的识别,这些项目、事件或观察结果与大多数数据显着不同,从而引起怀疑。使用示例:入侵检测、欺诈检测、系统健康监控、从数据集中删除异常数据等。

示例:检测过载的服务器。

神经网络

神经网络本身不是算法,而是许多不同机器学习算法协同工作和处理复杂数据输入的框架。使用示例:作为一般所有其他算法的替代,图像识别、语音识别、图像处理(应用特定风格)、语言翻译等。

示例:手写数字识别。

详情参阅 - 亚图跨际

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值