@@ -122,21 +122,22 @@ setMethod(f="run",
122
122
if (is(models(I ),' model_OR_model.seq' ))
123
123
{ # if a model or list then apply the metric
124
124
125
- k = length(unique(( results $ no_features )) )
125
+ k = length(searchlist )
126
126
ts.metric = numeric (k )
127
127
for (i in 1 : k )
128
128
{
129
- ts = results [results $ no_features == i ,]
129
+ ts = results [results $ no_features == searchlist [ i ] ,]
130
130
MET = calculate(MET ,ts $ actual ,ts $ predicted )
131
131
ts.metric [i ]= value(MET )
132
132
}
133
133
134
134
value = ts.metric
135
-
135
+ df = data.frame ( metric = name( MET ), mean = value , sd = NA )
136
136
} else
137
137
{
138
138
# if not a model or list then the metric has already been applied, we just need to choose the optimum
139
139
value = results $ mean
140
+ df = results
140
141
}
141
142
142
143
# locate optimum using a loess fit
@@ -152,6 +153,7 @@ setMethod(f="run",
152
153
lo_var_ind = searchlist [lo ]
153
154
output.value(I ,' chosen_vars' )= O [R < = lo_var_ind ]
154
155
output.value(I ,' smoothed' )= smoothed25
156
+ output.value(I ,' metric' )= df
155
157
156
158
return (I )
157
159
}
@@ -187,12 +189,36 @@ eval_loess=function(x,X,Y,k=10,p=0.66)
187
189
188
190
# ' forward_selection_plot
189
191
# '
190
- # ' plots the result of the evaluated models against the values the number of features within the search range.
192
+ # ' Plots the result of the evaluated models against the values the number of
193
+ # ' features within the search range for forward_selection_by_rank objects.
191
194
# '
192
195
# ' @import struct
193
196
# ' @export fs_line
194
197
# ' @examples
198
+ # ' # some data
199
+ # ' D = sbcms_dataset(filtered=TRUE)
200
+ # '
201
+ # ' # normalise, impute and scale then remove QCs
202
+ # ' P = pqn_norm(qc_label='QC',factor_name='class') +
203
+ # ' knn_impute(neighbours=5) +
204
+ # ' glog_transform(qc_label='QC',factor_name='class') +
205
+ # ' filter_smeta(mode='exclude',levels='QC',factor_name='class')
206
+ # ' P = method.apply(P,D)
207
+ # ' D = predicted(P)
208
+ # '
209
+ # ' # forward selection using a PLSDA model
210
+ # ' M = forward_selection_byrank(factor_name='class',
211
+ # ' min_no_vars=2,
212
+ # ' max_no_vars=11,
213
+ # ' variable_rank=1:2063) *
214
+ # ' (mean_centre() + PLSDA(number_components=1,
215
+ # ' factor_name='class'))
216
+ # ' M = run(M,D,balanced_accuracy())
217
+ # '
218
+ # ' # chart
195
219
# ' C = fs_line()
220
+ # ' chart.plot(C,M)
221
+ # '
196
222
fs_line <- setClass(
197
223
" fs_line" ,
198
224
contains = ' chart' ,
@@ -207,7 +233,7 @@ setMethod(f="chart.plot",
207
233
signature = c(" fs_line" ,' forward_selection_byrank' ),
208
234
definition = function (obj ,dobj )
209
235
{
210
- A = result( dobj )
236
+ A = dobj $ metric
211
237
A $ smoothed = output.value(dobj ,' smoothed' )
212
238
opt = length(output.value(dobj ,' chosen_vars' ))
213
239
A $ values = output.value(dobj ,' searchlist' )
0 commit comments