|
10 | 10 | """
|
11 | 11 | Assess model accuracy on the basis of the correlations of row vectors of Chat and
|
12 | 12 | C or Shat and S. Ideally the target words have highest correlations on the diagonal
|
13 |
| -of the pertinent correlation matrices. |
| 13 | +of the pertinent correlation matrices. Homophones support option is implemented. |
14 | 14 | """
|
15 | 15 | function eval_SC end
|
16 | 16 |
|
| 17 | + |
| 18 | +""" |
| 19 | +Assess model accuracy on the basis of the correlations of row vectors of Chat and |
| 20 | +C or Shat and S. Count it as correct if one of the top k candidates is correct. |
| 21 | +Homophones support option is implemented. |
| 22 | +""" |
| 23 | +function eval_SC_loose end |
| 24 | + |
17 | 25 | """
|
18 | 26 | accuracy_comprehension(::Matrix, ::Matrix) -> ::Comp_Acc_Struct
|
19 | 27 |
|
@@ -257,6 +265,79 @@ function eval_SC_chucks(SChat,SC,s,batch_size,data,target_col)
|
257 | 265 | sum(v)
|
258 | 266 | end
|
259 | 267 |
|
| 268 | +""" |
| 269 | + eval_SC_loose(SChat, SC, k) |
| 270 | +
|
| 271 | +Assess model accuracy on the basis of the correlations of row vectors of Chat and |
| 272 | +C or Shat and S. Count it as correct if one of the top k candidates is correct. |
| 273 | +
|
| 274 | +... |
| 275 | +# Obligatory Arguments |
| 276 | +- `SChat::Union{SparseMatrixCSC, Matrix}`: the Chat or Shat matrix |
| 277 | +- `SC::Union{SparseMatrixCSC, Matrix}`: the C or S matrix |
| 278 | +- `k`: top k candidates |
| 279 | +
|
| 280 | +```julia |
| 281 | +eval_SC_loose(Chat, cue_obj.C, k) |
| 282 | +eval_SC_loose(Shat, S, k) |
| 283 | +``` |
| 284 | +... |
| 285 | +""" |
| 286 | +function eval_SC_loose(SChat, SC, k) |
| 287 | + total = size(SChat, 1) |
| 288 | + correct = 0 |
| 289 | + rSC = cor(convert(Matrix{Float64}, SChat), convert(Matrix{Float64}, SC), dims=2) |
| 290 | + |
| 291 | + for i in 1:total |
| 292 | + p = sortperm(rSC[i,:],rev=true) |
| 293 | + p = p[1:k,:] |
| 294 | + if i in p |
| 295 | + correct += 1 |
| 296 | + end |
| 297 | + end |
| 298 | + return correct/total |
| 299 | +end |
| 300 | + |
| 301 | +""" |
| 302 | + eval_SC_loose(SChat,SC,k,data,target_col) |
| 303 | +
|
| 304 | +Assess model accuracy on the basis of the correlations of row vectors of Chat and |
| 305 | +C or Shat and S. Count it as correct if one of the top k candidates is correct. |
| 306 | +Support for homophones. |
| 307 | +
|
| 308 | +... |
| 309 | +# Obligatory Arguments |
| 310 | +- `SChat::Union{SparseMatrixCSC, Matrix}`: the Chat or Shat matrix |
| 311 | +- `SC::Union{SparseMatrixCSC, Matrix}`: the C or S matrix |
| 312 | +- `k`: top k candidates |
| 313 | +- `data`: datasets |
| 314 | +- `target_col`: target column name |
| 315 | +
|
| 316 | +```julia |
| 317 | +eval_SC_loose(Chat, cue_obj.C, k, latin, :Word) |
| 318 | +eval_SC_loose(Shat, S, k, latin, :Word) |
| 319 | +``` |
| 320 | +... |
| 321 | +""" |
| 322 | +function eval_SC_loose(SChat,SC,k,data,target_col) |
| 323 | + total = size(SChat, 1) |
| 324 | + correct = 0 |
| 325 | + rSC = cor(convert(Matrix{Float64}, SChat), convert(Matrix{Float64}, SC), dims=2) |
| 326 | + |
| 327 | + for i in 1:total |
| 328 | + p = sortperm(rSC[i,:],rev=true) |
| 329 | + p = p[1:k] |
| 330 | + if i in p |
| 331 | + correct += 1 |
| 332 | + else |
| 333 | + if data[i,target_col] in data[p,:Word] |
| 334 | + correct += 1 |
| 335 | + end |
| 336 | + end |
| 337 | + end |
| 338 | + return correct/total |
| 339 | +end |
| 340 | + |
260 | 341 | """
|
261 | 342 | eval_manual(::Array, ::DataFrame, ::Dict) -> ::Nothing
|
262 | 343 |
|
|
0 commit comments