@huggingface/tasks 0.13.1-test → 0.13.1-test2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (198) hide show
  1. package/package.json +4 -2
  2. package/src/dataset-libraries.ts +89 -0
  3. package/src/default-widget-inputs.ts +718 -0
  4. package/src/gguf.ts +40 -0
  5. package/src/hardware.ts +482 -0
  6. package/src/index.ts +59 -0
  7. package/src/library-to-tasks.ts +76 -0
  8. package/src/local-apps.ts +412 -0
  9. package/src/model-data.ts +149 -0
  10. package/src/model-libraries-downloads.ts +18 -0
  11. package/src/model-libraries-snippets.ts +1128 -0
  12. package/src/model-libraries.ts +820 -0
  13. package/src/pipelines.ts +698 -0
  14. package/src/snippets/common.ts +39 -0
  15. package/src/snippets/curl.spec.ts +94 -0
  16. package/src/snippets/curl.ts +120 -0
  17. package/src/snippets/index.ts +7 -0
  18. package/src/snippets/inputs.ts +167 -0
  19. package/src/snippets/js.spec.ts +148 -0
  20. package/src/snippets/js.ts +305 -0
  21. package/src/snippets/python.spec.ts +144 -0
  22. package/src/snippets/python.ts +321 -0
  23. package/src/snippets/types.ts +16 -0
  24. package/src/tasks/audio-classification/about.md +86 -0
  25. package/src/tasks/audio-classification/data.ts +81 -0
  26. package/src/tasks/audio-classification/inference.ts +52 -0
  27. package/src/tasks/audio-classification/spec/input.json +35 -0
  28. package/src/tasks/audio-classification/spec/output.json +11 -0
  29. package/src/tasks/audio-to-audio/about.md +56 -0
  30. package/src/tasks/audio-to-audio/data.ts +70 -0
  31. package/src/tasks/automatic-speech-recognition/about.md +90 -0
  32. package/src/tasks/automatic-speech-recognition/data.ts +82 -0
  33. package/src/tasks/automatic-speech-recognition/inference.ts +160 -0
  34. package/src/tasks/automatic-speech-recognition/spec/input.json +35 -0
  35. package/src/tasks/automatic-speech-recognition/spec/output.json +38 -0
  36. package/src/tasks/chat-completion/inference.ts +322 -0
  37. package/src/tasks/chat-completion/spec/input.json +350 -0
  38. package/src/tasks/chat-completion/spec/output.json +206 -0
  39. package/src/tasks/chat-completion/spec/stream_output.json +213 -0
  40. package/src/tasks/common-definitions.json +100 -0
  41. package/src/tasks/depth-estimation/about.md +45 -0
  42. package/src/tasks/depth-estimation/data.ts +70 -0
  43. package/src/tasks/depth-estimation/inference.ts +35 -0
  44. package/src/tasks/depth-estimation/spec/input.json +25 -0
  45. package/src/tasks/depth-estimation/spec/output.json +16 -0
  46. package/src/tasks/document-question-answering/about.md +53 -0
  47. package/src/tasks/document-question-answering/data.ts +85 -0
  48. package/src/tasks/document-question-answering/inference.ts +110 -0
  49. package/src/tasks/document-question-answering/spec/input.json +85 -0
  50. package/src/tasks/document-question-answering/spec/output.json +36 -0
  51. package/src/tasks/feature-extraction/about.md +72 -0
  52. package/src/tasks/feature-extraction/data.ts +57 -0
  53. package/src/tasks/feature-extraction/inference.ts +40 -0
  54. package/src/tasks/feature-extraction/spec/input.json +47 -0
  55. package/src/tasks/feature-extraction/spec/output.json +15 -0
  56. package/src/tasks/fill-mask/about.md +51 -0
  57. package/src/tasks/fill-mask/data.ts +79 -0
  58. package/src/tasks/fill-mask/inference.ts +62 -0
  59. package/src/tasks/fill-mask/spec/input.json +38 -0
  60. package/src/tasks/fill-mask/spec/output.json +29 -0
  61. package/src/tasks/image-classification/about.md +50 -0
  62. package/src/tasks/image-classification/data.ts +88 -0
  63. package/src/tasks/image-classification/inference.ts +52 -0
  64. package/src/tasks/image-classification/spec/input.json +35 -0
  65. package/src/tasks/image-classification/spec/output.json +11 -0
  66. package/src/tasks/image-feature-extraction/about.md +23 -0
  67. package/src/tasks/image-feature-extraction/data.ts +59 -0
  68. package/src/tasks/image-segmentation/about.md +63 -0
  69. package/src/tasks/image-segmentation/data.ts +99 -0
  70. package/src/tasks/image-segmentation/inference.ts +69 -0
  71. package/src/tasks/image-segmentation/spec/input.json +45 -0
  72. package/src/tasks/image-segmentation/spec/output.json +26 -0
  73. package/src/tasks/image-text-to-text/about.md +76 -0
  74. package/src/tasks/image-text-to-text/data.ts +102 -0
  75. package/src/tasks/image-to-3d/about.md +62 -0
  76. package/src/tasks/image-to-3d/data.ts +75 -0
  77. package/src/tasks/image-to-image/about.md +129 -0
  78. package/src/tasks/image-to-image/data.ts +101 -0
  79. package/src/tasks/image-to-image/inference.ts +68 -0
  80. package/src/tasks/image-to-image/spec/input.json +55 -0
  81. package/src/tasks/image-to-image/spec/output.json +12 -0
  82. package/src/tasks/image-to-text/about.md +61 -0
  83. package/src/tasks/image-to-text/data.ts +82 -0
  84. package/src/tasks/image-to-text/inference.ts +143 -0
  85. package/src/tasks/image-to-text/spec/input.json +34 -0
  86. package/src/tasks/image-to-text/spec/output.json +14 -0
  87. package/src/tasks/index.ts +312 -0
  88. package/src/tasks/keypoint-detection/about.md +57 -0
  89. package/src/tasks/keypoint-detection/data.ts +50 -0
  90. package/src/tasks/mask-generation/about.md +65 -0
  91. package/src/tasks/mask-generation/data.ts +55 -0
  92. package/src/tasks/object-detection/about.md +37 -0
  93. package/src/tasks/object-detection/data.ts +86 -0
  94. package/src/tasks/object-detection/inference.ts +75 -0
  95. package/src/tasks/object-detection/spec/input.json +31 -0
  96. package/src/tasks/object-detection/spec/output.json +50 -0
  97. package/src/tasks/placeholder/about.md +15 -0
  98. package/src/tasks/placeholder/data.ts +21 -0
  99. package/src/tasks/placeholder/spec/input.json +35 -0
  100. package/src/tasks/placeholder/spec/output.json +17 -0
  101. package/src/tasks/question-answering/about.md +56 -0
  102. package/src/tasks/question-answering/data.ts +75 -0
  103. package/src/tasks/question-answering/inference.ts +99 -0
  104. package/src/tasks/question-answering/spec/input.json +67 -0
  105. package/src/tasks/question-answering/spec/output.json +29 -0
  106. package/src/tasks/reinforcement-learning/about.md +167 -0
  107. package/src/tasks/reinforcement-learning/data.ts +75 -0
  108. package/src/tasks/sentence-similarity/about.md +97 -0
  109. package/src/tasks/sentence-similarity/data.ts +101 -0
  110. package/src/tasks/sentence-similarity/inference.ts +32 -0
  111. package/src/tasks/sentence-similarity/spec/input.json +40 -0
  112. package/src/tasks/sentence-similarity/spec/output.json +12 -0
  113. package/src/tasks/summarization/about.md +58 -0
  114. package/src/tasks/summarization/data.ts +76 -0
  115. package/src/tasks/summarization/inference.ts +57 -0
  116. package/src/tasks/summarization/spec/input.json +42 -0
  117. package/src/tasks/summarization/spec/output.json +14 -0
  118. package/src/tasks/table-question-answering/about.md +43 -0
  119. package/src/tasks/table-question-answering/data.ts +59 -0
  120. package/src/tasks/table-question-answering/inference.ts +61 -0
  121. package/src/tasks/table-question-answering/spec/input.json +44 -0
  122. package/src/tasks/table-question-answering/spec/output.json +40 -0
  123. package/src/tasks/tabular-classification/about.md +65 -0
  124. package/src/tasks/tabular-classification/data.ts +68 -0
  125. package/src/tasks/tabular-regression/about.md +87 -0
  126. package/src/tasks/tabular-regression/data.ts +57 -0
  127. package/src/tasks/text-classification/about.md +173 -0
  128. package/src/tasks/text-classification/data.ts +103 -0
  129. package/src/tasks/text-classification/inference.ts +51 -0
  130. package/src/tasks/text-classification/spec/input.json +35 -0
  131. package/src/tasks/text-classification/spec/output.json +11 -0
  132. package/src/tasks/text-generation/about.md +154 -0
  133. package/src/tasks/text-generation/data.ts +114 -0
  134. package/src/tasks/text-generation/inference.ts +200 -0
  135. package/src/tasks/text-generation/spec/input.json +219 -0
  136. package/src/tasks/text-generation/spec/output.json +179 -0
  137. package/src/tasks/text-generation/spec/stream_output.json +103 -0
  138. package/src/tasks/text-to-3d/about.md +62 -0
  139. package/src/tasks/text-to-3d/data.ts +56 -0
  140. package/src/tasks/text-to-audio/inference.ts +143 -0
  141. package/src/tasks/text-to-audio/spec/input.json +31 -0
  142. package/src/tasks/text-to-audio/spec/output.json +17 -0
  143. package/src/tasks/text-to-image/about.md +96 -0
  144. package/src/tasks/text-to-image/data.ts +100 -0
  145. package/src/tasks/text-to-image/inference.ts +75 -0
  146. package/src/tasks/text-to-image/spec/input.json +63 -0
  147. package/src/tasks/text-to-image/spec/output.json +13 -0
  148. package/src/tasks/text-to-speech/about.md +63 -0
  149. package/src/tasks/text-to-speech/data.ts +79 -0
  150. package/src/tasks/text-to-speech/inference.ts +145 -0
  151. package/src/tasks/text-to-speech/spec/input.json +31 -0
  152. package/src/tasks/text-to-speech/spec/output.json +7 -0
  153. package/src/tasks/text-to-video/about.md +41 -0
  154. package/src/tasks/text-to-video/data.ts +102 -0
  155. package/src/tasks/text2text-generation/inference.ts +55 -0
  156. package/src/tasks/text2text-generation/spec/input.json +55 -0
  157. package/src/tasks/text2text-generation/spec/output.json +14 -0
  158. package/src/tasks/token-classification/about.md +76 -0
  159. package/src/tasks/token-classification/data.ts +92 -0
  160. package/src/tasks/token-classification/inference.ts +85 -0
  161. package/src/tasks/token-classification/spec/input.json +65 -0
  162. package/src/tasks/token-classification/spec/output.json +37 -0
  163. package/src/tasks/translation/about.md +65 -0
  164. package/src/tasks/translation/data.ts +70 -0
  165. package/src/tasks/translation/inference.ts +67 -0
  166. package/src/tasks/translation/spec/input.json +50 -0
  167. package/src/tasks/translation/spec/output.json +14 -0
  168. package/src/tasks/unconditional-image-generation/about.md +50 -0
  169. package/src/tasks/unconditional-image-generation/data.ts +72 -0
  170. package/src/tasks/video-classification/about.md +37 -0
  171. package/src/tasks/video-classification/data.ts +84 -0
  172. package/src/tasks/video-classification/inference.ts +59 -0
  173. package/src/tasks/video-classification/spec/input.json +42 -0
  174. package/src/tasks/video-classification/spec/output.json +10 -0
  175. package/src/tasks/video-text-to-text/about.md +98 -0
  176. package/src/tasks/video-text-to-text/data.ts +66 -0
  177. package/src/tasks/visual-question-answering/about.md +48 -0
  178. package/src/tasks/visual-question-answering/data.ts +97 -0
  179. package/src/tasks/visual-question-answering/inference.ts +62 -0
  180. package/src/tasks/visual-question-answering/spec/input.json +41 -0
  181. package/src/tasks/visual-question-answering/spec/output.json +21 -0
  182. package/src/tasks/zero-shot-classification/about.md +40 -0
  183. package/src/tasks/zero-shot-classification/data.ts +70 -0
  184. package/src/tasks/zero-shot-classification/inference.ts +67 -0
  185. package/src/tasks/zero-shot-classification/spec/input.json +50 -0
  186. package/src/tasks/zero-shot-classification/spec/output.json +11 -0
  187. package/src/tasks/zero-shot-image-classification/about.md +75 -0
  188. package/src/tasks/zero-shot-image-classification/data.ts +84 -0
  189. package/src/tasks/zero-shot-image-classification/inference.ts +61 -0
  190. package/src/tasks/zero-shot-image-classification/spec/input.json +45 -0
  191. package/src/tasks/zero-shot-image-classification/spec/output.json +10 -0
  192. package/src/tasks/zero-shot-object-detection/about.md +45 -0
  193. package/src/tasks/zero-shot-object-detection/data.ts +67 -0
  194. package/src/tasks/zero-shot-object-detection/inference.ts +66 -0
  195. package/src/tasks/zero-shot-object-detection/spec/input.json +40 -0
  196. package/src/tasks/zero-shot-object-detection/spec/output.json +47 -0
  197. package/src/tokenizer-data.ts +32 -0
  198. package/src/widget-example.ts +125 -0
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Inference code generated from the JSON schema spec in ./spec
3
+ *
4
+ * Using src/scripts/inference-codegen
5
+ */
6
+
7
+ /**
8
+ * Inputs for Summarization inference
9
+ */
10
+ export interface SummarizationInput {
11
+ /**
12
+ * The input text to summarize.
13
+ */
14
+ inputs: string;
15
+ /**
16
+ * Additional inference parameters.
17
+ */
18
+ parameters?: SummarizationParameters;
19
+ [property: string]: unknown;
20
+ }
21
+
22
+ /**
23
+ * Additional inference parameters.
24
+ *
25
+ * Additional inference parameters for summarization.
26
+ */
27
+ export interface SummarizationParameters {
28
+ /**
29
+ * Whether to clean up the potential extra spaces in the text output.
30
+ */
31
+ clean_up_tokenization_spaces?: boolean;
32
+ /**
33
+ * Additional parametrization of the text generation algorithm.
34
+ */
35
+ generate_parameters?: { [key: string]: unknown };
36
+ /**
37
+ * The truncation strategy to use.
38
+ */
39
+ truncation?: SummarizationTruncationStrategy;
40
+ [property: string]: unknown;
41
+ }
42
+
43
+ /**
44
+ * The truncation strategy to use.
45
+ */
46
+ export type SummarizationTruncationStrategy = "do_not_truncate" | "longest_first" | "only_first" | "only_second";
47
+
48
+ /**
49
+ * Outputs of inference for the Summarization task
50
+ */
51
+ export interface SummarizationOutput {
52
+ /**
53
+ * The summarized text.
54
+ */
55
+ summary_text: string;
56
+ [property: string]: unknown;
57
+ }
@@ -0,0 +1,42 @@
1
+ {
2
+ "$id": "/inference/schemas/summarization/input.json",
3
+ "$schema": "http://json-schema.org/draft-06/schema#",
4
+ "description": "Inputs for Summarization inference",
5
+ "title": "SummarizationInput",
6
+ "type": "object",
7
+ "properties": {
8
+ "inputs": {
9
+ "description": "The input text to summarize.",
10
+ "type": "string"
11
+ },
12
+ "parameters": {
13
+ "description": "Additional inference parameters.",
14
+ "$ref": "#/$defs/SummarizationParameters"
15
+ }
16
+ },
17
+ "$defs": {
18
+ "SummarizationParameters": {
19
+ "title": "SummarizationParameters",
20
+ "description": "Additional inference parameters for summarization.",
21
+ "type": "object",
22
+ "properties": {
23
+ "clean_up_tokenization_spaces": {
24
+ "type": "boolean",
25
+ "description": "Whether to clean up the potential extra spaces in the text output."
26
+ },
27
+ "truncation": {
28
+ "title": "SummarizationTruncationStrategy",
29
+ "type": "string",
30
+ "description": "The truncation strategy to use.",
31
+ "enum": ["do_not_truncate", "longest_first", "only_first", "only_second"]
32
+ },
33
+ "generate_parameters": {
34
+ "title": "generateParameters",
35
+ "type": "object",
36
+ "description": "Additional parametrization of the text generation algorithm."
37
+ }
38
+ }
39
+ }
40
+ },
41
+ "required": ["inputs"]
42
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "$id": "/inference/schemas/summarization/output.json",
3
+ "$schema": "http://json-schema.org/draft-06/schema#",
4
+ "description": "Outputs of inference for the Summarization task",
5
+ "title": "SummarizationOutput",
6
+ "type": "object",
7
+ "properties": {
8
+ "summary_text": {
9
+ "type": "string",
10
+ "description": "The summarized text."
11
+ }
12
+ },
13
+ "required": ["summary_text"]
14
+ }
@@ -0,0 +1,43 @@
1
+ ## Use Cases
2
+
3
+ ### SQL execution
4
+
5
+ You can use the Table Question Answering models to simulate SQL execution by inputting a table.
6
+
7
+ ### Table Question Answering
8
+
9
+ Table Question Answering models are capable of answering questions based on a table.
10
+
11
+ ## Task Variants
12
+
13
+ This place can be filled with variants of this task if there's any.
14
+
15
+ ## Inference
16
+
17
+ You can infer with TableQA models using the 🤗 Transformers library.
18
+
19
+ ```python
20
+ from transformers import pipeline
21
+ import pandas as pd
22
+
23
+ # prepare table + question
24
+ data = {"Actors": ["Brad Pitt", "Leonardo Di Caprio", "George Clooney"], "Number of movies": ["87", "53", "69"]}
25
+ table = pd.DataFrame.from_dict(data)
26
+ question = "how many movies does Leonardo Di Caprio have?"
27
+
28
+ # pipeline model
29
+ # Note: you must to install torch-scatter first.
30
+ tqa = pipeline(task="table-question-answering", model="google/tapas-large-finetuned-wtq")
31
+
32
+ # result
33
+
34
+ print(tqa(table=table, query=question)['cells'][0])
35
+ #53
36
+
37
+ ```
38
+
39
+ ## Useful Resources
40
+
41
+ In this area, you can insert useful resources about how to train or use a model for this task.
42
+
43
+ This task page is complete thanks to the efforts of [Hao Kim Tieu](https://huggingface.co/haotieu). 🦸
@@ -0,0 +1,59 @@
1
+ import type { TaskDataCustom } from "../index.js";
2
+
3
+ const taskData: TaskDataCustom = {
4
+ datasets: [
5
+ {
6
+ description:
7
+ "The WikiTableQuestions dataset is a large-scale dataset for the task of question answering on semi-structured tables.",
8
+ id: "wikitablequestions",
9
+ },
10
+ {
11
+ description:
12
+ "WikiSQL is a dataset of 80654 hand-annotated examples of questions and SQL queries distributed across 24241 tables from Wikipedia.",
13
+ id: "wikisql",
14
+ },
15
+ ],
16
+ demo: {
17
+ inputs: [
18
+ {
19
+ table: [
20
+ ["Rank", "Name", "No.of reigns", "Combined days"],
21
+ ["1", "lou Thesz", "3", "3749"],
22
+ ["2", "Ric Flair", "8", "3103"],
23
+ ["3", "Harley Race", "7", "1799"],
24
+ ],
25
+ type: "tabular",
26
+ },
27
+
28
+ { label: "Question", content: "What is the number of reigns for Harley Race?", type: "text" },
29
+ ],
30
+ outputs: [{ label: "Result", content: "7", type: "text" }],
31
+ },
32
+ metrics: [
33
+ {
34
+ description: "Checks whether the predicted answer(s) is the same as the ground-truth answer(s).",
35
+ id: "Denotation Accuracy",
36
+ },
37
+ ],
38
+ models: [
39
+ {
40
+ description:
41
+ "A table question answering model that is capable of neural SQL execution, i.e., employ TAPEX to execute a SQL query on a given table.",
42
+ id: "microsoft/tapex-base",
43
+ },
44
+ {
45
+ description: "A robust table question answering model.",
46
+ id: "google/tapas-base-finetuned-wtq",
47
+ },
48
+ ],
49
+ spaces: [
50
+ {
51
+ description: "An application that answers questions based on table CSV files.",
52
+ id: "katanaml/table-query",
53
+ },
54
+ ],
55
+ summary: "Table Question Answering (Table QA) is the answering a question about an information on a given table.",
56
+ widgetModels: ["google/tapas-base-finetuned-wtq"],
57
+ };
58
+
59
+ export default taskData;
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Inference code generated from the JSON schema spec in ./spec
3
+ *
4
+ * Using src/scripts/inference-codegen
5
+ */
6
+ /**
7
+ * Inputs for Table Question Answering inference
8
+ */
9
+ export interface TableQuestionAnsweringInput {
10
+ /**
11
+ * One (table, question) pair to answer
12
+ */
13
+ inputs: TableQuestionAnsweringInputData;
14
+ /**
15
+ * Additional inference parameters
16
+ */
17
+ parameters?: {
18
+ [key: string]: unknown;
19
+ };
20
+ [property: string]: unknown;
21
+ }
22
+ /**
23
+ * One (table, question) pair to answer
24
+ */
25
+ export interface TableQuestionAnsweringInputData {
26
+ /**
27
+ * The question to be answered about the table
28
+ */
29
+ question: string;
30
+ /**
31
+ * The table to serve as context for the questions
32
+ */
33
+ table: {
34
+ [key: string]: string[];
35
+ };
36
+ [property: string]: unknown;
37
+ }
38
+ export type TableQuestionAnsweringOutput = TableQuestionAnsweringOutputElement[];
39
+ /**
40
+ * Outputs of inference for the Table Question Answering task
41
+ */
42
+ export interface TableQuestionAnsweringOutputElement {
43
+ /**
44
+ * If the model has an aggregator, this returns the aggregator.
45
+ */
46
+ aggregator?: string;
47
+ /**
48
+ * The answer of the question given the table. If there is an aggregator, the answer will be
49
+ * preceded by `AGGREGATOR >`.
50
+ */
51
+ answer: string;
52
+ /**
53
+ * List of strings made up of the answer cell values.
54
+ */
55
+ cells: string[];
56
+ /**
57
+ * Coordinates of the cells of the answers.
58
+ */
59
+ coordinates: Array<number[]>;
60
+ [property: string]: unknown;
61
+ }
@@ -0,0 +1,44 @@
1
+ {
2
+ "$id": "/inference/schemas/table-question-answering/input.json",
3
+ "$schema": "http://json-schema.org/draft-06/schema#",
4
+ "description": "Inputs for Table Question Answering inference",
5
+ "title": "TableQuestionAnsweringInput",
6
+ "type": "object",
7
+ "properties": {
8
+ "inputs": {
9
+ "description": "One (table, question) pair to answer",
10
+ "title": "TableQuestionAnsweringInputData",
11
+ "type": "object",
12
+ "properties": {
13
+ "table": {
14
+ "description": "The table to serve as context for the questions",
15
+ "type": "object",
16
+ "additionalProperties": {
17
+ "type": "array",
18
+ "items": {
19
+ "type": "string"
20
+ }
21
+ }
22
+ },
23
+ "question": {
24
+ "description": "The question to be answered about the table",
25
+ "type": "string"
26
+ }
27
+ },
28
+ "required": ["table", "question"]
29
+ },
30
+ "parameters": {
31
+ "description": "Additional inference parameters",
32
+ "$ref": "#/$defs/TableQuestionAnsweringParameters"
33
+ }
34
+ },
35
+ "$defs": {
36
+ "TableQuestionAnsweringParameters": {
37
+ "title": "TableQuestionAnsweringParameters",
38
+ "description": "Additional inference parameters for Table Question Answering",
39
+ "type": "object",
40
+ "properties": {}
41
+ }
42
+ },
43
+ "required": ["inputs"]
44
+ }
@@ -0,0 +1,40 @@
1
+ {
2
+ "$id": "/inference/schemas/table-question-answering/output.json",
3
+ "$schema": "http://json-schema.org/draft-06/schema#",
4
+ "description": "Outputs of inference for the Table Question Answering task",
5
+ "title": "TableQuestionAnsweringOutput",
6
+ "type": "array",
7
+ "items": {
8
+ "type": "object",
9
+ "properties": {
10
+ "answer": {
11
+ "type": "string",
12
+ "description": "The answer of the question given the table. If there is an aggregator, the answer will be preceded by `AGGREGATOR >`."
13
+ },
14
+ "coordinates": {
15
+ "type": "array",
16
+ "description": "Coordinates of the cells of the answers.",
17
+ "items": {
18
+ "type": "array",
19
+ "items": {
20
+ "type": "integer"
21
+ },
22
+ "minLength": 2,
23
+ "maxLength": 2
24
+ }
25
+ },
26
+ "cells": {
27
+ "type": "array",
28
+ "description": "List of strings made up of the answer cell values.",
29
+ "items": {
30
+ "type": "string"
31
+ }
32
+ },
33
+ "aggregator": {
34
+ "type": "string",
35
+ "description": "If the model has an aggregator, this returns the aggregator."
36
+ }
37
+ },
38
+ "required": ["answer", "cells", "coordinates"]
39
+ }
40
+ }
@@ -0,0 +1,65 @@
1
+ ## About the Task
2
+
3
+ Tabular classification is the task of assigning a label or class given a limited number of attributes. For example, the input can be data related to a customer (balance of the customer, the time being a customer, or more) and the output can be whether the customer will churn from the service or not.
4
+ There are three types of categorical variables:
5
+
6
+ - Binary variables: Variables that can take two values, like yes or no, open or closed. The task of predicting binary variables is called binary classification.
7
+ - Ordinal variables: Variables with a ranking relationship, e.g., good, insignificant, and bad product reviews. The task of predicting ordinal variables is called ordinal classification.
8
+ - Nominal variables: Variables with no ranking relationship among them, e.g., predicting an animal from their weight and height, where categories are cat, dog, or bird. The task of predicting nominal variables is called multinomial classification.
9
+
10
+ ## Use Cases
11
+
12
+ ### Fraud Detection
13
+ Tabular classification models can be used in detecting fraudulent credit card transactions, where the features could be the amount of the transaction and the account balance, and the target to predict could be whether the transaction is fraudulent or not. This is an example of binary classification.
14
+
15
+ ### Churn Prediction
16
+ Tabular classification models can be used in predicting customer churn in telecommunication. An example dataset for the task is hosted [here](https://huggingface.co/datasets/scikit-learn/churn-prediction).
17
+
18
+ # Model Hosting and Inference
19
+
20
+ You can use [skops](https://skops.readthedocs.io/) for model hosting and inference on the Hugging Face Hub. This library is built to improve production workflows of various libraries that are used to train tabular models, including [sklearn](https://scikit-learn.org/stable/) and [xgboost](https://xgboost.readthedocs.io/en/stable/). Using `skops` you can:
21
+
22
+ - Easily use Inference Endpoints
23
+ - Build neat UIs with one line of code,
24
+ - Programmatically create model cards,
25
+ - Securely serialize your scikit-learn model. (See limitations of using pickle [here](https://huggingface.co/docs/hub/security-pickle).)
26
+
27
+ You can push your model as follows:
28
+
29
+ ```python
30
+ from skops import hub_utils
31
+ # initialize a repository with a trained model
32
+ local_repo = "/path_to_new_repo"
33
+ hub_utils.init(model, dst=local_repo)
34
+ # push to Hub!
35
+ hub_utils.push("username/my-awesome-model", source=local_repo)
36
+ ```
37
+
38
+ Once the model is pushed, you can infer easily.
39
+
40
+ ```python
41
+ import skops.hub_utils as hub_utils
42
+ import pandas as pd
43
+ data = pd.DataFrame(your_data)
44
+ # Load the model from the Hub
45
+ res = hub_utils.get_model_output("username/my-awesome-model", data)
46
+ ```
47
+
48
+ You can launch a UI for your model with only one line of code!
49
+
50
+ ```python
51
+ import gradio as gr
52
+ gr.Interface.load("huggingface/username/my-awesome-model").launch()
53
+ ```
54
+
55
+ ## Useful Resources
56
+
57
+ - Check out the [scikit-learn organization](https://huggingface.co/scikit-learn) to learn more about different algorithms used for this task.
58
+ - [Skops documentation](https://skops.readthedocs.io/en/latest/)
59
+ - [Skops announcement blog](https://huggingface.co/blog/skops)
60
+ - [Notebook: Persisting your scikit-learn model using skops](https://www.kaggle.com/code/unofficialmerve/persisting-your-scikit-learn-model-using-skops)
61
+ - Check out [interactive sklearn examples](https://huggingface.co/sklearn-docs) built with ❤️ using Gradio.
62
+
63
+ ### Training your own model in just a few seconds
64
+
65
+ We have built a [baseline trainer](https://huggingface.co/spaces/scikit-learn/baseline-trainer) application to which you can drag and drop your dataset. It will train a baseline and push it to your Hugging Face Hub profile with a model card containing information about the model.
@@ -0,0 +1,68 @@
1
+ import type { TaskDataCustom } from "../index.js";
2
+
3
+ const taskData: TaskDataCustom = {
4
+ datasets: [
5
+ {
6
+ description: "A comprehensive curation of datasets covering all benchmarks.",
7
+ id: "inria-soda/tabular-benchmark",
8
+ },
9
+ ],
10
+ demo: {
11
+ inputs: [
12
+ {
13
+ table: [
14
+ ["Glucose", "Blood Pressure ", "Skin Thickness", "Insulin", "BMI"],
15
+ ["148", "72", "35", "0", "33.6"],
16
+ ["150", "50", "30", "0", "35.1"],
17
+ ["141", "60", "29", "1", "39.2"],
18
+ ],
19
+ type: "tabular",
20
+ },
21
+ ],
22
+ outputs: [
23
+ {
24
+ table: [["Diabetes"], ["1"], ["1"], ["0"]],
25
+ type: "tabular",
26
+ },
27
+ ],
28
+ },
29
+ metrics: [
30
+ {
31
+ description: "",
32
+ id: "accuracy",
33
+ },
34
+ {
35
+ description: "",
36
+ id: "recall",
37
+ },
38
+ {
39
+ description: "",
40
+ id: "precision",
41
+ },
42
+ {
43
+ description: "",
44
+ id: "f1",
45
+ },
46
+ ],
47
+ models: [
48
+ {
49
+ description: "Breast cancer prediction model based on decision trees.",
50
+ id: "scikit-learn/cancer-prediction-trees",
51
+ },
52
+ ],
53
+ spaces: [
54
+ {
55
+ description: "An application that can predict defective products on a production line.",
56
+ id: "scikit-learn/tabular-playground",
57
+ },
58
+ {
59
+ description: "An application that compares various tabular classification techniques on different datasets.",
60
+ id: "scikit-learn/classification",
61
+ },
62
+ ],
63
+ summary: "Tabular classification is the task of classifying a target category (a group) based on set of attributes.",
64
+ widgetModels: ["scikit-learn/tabular-playground"],
65
+ youtubeId: "",
66
+ };
67
+
68
+ export default taskData;
@@ -0,0 +1,87 @@
1
+ ## About the Task
2
+
3
+ Tabular regression is the task of predicting a numerical value given a set of attributes/features. _Tabular_ meaning that data is stored in a table (like an excel sheet), and each sample is contained in its own row. The features used to predict our target can be both numerical and categorical. However, including categorical features often requires additional preprocessing/feature engineering (a few models do accept categorical features directly, like [CatBoost](https://catboost.ai/)). An example of tabular regression would be predicting the weight of a fish given its' species and length.
4
+
5
+ ## Use Cases
6
+
7
+ ### Sales Prediction: a Use Case for Predicting a Continuous Target Variable
8
+
9
+ Here the objective is to predict a continuous variable based on a set of input variable(s). For example, predicting `sales` of an ice cream shop based on `temperature` of weather and `duration of hours` shop was open. Here we can build a regression model with `temperature` and `duration of hours` as input variable and `sales` as target variable.
10
+
11
+ ### Missing Value Imputation for Other Tabular Tasks
12
+ In real-world applications, due to human error or other reasons, some of the input values can be missing or there might not be any recorded data. Considering the example above, say the shopkeeper's watch was broken and they forgot to calculate the `hours` for which the shop was open. This will lead to a missing value in their dataset. In this case, missing values could be replaced it with zero, or average hours for which the shop is kept open. Another approach we can try is to use `temperature` and `sales` variables to predict the `hours` variable here.
13
+
14
+ ## Model Training
15
+
16
+ A simple regression model can be created using `sklearn` as follows:
17
+
18
+ ```python
19
+ #set the input features
20
+ X = data[["Feature 1", "Feature 2", "Feature 3"]]
21
+ #set the target variable
22
+ y = data["Target Variable"]
23
+ #initialize the model
24
+ model = LinearRegression()
25
+ #Fit the model
26
+ model.fit(X, y)
27
+ ```
28
+
29
+ # Model Hosting and Inference
30
+
31
+ You can use [skops](https://skops.readthedocs.io/) for model hosting and inference on the Hugging Face Hub. This library is built to improve production workflows of various libraries that are used to train tabular models, including [sklearn](https://scikit-learn.org/stable/) and [xgboost](https://xgboost.readthedocs.io/en/stable/). Using `skops` you can:
32
+
33
+ - Easily use Inference Endpoints,
34
+ - Build neat UIs with one line of code,
35
+ - Programmatically create model cards,
36
+ - Securely serialize your models. (See limitations of using pickle [here](https://huggingface.co/docs/hub/security-pickle).)
37
+
38
+ You can push your model as follows:
39
+
40
+ ```python
41
+ from skops import hub_utils
42
+ # initialize a repository with a trained model
43
+ local_repo = "/path_to_new_repo"
44
+ hub_utils.init(model, dst=local_repo)
45
+ # push to Hub!
46
+ hub_utils.push("username/my-awesome-model", source=local_repo)
47
+ ```
48
+
49
+ Once the model is pushed, you can infer easily.
50
+
51
+ ```python
52
+ import skops.hub_utils as hub_utils
53
+ import pandas as pd
54
+ data = pd.DataFrame(your_data)
55
+ # Load the model from the Hub
56
+ res = hub_utils.get_model_output("username/my-awesome-model", data)
57
+ ```
58
+
59
+ You can launch a UI for your model with only one line of code!
60
+
61
+ ```python
62
+ import gradio as gr
63
+ gr.Interface.load("huggingface/username/my-awesome-model").launch()
64
+ ```
65
+
66
+ ## Useful Resources
67
+
68
+ - [Skops documentation](https://skops.readthedocs.io/en/stable/index.html)
69
+
70
+ - Check out [interactive sklearn examples](https://huggingface.co/sklearn-docs) built with ❤️ using Gradio.
71
+ - [Notebook: Persisting your scikit-learn model using skops](https://www.kaggle.com/code/unofficialmerve/persisting-your-scikit-learn-model-using-skops)
72
+
73
+ - For starting with tabular regression:
74
+
75
+ - Doing [Exploratory Data Analysis](https://neptune.ai/blog/exploratory-data-analysis-for-tabular-data) for tabular data.
76
+ - The data considered here consists of details of Olympic athletes and medal results from Athens 1896 to Rio 2016.
77
+ - Here you can learn more about how to explore and analyse the data and visualize them in order to get a better understanding of dataset.
78
+ - Building your [first ML model](https://www.kaggle.com/code/dansbecker/your-first-machine-learning-model).
79
+
80
+ - Intermediate level tutorials on tabular regression:
81
+ - [A Short Chronology of Deep Learning for Tabular Data](https://sebastianraschka.com/blog/2022/deep-learning-for-tabular-data.html) by Sebastian Raschka.
82
+
83
+ ### Training your own model in just a few seconds
84
+
85
+ We have built a [baseline trainer](https://huggingface.co/spaces/scikit-learn/baseline-trainer) application to which you can drag and drop your dataset. It will train a baseline and push it to your Hugging Face Hub profile with a model card containing information about the model.
86
+
87
+ This page was made possible thanks to efforts of [Brenden Connors](https://huggingface.co/brendenc) and [Ayush Bihani](https://huggingface.co/hsuyab).
@@ -0,0 +1,57 @@
1
+ import type { TaskDataCustom } from "../index.js";
2
+
3
+ const taskData: TaskDataCustom = {
4
+ datasets: [
5
+ {
6
+ description: "A comprehensive curation of datasets covering all benchmarks.",
7
+ id: "inria-soda/tabular-benchmark",
8
+ },
9
+ ],
10
+ demo: {
11
+ inputs: [
12
+ {
13
+ table: [
14
+ ["Car Name", "Horsepower", "Weight"],
15
+ ["ford torino", "140", "3,449"],
16
+ ["amc hornet", "97", "2,774"],
17
+ ["toyota corolla", "65", "1,773"],
18
+ ],
19
+ type: "tabular",
20
+ },
21
+ ],
22
+ outputs: [
23
+ {
24
+ table: [["MPG (miles per gallon)"], ["17"], ["18"], ["31"]],
25
+ type: "tabular",
26
+ },
27
+ ],
28
+ },
29
+ metrics: [
30
+ {
31
+ description: "",
32
+ id: "mse",
33
+ },
34
+ {
35
+ description:
36
+ "Coefficient of determination (or R-squared) is a measure of how well the model fits the data. Higher R-squared is considered a better fit.",
37
+ id: "r-squared",
38
+ },
39
+ ],
40
+ models: [
41
+ {
42
+ description: "Fish weight prediction based on length measurements and species.",
43
+ id: "scikit-learn/Fish-Weight",
44
+ },
45
+ ],
46
+ spaces: [
47
+ {
48
+ description: "An application that can predict weight of a fish based on set of attributes.",
49
+ id: "scikit-learn/fish-weight-prediction",
50
+ },
51
+ ],
52
+ summary: "Tabular regression is the task of predicting a numerical value given a set of attributes.",
53
+ widgetModels: ["scikit-learn/Fish-Weight"],
54
+ youtubeId: "",
55
+ };
56
+
57
+ export default taskData;