/
predictoutput.jl
116 lines (105 loc) · 2.46 KB
/
predictoutput.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
##### Beginning of file
import DataFrames
"""
"""
struct ImmutablePredictionsSingleLabelInt2StringTransformer <:
AbstractEstimator
index::T1 where T1 <: Integer
levels::T2 where T2 <: AbstractVector
end
"""
"""
function set_feature_contrasts!(
x::ImmutablePredictionsSingleLabelInt2StringTransformer,
feature_contrasts::AbstractFeatureContrasts,
)
return nothing
end
"""
"""
function get_underlying(
x::ImmutablePredictionsSingleLabelInt2StringTransformer;
saving::Bool = false,
loading::Bool = false,
)
return nothing
end
"""
"""
function get_history(
x::ImmutablePredictionsSingleLabelInt2StringTransformer;
saving::Bool = false,
loading::Bool = false,
)
return nothing
end
"""
"""
function parse_functions!(
transformer::ImmutablePredictionsSingleLabelInt2StringTransformer,
)
return nothing
end
"""
"""
function fit!(
transformer::ImmutablePredictionsSingleLabelInt2StringTransformer,
varargs...;
kwargs...
)
if length(varargs) == 1
return varargs[1]
else
return varargs
end
end
"""
"""
function predict(
transformer::ImmutablePredictionsSingleLabelInt2StringTransformer,
single_labelpredictions::AbstractVector;
kwargs...
)
single_labelpredictions = parse.(Int, single_labelpredictions)
labelint2stringmap = _getlabelint2stringmap(
transformer.levels,
transformer.index,
)
result = Vector{String}(length(single_labelpredictions))
for i = 1:length(result)
result[i] = labelint2stringmap[single_labelpredictions[i]]
end
return result
end
"""
"""
function predict(
transformer::ImmutablePredictionsSingleLabelInt2StringTransformer,
single_labelpredictions::DataFrames.AbstractDataFrame;
kwargs...
)
label_names = DataFrames.names(single_labelpredictions)
result = DataFrames.DataFrame()
for i = 1:length(label_names)
result[label_names[i]] = predict(
transformer,
single_labelpredictions[label_names[i]];
kwargs...
)
end
return result
end
"""
"""
function predict_proba(
transformer::ImmutablePredictionsSingleLabelInt2StringTransformer,
varargs...;
kwargs...
)
if length(varargs) == 1
return varargs[1]
else
return varargs
end
end
##### End of file