visual-studio-2010 - 在行 .`` 花瓣宽度`|]) 行上出现缺少资格错误

标签 visual-studio-2010 algorithm f# k-means

提前感谢您的任何回复,这个论坛上的答案对我的研究非常宝贵。我是一名学生,为了语言范式的研究项目而学习 F#,并尝试利用 http://trelford.com/blog/post/specialk.aspx 中的一个精彩示例。为了使用简单的 k 均值算法。我收到一个错误,我不知道如何修复,希望得到一些指导。非常有义务,这里是代码,错误是:在行上缺少资格错误。`花瓣宽度|])行

//代码来自http://trelford.com/blog/post/specialk.aspx

open System
open FSharp

type Iris = CsvProvider<irisDataFile>
let iris = Iris.Load(irisDataFile)
let irisData = iris.Data |> Seq.toArray
//
///// classifcations
let y = irisData |> Array.map (fun row -> row.Class)
/// feature vectors
let X = irisData |> Array.map (fun row -> 
  [|row.``Sepal Length`` 
    row.``Sepal Width`` 
    row.``Petal Length`` 
    row.``Petal Width`|])


//Computing k-means centroids:

let K = 3 // The Iris dataset is known to only have 3 clusters

let seed = 
  [|X.[0]; X.[1]; X.[2]|]  // pick bad centroids on purpose

let centroidResults = 
  KMeans.computeCentroids seed X |> Seq.take iterationLimit



(* K-Means Algorithm *)

/// Group all the vectors by the nearest center. 
let classify centroids vectors = 
  vectors |> Array.groupBy (fun v -> centroids |> Array.minBy (distance v))

/// Repeatedly classify the vectors, starting with the seed centroids
let computeCentroids seed vectors = 
  seed |> Seq.iterate (fun centers -> classify centers vectors |> Array.map (snd >> average))

最佳答案

看起来您在这里缺少一个反勾号:

row.``Petal Width`|])

应该是:

row.``Petal Width``|])

关于visual-studio-2010 - 在行 .`` 花瓣宽度`|]) 行上出现缺少资格错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19717536/

相关文章:

algorithm - TAOCP中的不相交集

f# - 部署到IIS应用程序时升级FSharp.Core版本,程序集引用错误

c# - 在运行时为报表设置数据源?

asp.net - Visual Studio 2010 Intellisense 不适用于 asp 标记

.net - 如何禁用VS PowerTools工具提示?

c++ - 在 C 和 C++ 库之间共享变量的困境

算法 - 组合和排列

算法 : random unique string

azure - 发布到 Azure 后无法将函数参数绑定(bind)到类型 TraceWriter

f# - 将结果列表转换为计算表达式中列表的结果?