首页 \ 问答 \ SVM分类 - R中的归一化(SVM classification - normalization in R)

SVM分类 - R中的归一化(SVM classification - normalization in R)

我想使用SVM分类。 在使用SVM模型之前,如何对数据集中每列的特征进行标准化(或缩放)?

train <- read.csv("train.csv")
test <- read.csv("test.csv")

svm.fit=svm(as.factor(type)~ ., data=train, core="libsvm",kernel="linear",cross=10, probability=TRUE)

I want to work with SVM classification. How is it possible to normalize (or scale) the features per column in my dataset before i use the SVM model?

train <- read.csv("train.csv")
test <- read.csv("test.csv")

svm.fit=svm(as.factor(type)~ ., data=train, core="libsvm",kernel="linear",cross=10, probability=TRUE)

原文:https://stackoverflow.com/questions/36728598
更新时间:2023-12-26 07:12

最满意答案

这应该工作......

Sub Btn_NextNum_Click()
Dim KeyStart As Range, LastNum, NewNum

    Set KeyStart = Sheets("Sheet2").[C2]   ' bad bad hard coding, but you asked for it
    If KeyStart(2, 1) = "" Then
        LastNum = KeyStart
    Else
        LastNum = KeyStart(KeyStart.End(xlDown).Row - 1, 1)
    End If

    NewNum = "CI" & Val(Mid(LastNum, 3)) + 1

    If KeyStart(2, 1) = "" Then
        KeyStart(2, 1) = NewNum
    Else
        KeyStart(KeyStart.End(xlDown).Row, 1) = NewNum
    End If

    Sheets("Sheet1").[D3] = NewNum         ' bad bad hard coding, but you asked for it

End Sub

注意我讨厌单元格地址的硬编码...恕我直言,最好使用范围名称作为键列和输出单元格的开头,或者将输出定向到Selection以便按钮可以放置光标可能的NextNum。


This should work ...

Sub Btn_NextNum_Click()
Dim KeyStart As Range, LastNum, NewNum

    Set KeyStart = Sheets("Sheet2").[C2]   ' bad bad hard coding, but you asked for it
    If KeyStart(2, 1) = "" Then
        LastNum = KeyStart
    Else
        LastNum = KeyStart(KeyStart.End(xlDown).Row - 1, 1)
    End If

    NewNum = "CI" & Val(Mid(LastNum, 3)) + 1

    If KeyStart(2, 1) = "" Then
        KeyStart(2, 1) = NewNum
    Else
        KeyStart(KeyStart.End(xlDown).Row, 1) = NewNum
    End If

    Sheets("Sheet1").[D3] = NewNum         ' bad bad hard coding, but you asked for it

End Sub

Note I hate hard coding of cell addresses ... IMHO it would be better to use range names for the start of the key column and the output cell or direct the output to Selection so that the button places your NextNum whereever the cursor might be.

相关问答

更多
  • 文件格式将允许最多255个字符的工作表名称,但如果Excel UI不希望超过31个字符,请勿尝试超出31.应用程序充满了奇怪的无证限制和怪癖,并将文件在规范内,但不在测试人员测试的范围内通常会导致真正的奇怪行为。 (个人最喜欢的例子:使用Excel 4.0字节码为if()函数,在具有Excel 97风格的字符串的文件中,禁用Excel 97中的粗体工具栏按钮。) The file format would permit up to 255-character worksheet names, but if ...
  • 如果我记得正确 - 我对此的记忆有点模糊,自从我把Excel PIA分开以来已经很久了 - 就这样。 一个事件本质上是一个对象在发生事件时调用的方法。 在.NET中,事件是委托,简单而简单。 但是在COM中,将很多事件回调组织到接口中是很常见的。 因此,您在给定对象上有两个接口 - “传入”接口,您希望其他人呼叫的方法以及“传出”接口,当事件发生时,您希望对其他人发送的方法。 在非托管元数据(类型库)中,对于可创建对象,存在以下三个方面的定义:传入接口,传出接口和coclass,说“我是一个可创建的对象来实 ...
  • 这应该工作...... Sub Btn_NextNum_Click() Dim KeyStart As Range, LastNum, NewNum Set KeyStart = Sheets("Sheet2").[C2] ' bad bad hard coding, but you asked for it If KeyStart(2, 1) = "" Then LastNum = KeyStart Else LastNum = KeyStar ...
  • 要访问场景中的工作簿,请使用: Globals.ThisAddIn.Application.Workbooks... MSDN参考: 编程VSTO加载项 下面的代码示例演示如何使用“应用程序”字段在VSTO加载项中为Microsoft Office Excel创建新工作簿。 此示例旨在从ThisAddIn类运行。 Excel.Workbook newWorkbook = this.Application.Workbooks.Add(System.Type.Missing); 要从ThisAd ...
  • 尝试这个。 我添加了另一个集合yCol,它包含来自不同列的数据,但使用与xCol相同的密钥。 Sub Parse_data() Dim xRCount As Long Dim xSht As Worksheet, xNSht As Worksheet Dim I As Long Dim xTRrow As Integer Dim xCol As New Collection Dim yCol as New Collection Dim xTitle As String Dim xSUpdate As Boo ...
  • 如果你知道它将进入一个列,你可以简单地使用2D数组开始: Dim bfb(1 To 3000, 1 to 1) As Integer 并改变这个: bfb(n) = BFval 对此: bfb(n, 1) = BFval If you know it will go into a column, you can simply use a 2D array to start with: Dim bfb(1 To 3000, 1 to 1) As Integer and change this: bfb ...
  • 假设在worksheet1 ,产品代码从A1开始, worksheet1的产品代码也从A1开始,那么您可以组合VLOOKUP()和IFERROR() 。 在worksheet1 B1列中,产品代码插入旁边: =IFERROR(IF(VLOOKUP(worksheet1!A1,worksheet2!$A:$A,1,FALSE)=worksheet1!A1, "In Stock"), "Out of Stock") 这样可以查看worksheet1中是否可以找到worksheet2的产品代码。 如果找不到, ...
  • 我(希望是正确的)调查结果: 工作表名称中的UTF-8只能以BIFF8格式使用。 Spreadsheet_Excel_Writer_Worksheet构造函数将UTF-8硬编码为工作表名称的输入编码。 没有内置方法来重命名工作表。 因此需要注意: 使用\Spreadsheet_Excel_Writer_Workbook::setVersion()尽快将BIFF8设置为格式(有扩展工作表限制等附加好处): $workbook->setVersion(8); 如果您不使用UTF-8(例如,因为它是遗留项目), ...
  • 工作表添加操作的返回对象是工作表本身。 更改该对象上的工作表名称: var ws = wb.Worksheets.Add(dt); ws.Name = "my sheet name"; 此外,因为您使用DataTable作为工作表的源,所以您必须确保该表具有名称: dt.TableName = "my sheet name"; MSDN参考: https://msdn.microsoft.com/en-us/library/microsoft.office.tools.excel.worksheet.n ...
  • 1-您需要使用Set关键字来分配对象变量。 2-您无法直接将表变量分配给字符串,但需要通过Worksheets集合进行索引 3-你不能Debug.Print一个工作表,但只有它的名字或里面的一些单元格 Sub TestIt() Dim ws2 As Worksheet, ws1 As Worksheet Set ws2 = ActiveWorkbook.ActiveSheet Set ws1 = ThisWorkbook.Worksheets("Belgium") Deb ...

相关文章

更多

最新问答

更多
  • 如何检索Ember.js模型的所有属性(How to retrieve all properties of an Ember.js model)
  • maven中snapshot快照库和release发布库的区别和作用
  • arraylist中的搜索元素(Search element in arraylist)
  • 从mysli_fetch_array中获取选定的值并输出(Get selected value from mysli_fetch_array and output)
  • Windows Phone上的可用共享扩展(Available Share Extensions on Windows Phone)
  • 如何在命令提示符下将日期设置为文件名(How to set file name as date in command prompt)
  • 如何在Laravel 5.2中使用paginate与关系?(How to use paginate with relationships in Laravel 5.2?)
  • 从iframe访问父页面的id元素(accessing id element of parent page from iframe)
  • linux的常用命令干什么用的
  • Feign Client + Eureka POST请求正文(Feign Client + Eureka POST request body)
  • 怎么删除禁用RHEL/CentOS 7上不需要的服务
  • 为什么Gradle运行测试两次?(Why does Gradle run tests twice?)
  • 由于有四个新控制器,Auth刀片是否有任何变化?(Are there any changes in Auth blades due to four new controllers?)
  • 如何交换返回集中的行?(How to swap rows in a return set?)
  • 在android中的活动之间切换?(Switching between activities in android?)
  • Perforce:如何从Depot到Workspace丢失文件?(Perforce: how to get missing file from Depot to Workspace?)
  • Webform页面避免运行服务器(Webform page avoiding runat server)
  • 在ios 7中的UITableView部分周围绘制边界线(draw borderline around UITableView section in ios 7)
  • 内存布局破解(memory layout hack)
  • 使用Boost.Spirit Qi和Lex时的空白队长(Whitespace skipper when using Boost.Spirit Qi and Lex)
  • 我们可以有一个调度程序,你可以异步添加东西,但会同步按顺序执行吗?(Can we have a dispatcher that you can add things todo asynchronously but will be executed in that order synchronously?)
  • “FROM a,b”和“FROM a FULL OUTER JOIN b”之间有什么区别?(What is the difference between “FROM a, b” and “FROM a FULL OUTER JOIN b”?)
  • Java中的不可变类(Immutable class in Java)
  • bat批处理文件结果导出到txt
  • WordPress发布查询(WordPress post query)
  • 如何在关系数据库中存储与IPv6兼容的地址(How to store IPv6-compatible address in a relational database)
  • 是否可以检查对象值的条件并返回密钥?(Is it possible to check the condition of a value of an object and JUST return the key?)
  • 德州新起点计算机培训学校主要课程有什么?
  • GEP分段错误LLVM C ++ API(GEP segmentation fault LLVM C++ API)
  • “latin1_german1_ci”整理来自哪里?(Where is “latin1_german1_ci” collation coming from?)