octave 机器学习_使用Octave开发机器学习算法

2023-11-17

octave 机器学习

Octave is an open-source high-level programming language designed to perform efficient numerical computations solving linear and non-linear equations. Moreover, Octave gives the user the ability to use statistics and data analysis.

Octave是一种开放源代码的高级编程语言,旨在执行解决线性和非线性方程式的高效数值计算。 此外,Octave使用户能够使用统计数据和数据分析。

Due to its fast developing time and easy to learn syntax, Octave is one of the most used programming languages for Machine Learning along with Python and R.

由于其快速的开发时间和易于学习的语法,Octave是与Python和R一起用于机器学习的最常用编程语言之一。

Being a more productive language, it is a good choice for students and beginners in ML. In general, people tend to only prototype in Octave and only after succeeding, proceed into larger-scale implementations of the algorithms in languages like C++ and Java, or any other low-level languages which are more efficient than Octave when time is concerned.

作为一种生产力更高的语言,对于ML的学生和初学者来说,它是一个不错的选择。 通常,人们倾向于仅在Octave中进行原型制作,并且只有在成功之后才可以使用C ++和Java之类的语言或在时间上比Octave更高效的任何其他低级语言进行算法的大规模实现。

Now I am going to present everything you need to know in order to master Octave and use it for implementing your models in Machine Learning.

现在,我将介绍您需要掌握的所有知识,以掌握Octave并将其用于在Machine Learning中实现模型。

基本操作 (Basic Operations)

This section is intended to give you foundational knowledge about logic operations, assigning variables, and other simple concepts to prepare you for more complex operations.

本部分旨在为您提供有关逻辑运算,分配变量和其他简单概念的基础知识,以使您为更复杂的运算做准备。

快速笔记 (Quick note)

Indentation is not necessary in Octave.

在八度中不需要缩进。

  • Equal and not equal

    平等 不平等

1 == 1 % equal            1 ~= 2 % not equal
  • Comment

    评论

% this is a comment in Octave
  • And operator and Or operator

    运算符和 运算符

1 && 2 % and operator       1 || 2 % or operator
  • Assign a variable

    分配一个变量

a = 76 % assign variable a an integer
b = 'Octave' % assign variable b a string
  • Print with decimal places

    小数位 打印

disp(sprintf('2 decimals: %0.2f', a)) % print variable a with 2           %decimalsdisp(sprintf('6 decimals: %0.6f', a)) % print variable a with 6   %decimals
  • Format of decimal number

    十进制数字 格式

format short % this is the default format
format long % displays more decimals
  • Matrices and vectors

    矩阵 向量

% In Octave the semicolon implies go to the next lineA = [1 2; 3 4; 5 6]; % this is a 3x2 matrixv = [1 2 3]; % this is a row vector or a 1x3 matrixx = [1; 2; 3] % this is a column vector or a 3x1 matrix
  • Special matrices

    特殊 矩阵

A = ones(2,3); % creates a matrix of size 2x3 filled with 1B = zeros(1,3); % creates a matrix of size 1x3 filled with 0 C = rand(3,4); % returns a matrix with random elements between (0,1)D = randn(1,3); % Gaussian-distribution matrixE = eye(3,3); % returns the identity matrix
  • Incrementing

    增量式

v = 1:0.1:2; % start from 1, increment with 0.1, up to 2v = 1:6; % start from 1, increment with 1, up to 6
  • Histogram

    直方图

x = 
hist(x); % draws a histogram of x

移动数据 (Moving Data Around)

Here we will discuss how to play with the variables and data learnt above.

在这里,我们将讨论如何使用上面学习的变量和数据。

A = [1 2; 3 4; 5 6];
  • Get matrix dimensions

    获取矩阵 尺寸

size(A) % returns the dimension of matrix 3x2
size(A, 1) % returns the first dimension of matrix
size(A, 2) % returns the second dimension of matrix
length(A) % returns the longest dimension
  • Load file

    载入 档案

load file.dat % loads a specific file in the current directory
  • Show variables in current workspace

    在当前工作空间中 显示变量

who % show all the variables declared in the current scope
whos % for a more detailed version of who
  • Get data from specific file

    从特定文件 获取数据

v = cost(1:10);
  • Save file

    储存 档案

save helloWorld.txt v -ascii % saves a file in the current directory
  • Access elements in matrix

    矩阵中的 访问 元素

A(1, 2) % gives the number in row 1, column 2
A(2, :) % gives all row 2
A(: ,2) % gives all column 2
  • Replace elements

    替换 元素

A(: ,2) = [100; 101; 102] % replace elements in column 2
  • Concatenate matrices

    串联 矩阵

A = [1 2; 3 4; 5 6];
B = [7 8; 9 10; 11 12];
C = [A B] % concatenate horizontally
D = [A;B] % concatenate vertically

计算数据 (Computing Data)

Now that you know the basic principles in Octave, it is time to learn how to compute different variables and functions.

既然您已经了解了Octave的基本原理,就该学习如何计算不同的变量和函数了。

A = [1 2; 3 4; 5 6];
B = [7 8; 9 10; 11 12];
C = [1 1; 2 2];
  • Multiply matrices

    乘法 矩阵

A * C % multiplies matrix A with matrix C
% you should pay attention if the matrices can be multiplied
  • Element-wise operations

    按元素 操作

A .^ 2 % squares each cell in matrix A
log(A) % logs each cell in matrix A
exp(A) % exponentiates each cell in matrix A
abs(A) % absolute value of each cell in matrix A
A + 1 % add numbers to each cell in matrix A
  • Transpose matrix

    转置 矩阵

A' % transposes matrix A
  • Maximum value of matrix

    矩阵 最大值

max(A) % does column-wise maximum
  • Mathematical operations on matrix

    矩阵的 数学运算

sum(A) % sum of all elements in matrix A
prod(A) % product of all elements in matrix A
floor(A) % round down of all elements in matrix A
ceil(A) % round up of all elements in matrix A
  • Create random matrix

    创建 随机矩阵

rand(3) % creates a 3x3 random matrix
  • Convert matrix to vector

    矩阵 转换 为矢量

A(:) % convert matrix A to a vector
  • Inverse matrix

    矩阵

pinv(A) % invert matrix A

绘制数据 (Plotting Data)

An important part in developing good algorithms in ML is plotting data. By visualizing your data set and model, you could get a better idea of what needs improvement.

开发ML中好的算法的重要部分是绘制数据。 通过可视化数据集和模型,您可以更好地了解需要改进的地方。

t = [0:0.01:0.98];
y1 = sin(2 * pi * 4 * t);
plot(t, y1); % plots function y1 with the help of thold on; % allows you to print 2 graphs togethery2 = cos(2 * pi * 4 * t);
plot(t, y2) % plots function y2 with the help of t
  • Label the axis of a plot

    标记图 的轴

xlabel('time') % names the x-axis of the plot
ylabel('value') % names the y-axis of the plotlegend('sin', 'cos') % creates a legend of the plot
title('trigonometric plot') % sets the title o the plot
  • Save the plot

    保存 情节

rint -dpng 'trigoPlot.png' % saves the plot as an image
  • Get rid of figure

    摆脱 数字

close % gets rid of the current figure
  • Multiple figures at the save time

    节省 多个数字

figure(1); plot(t, y1) % plots the first figure
figure(2); plot(t, y2) % plots the second figure
  • Change the ranges on the axis

    更改 轴上 的范围

axis([0.5 1 -1 1]) % x-axis : 0.5 to 1  y-axis : -1 to 1
  • Clear figure

    清晰的 身影

clf % deletes the figure from memory

控制声明 (Control Statements)

In any programming language it is necessary to know how to use control statements as it can ease you work and make you more efficient.

在任何编程语言中,都有必要知道如何使用控制语句,因为它可以简化您的工作并提高您的效率。

  • For loop

    对于 循环

for i = 1:20,
  v(i) = (i + 1) * 2;
end;
  • While loop

    While 循环

i = 1; 
while i <= 5,
  x(i) = i * 100;
  i = i + 1;
end;
  • If and else

    如果 其他

v(1) = 100;
if v(1) == 99,
  disp('This statement is false');
elseif v(1) == 100,
  disp('This statement is true');
else v(1) == 101,
  disp('This statement is false');
end;

If you are not entirely sure what a specific command does or you want to learn more about how it works, you can type help name_of_command to see all the information regarding that command.

如果您不能完全确定特定命令的功能,或者想了解有关该命令如何工作的更多信息,可以键入help name_of_command来查看有关该命令的所有信息。

You can find the full documentation and download Octave from here.

您可以找到完整的文档并从此处下载Octave。

资源资源 (Resources)

[1]Andrew Ng, Machine Learning, Machine Learning course on Coursera.

[1] Nrew, 机器学习Coursera上的机器学习课程。

翻译自: https://levelup.gitconnected.com/develop-machine-learning-algorithms-with-octave-dbf10cf9caf3

octave 机器学习

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

octave 机器学习_使用Octave开发机器学习算法 的相关文章

随机推荐

  • java jvm监控实现_JVM及Java监控原理与实践

    简介 主要是介绍一下对运行Java程序的一些跟踪 以及对JVM内存等方面进行运维的一些方法 反解析class文件的工具使用 一般使用jd gui工具进行反编译class文件 有些jd gui无法反编译的class 可以使用luyten工具进
  • 关于video标签的巨坑

    事情是这样的 请求第一页的资源的时候 第一个位置是个视频 现在视频的src是写在video的source中的 第一个位置 但是切换到下一页的时候 下一页的数据的第一个位置也是视频 但是页面上显示的还是之前的 打开调试工具看 可以发现sour
  • Qt :非window子窗体的透明度设置

    问题的由来 心血来潮 想利用QTimer 配合 setWindowOpacity 方法来实现一个窗体淡入的效果 实验代码 粗糙的实验代码 void Widget on pushButton clicked QTimer timerOpaci
  • 3DMAX怎么把模型分开

    一 3dmax怎么把模型分开 1 怎样将一个合并过得物体分解成数个小物体呢 前提是经过合并过得 2 如果是成组的物体 只需点击工具栏 组 成组 3 如果是附加合并的物体 点击组的话 不会出现其他的命令 这时 要在修改面板分离 选中物体 右键
  • 空中旋球计算机控制系统,自动乒乓球发球机设计及其控制系统的研究

    摘要 为了使练习者能更好地学习乒乓球技术以达到健身和训练的目的 本文针对乒乓球发球的特点 从总体上设计了一种新型的乒乓球发球机 自动乒乓球发球机 本文综述了国内外乒乓球发球机的现状 对已有发球机的机械结构进行分析 根据所需实现的功能 提出了
  • IDEA使用教程最全汇总(持续更新)

    1 IDEA实用设置小技巧 2 IDEA常用快捷键 3 IDEA关联数据库 前言 本文记录IDEA实用的使用教程 以作记录 一 IDEA实用设置小技巧 1 IDEA去掉代码黄色下划线 在IDEA中根据设置的不同 有些代码页 当代码重复比较多
  • 【RabbitMQ分析】01 SimpleMessageListenerContainer原理分析

    往期推荐 sharding sphere 01 SQL路由 Nacos源码分析 02 获取配置流程 Java并发编程 03 MESI 内存屏障 Spring源码 11 Spring AOP之编程式事务 编程开发 01 日志框架 概述 Sim
  • 网络安全:制作 windows 和 linux 客户端恶意软件进行渗透

    实战 制作 Windows 恶意软件获取公司财务电脑 shell 实战 WinRAR 捆绑恶意程序并自动上线 MSF 实战 制作 Linux 恶意软件获取公司服务器 shell 实战 制作恶意 deb 软件包来触发后门 1 制作 Windo
  • python 使用上级目录的文件(相对路径,绝对路径)

    Python功能点实现 多方法访问上级目录中的文件 简书 1 相对路径 csv test b txt 2 绝对路径 from os path import dirname abspath dirname dirname abspath fi
  • php 随机生成指定金额范围内的随机数

    function random bag money total personal num min money money total 20 personal num 19 min money 1 money right money tota
  • CSS之设置图片宽度100%,高度等于宽度

    html代码如下 div class left div class img img src static img face 2 jpg div div stulus语法 img position relative width 100 hei
  • DDD-笔记

    先说下传统系统设计 大部分从数据库开始 自底向上的设计 这种设计会使系统的设计受到数据库的影响 会有比较大的局限性 比如说 数据库仅有数据 没有行为 而对现实世界的描述则会更加抽象 更加远离业务 开发团队通过与产品或客户的沟通 直接设计表模
  • Python 快速验证代理IP是否有效

    有时候 我们需要用到代理IP 比如在爬虫的时候 但是得到了IP之后 可能不知道怎么验证这些IP是不是有效的 这时候我们可以使用Python携带该IP来模拟访问某一个网站 如果多次未成功访问 则说明这个代理是无效的 代码如下 import r
  • mysql到hive调度工具_调度工具(ETL+任务流)

    1 区别ETL作业调度工具和任务流调度工具 kettle是一个ETL工具 ETL Extract Transform Load的缩写 即数据抽取 转换 装载的过程 kettle中文名称叫水壶 该项目的主程序员MATT 希望把各种数据放到一个
  • RMAN.DBMS_RCVCAT 版本错误处理

    oracle xml oms rman target sys oracle1 emdb catalog rman rman emdb Recovery Manager Release 10 2 0 5 0 Production on Wed
  • Java中的函数使用

    Java中函数是一段可重复使用的代码块 可接受输入参数并返回结果 函数的定义通常包括函数名 参数列表和返回类型 在Java中 函数也被看作是对象 具有属性和方法 本文将从多个方面详细阐述Java中函数的使用和注意事项 一 函数的定义和使用
  • Oracle---day01

    一 简单查询语句 1 去重查询 和mysql的一样 select distinct job from emp select distinct job deptno from emp 去除job相等且deptno相等的结果 2 查询员工年薪
  • Hanlp本地化安装

    环境说明 系统 centos7 x python版本 3 9 0 这里安装完整版本hanlp full 精简版会有不少问题出现 没有找到解决方案 官网安装地址 https hanlp hankcs com install html 2 x
  • HTML简介

    目录 话不多说 先上一个HELLO WORLD 什么是 HTML HTML 标签 HTML 文档 网页 例子解释 话不多说 先上一个HELLO WORLD h1 我的第一个标题 h1 p 我的第一个段落 p 什么是 HTML HTML 是用
  • octave 机器学习_使用Octave开发机器学习算法

    octave 机器学习 Octave is an open source high level programming language designed to perform efficient numerical computation