gpt4 book ai didi

visual-studio-2010 - 在行 .`` Petal Width`|]) 行上获取缺少资格错误

转载 作者:塔克拉玛干 更新时间:2023-11-03 03:43:49 28 4
gpt4 key购买 nike

预先感谢您的任何回复,这个论坛上的答案对我的研究非常宝贵。我是一名为了语言范式研究项目而学习 F# 的学生,我正在尝试利用 http://trelford.com/blog/post/specialk.aspx 中的一个极好的例子。为了玩一个简单的k-means算法。我收到一个错误,我不确定如何修复,希望得到一些指导。非常有责任,这是代码,错误是:Getting Missing Qualification Error on row.`Petal Width|]) Line

//代码来自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 - 在行 .`` Petal Width`|]) 行上获取缺少资格错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19717536/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com