Source file impute.ml

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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
let () = Wrap_utils.init ();;
let ns = Py.import "sklearn.impute"

module KNNImputer = struct
type t = Py.Object.t
let of_pyobject x = x
let to_pyobject x = x
                  let create ?missing_values ?n_neighbors ?weights ?metric ?copy ?add_indicator () =
                     Py.Module.get_function_with_keywords ns "KNNImputer"
                       [||]
                       (Wrap_utils.keyword_args [("missing_values", Wrap_utils.Option.map missing_values (function
| `String x -> Py.String.of_string x
| `None -> Py.String.of_string "None"
| `PyObject x -> Wrap_utils.id x
)); ("n_neighbors", Wrap_utils.Option.map n_neighbors Py.Int.of_int); ("weights", Wrap_utils.Option.map weights (function
| `Uniform -> Py.String.of_string "uniform"
| `Distance -> Py.String.of_string "distance"
| `Callable x -> Wrap_utils.id x
)); ("metric", Wrap_utils.Option.map metric (function
| `Nan_euclidean -> Py.String.of_string "nan_euclidean"
| `Callable x -> Wrap_utils.id x
)); ("copy", Wrap_utils.Option.map copy Py.Bool.of_bool); ("add_indicator", Wrap_utils.Option.map add_indicator Py.Bool.of_bool)])

let fit ?y ~x self =
   Py.Module.get_function_with_keywords self "fit"
     [||]
     (Wrap_utils.keyword_args [("y", y); ("X", Some(x ))])

let fit_transform ?y ?fit_params ~x self =
   Py.Module.get_function_with_keywords self "fit_transform"
     [||]
     (List.rev_append (Wrap_utils.keyword_args [("y", Wrap_utils.Option.map y Ndarray.to_pyobject); ("X", Some(x |> Ndarray.to_pyobject))]) (match fit_params with None -> [] | Some x -> x))
     |> Ndarray.of_pyobject
let get_params ?deep self =
   Py.Module.get_function_with_keywords self "get_params"
     [||]
     (Wrap_utils.keyword_args [("deep", Wrap_utils.Option.map deep Py.Bool.of_bool)])

let set_params ?params self =
   Py.Module.get_function_with_keywords self "set_params"
     [||]
     (match params with None -> [] | Some x -> x)

let transform ~x self =
   Py.Module.get_function_with_keywords self "transform"
     [||]
     (Wrap_utils.keyword_args [("X", Some(x |> Ndarray.to_pyobject))])
     |> Ndarray.of_pyobject
let indicator_ self =
  match Py.Object.get_attr_string self "indicator_" with
| None -> raise (Wrap_utils.Attribute_not_found "indicator_")
| Some x -> Wrap_utils.id x
let to_string self = Py.Object.to_string self
let show self = to_string self
let pp formatter self = Format.fprintf formatter "%s" (show self)

end
module MissingIndicator = struct
type t = Py.Object.t
let of_pyobject x = x
let to_pyobject x = x
                  let create ?missing_values ?features ?sparse ?error_on_new () =
                     Py.Module.get_function_with_keywords ns "MissingIndicator"
                       [||]
                       (Wrap_utils.keyword_args [("missing_values", Wrap_utils.Option.map missing_values (function
| `String x -> Py.String.of_string x
| `PyObject x -> Wrap_utils.id x
)); ("features", Wrap_utils.Option.map features Py.String.of_string); ("sparse", Wrap_utils.Option.map sparse (function
| `Bool x -> Py.Bool.of_bool x
| `Auto -> Py.String.of_string "auto"
)); ("error_on_new", Wrap_utils.Option.map error_on_new Py.Bool.of_bool)])

                  let fit ?y ~x self =
                     Py.Module.get_function_with_keywords self "fit"
                       [||]
                       (Wrap_utils.keyword_args [("y", y); ("X", Some(x |> (function
| `Ndarray x -> Ndarray.to_pyobject x
| `SparseMatrix x -> Csr_matrix.to_pyobject x
)))])

                  let fit_transform ?y ~x self =
                     Py.Module.get_function_with_keywords self "fit_transform"
                       [||]
                       (Wrap_utils.keyword_args [("y", y); ("X", Some(x |> (function
| `Ndarray x -> Ndarray.to_pyobject x
| `SparseMatrix x -> Csr_matrix.to_pyobject x
)))])
                       |> Ndarray.of_pyobject
let get_params ?deep self =
   Py.Module.get_function_with_keywords self "get_params"
     [||]
     (Wrap_utils.keyword_args [("deep", Wrap_utils.Option.map deep Py.Bool.of_bool)])

let set_params ?params self =
   Py.Module.get_function_with_keywords self "set_params"
     [||]
     (match params with None -> [] | Some x -> x)

                  let transform ~x self =
                     Py.Module.get_function_with_keywords self "transform"
                       [||]
                       (Wrap_utils.keyword_args [("X", Some(x |> (function
| `Ndarray x -> Ndarray.to_pyobject x
| `SparseMatrix x -> Csr_matrix.to_pyobject x
)))])
                       |> Ndarray.of_pyobject
let features_ self =
  match Py.Object.get_attr_string self "features_" with
| None -> raise (Wrap_utils.Attribute_not_found "features_")
| Some x -> Ndarray.of_pyobject x
let to_string self = Py.Object.to_string self
let show self = to_string self
let pp formatter self = Format.fprintf formatter "%s" (show self)

end
module SimpleImputer = struct
type t = Py.Object.t
let of_pyobject x = x
let to_pyobject x = x
                  let create ?missing_values ?strategy ?fill_value ?verbose ?copy ?add_indicator () =
                     Py.Module.get_function_with_keywords ns "SimpleImputer"
                       [||]
                       (Wrap_utils.keyword_args [("missing_values", Wrap_utils.Option.map missing_values (function
| `String x -> Py.String.of_string x
| `PyObject x -> Wrap_utils.id x
)); ("strategy", Wrap_utils.Option.map strategy Py.String.of_string); ("fill_value", Wrap_utils.Option.map fill_value (function
| `String x -> Py.String.of_string x
| `PyObject x -> Wrap_utils.id x
)); ("verbose", Wrap_utils.Option.map verbose Py.Int.of_int); ("copy", Wrap_utils.Option.map copy Py.Bool.of_bool); ("add_indicator", Wrap_utils.Option.map add_indicator Py.Bool.of_bool)])

                  let fit ?y ~x self =
                     Py.Module.get_function_with_keywords self "fit"
                       [||]
                       (Wrap_utils.keyword_args [("y", y); ("X", Some(x |> (function
| `Ndarray x -> Ndarray.to_pyobject x
| `SparseMatrix x -> Csr_matrix.to_pyobject x
)))])

let fit_transform ?y ?fit_params ~x self =
   Py.Module.get_function_with_keywords self "fit_transform"
     [||]
     (List.rev_append (Wrap_utils.keyword_args [("y", Wrap_utils.Option.map y Ndarray.to_pyobject); ("X", Some(x |> Ndarray.to_pyobject))]) (match fit_params with None -> [] | Some x -> x))
     |> Ndarray.of_pyobject
let get_params ?deep self =
   Py.Module.get_function_with_keywords self "get_params"
     [||]
     (Wrap_utils.keyword_args [("deep", Wrap_utils.Option.map deep Py.Bool.of_bool)])

let set_params ?params self =
   Py.Module.get_function_with_keywords self "set_params"
     [||]
     (match params with None -> [] | Some x -> x)

                  let transform ~x self =
                     Py.Module.get_function_with_keywords self "transform"
                       [||]
                       (Wrap_utils.keyword_args [("X", Some(x |> (function
| `Ndarray x -> Ndarray.to_pyobject x
| `SparseMatrix x -> Csr_matrix.to_pyobject x
)))])
                       |> Ndarray.of_pyobject
let statistics_ self =
  match Py.Object.get_attr_string self "statistics_" with
| None -> raise (Wrap_utils.Attribute_not_found "statistics_")
| Some x -> Ndarray.of_pyobject x
let indicator_ self =
  match Py.Object.get_attr_string self "indicator_" with
| None -> raise (Wrap_utils.Attribute_not_found "indicator_")
| Some x -> Wrap_utils.id x
let to_string self = Py.Object.to_string self
let show self = to_string self
let pp formatter self = Format.fprintf formatter "%s" (show self)

end