aimodelshare 0.3.7__py3-none-any.whl

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 (171) hide show
  1. aimodelshare/README.md +26 -0
  2. aimodelshare/__init__.py +100 -0
  3. aimodelshare/aimsonnx.py +2381 -0
  4. aimodelshare/api.py +836 -0
  5. aimodelshare/auth.py +163 -0
  6. aimodelshare/aws.py +511 -0
  7. aimodelshare/aws_client.py +173 -0
  8. aimodelshare/base_image.py +154 -0
  9. aimodelshare/bucketpolicy.py +106 -0
  10. aimodelshare/color_mappings/color_mapping_keras.csv +121 -0
  11. aimodelshare/color_mappings/color_mapping_pytorch.csv +117 -0
  12. aimodelshare/containerisation.py +244 -0
  13. aimodelshare/containerization.py +712 -0
  14. aimodelshare/containerization_templates/Dockerfile.txt +8 -0
  15. aimodelshare/containerization_templates/Dockerfile_PySpark.txt +23 -0
  16. aimodelshare/containerization_templates/buildspec.txt +14 -0
  17. aimodelshare/containerization_templates/lambda_function.txt +40 -0
  18. aimodelshare/custom_approach/__init__.py +1 -0
  19. aimodelshare/custom_approach/lambda_function.py +17 -0
  20. aimodelshare/custom_eval_metrics.py +103 -0
  21. aimodelshare/data_sharing/__init__.py +0 -0
  22. aimodelshare/data_sharing/data_sharing_templates/Dockerfile.txt +3 -0
  23. aimodelshare/data_sharing/data_sharing_templates/__init__.py +1 -0
  24. aimodelshare/data_sharing/data_sharing_templates/buildspec.txt +15 -0
  25. aimodelshare/data_sharing/data_sharing_templates/codebuild_policies.txt +129 -0
  26. aimodelshare/data_sharing/data_sharing_templates/codebuild_trust_relationship.txt +12 -0
  27. aimodelshare/data_sharing/download_data.py +620 -0
  28. aimodelshare/data_sharing/share_data.py +373 -0
  29. aimodelshare/data_sharing/utils.py +8 -0
  30. aimodelshare/deploy_custom_lambda.py +246 -0
  31. aimodelshare/documentation/Makefile +20 -0
  32. aimodelshare/documentation/karma_sphinx_theme/__init__.py +28 -0
  33. aimodelshare/documentation/karma_sphinx_theme/_version.py +2 -0
  34. aimodelshare/documentation/karma_sphinx_theme/breadcrumbs.html +70 -0
  35. aimodelshare/documentation/karma_sphinx_theme/layout.html +172 -0
  36. aimodelshare/documentation/karma_sphinx_theme/search.html +50 -0
  37. aimodelshare/documentation/karma_sphinx_theme/searchbox.html +14 -0
  38. aimodelshare/documentation/karma_sphinx_theme/static/css/custom.css +2 -0
  39. aimodelshare/documentation/karma_sphinx_theme/static/css/custom.css.map +1 -0
  40. aimodelshare/documentation/karma_sphinx_theme/static/css/theme.css +2751 -0
  41. aimodelshare/documentation/karma_sphinx_theme/static/css/theme.css.map +1 -0
  42. aimodelshare/documentation/karma_sphinx_theme/static/css/theme.min.css +2 -0
  43. aimodelshare/documentation/karma_sphinx_theme/static/css/theme.min.css.map +1 -0
  44. aimodelshare/documentation/karma_sphinx_theme/static/font/fontello.eot +0 -0
  45. aimodelshare/documentation/karma_sphinx_theme/static/font/fontello.svg +32 -0
  46. aimodelshare/documentation/karma_sphinx_theme/static/font/fontello.ttf +0 -0
  47. aimodelshare/documentation/karma_sphinx_theme/static/font/fontello.woff +0 -0
  48. aimodelshare/documentation/karma_sphinx_theme/static/font/fontello.woff2 +0 -0
  49. aimodelshare/documentation/karma_sphinx_theme/static/js/theme.js +68 -0
  50. aimodelshare/documentation/karma_sphinx_theme/theme.conf +9 -0
  51. aimodelshare/documentation/make.bat +35 -0
  52. aimodelshare/documentation/requirements.txt +2 -0
  53. aimodelshare/documentation/source/about.rst +18 -0
  54. aimodelshare/documentation/source/advanced_features.rst +137 -0
  55. aimodelshare/documentation/source/competition.rst +218 -0
  56. aimodelshare/documentation/source/conf.py +58 -0
  57. aimodelshare/documentation/source/create_credentials.rst +86 -0
  58. aimodelshare/documentation/source/example_notebooks.rst +132 -0
  59. aimodelshare/documentation/source/functions.rst +151 -0
  60. aimodelshare/documentation/source/gettingstarted.rst +390 -0
  61. aimodelshare/documentation/source/images/creds1.png +0 -0
  62. aimodelshare/documentation/source/images/creds2.png +0 -0
  63. aimodelshare/documentation/source/images/creds3.png +0 -0
  64. aimodelshare/documentation/source/images/creds4.png +0 -0
  65. aimodelshare/documentation/source/images/creds5.png +0 -0
  66. aimodelshare/documentation/source/images/creds_file_example.png +0 -0
  67. aimodelshare/documentation/source/images/predict_tab.png +0 -0
  68. aimodelshare/documentation/source/index.rst +110 -0
  69. aimodelshare/documentation/source/modelplayground.rst +132 -0
  70. aimodelshare/exceptions.py +11 -0
  71. aimodelshare/generatemodelapi.py +1270 -0
  72. aimodelshare/iam/codebuild_policy.txt +129 -0
  73. aimodelshare/iam/codebuild_trust_relationship.txt +12 -0
  74. aimodelshare/iam/lambda_policy.txt +15 -0
  75. aimodelshare/iam/lambda_trust_relationship.txt +12 -0
  76. aimodelshare/json_templates/__init__.py +1 -0
  77. aimodelshare/json_templates/api_json.txt +155 -0
  78. aimodelshare/json_templates/auth/policy.txt +1 -0
  79. aimodelshare/json_templates/auth/role.txt +1 -0
  80. aimodelshare/json_templates/eval/policy.txt +1 -0
  81. aimodelshare/json_templates/eval/role.txt +1 -0
  82. aimodelshare/json_templates/function/policy.txt +1 -0
  83. aimodelshare/json_templates/function/role.txt +1 -0
  84. aimodelshare/json_templates/integration_response.txt +5 -0
  85. aimodelshare/json_templates/lambda_policy_1.txt +15 -0
  86. aimodelshare/json_templates/lambda_policy_2.txt +8 -0
  87. aimodelshare/json_templates/lambda_role_1.txt +12 -0
  88. aimodelshare/json_templates/lambda_role_2.txt +16 -0
  89. aimodelshare/leaderboard.py +174 -0
  90. aimodelshare/main/1.txt +132 -0
  91. aimodelshare/main/1B.txt +112 -0
  92. aimodelshare/main/2.txt +153 -0
  93. aimodelshare/main/3.txt +134 -0
  94. aimodelshare/main/4.txt +128 -0
  95. aimodelshare/main/5.txt +109 -0
  96. aimodelshare/main/6.txt +105 -0
  97. aimodelshare/main/7.txt +144 -0
  98. aimodelshare/main/8.txt +142 -0
  99. aimodelshare/main/__init__.py +1 -0
  100. aimodelshare/main/authorization.txt +275 -0
  101. aimodelshare/main/eval_classification.txt +79 -0
  102. aimodelshare/main/eval_lambda.txt +1709 -0
  103. aimodelshare/main/eval_regression.txt +80 -0
  104. aimodelshare/main/lambda_function.txt +8 -0
  105. aimodelshare/main/nst.txt +149 -0
  106. aimodelshare/model.py +1543 -0
  107. aimodelshare/modeluser.py +215 -0
  108. aimodelshare/moral_compass/README.md +408 -0
  109. aimodelshare/moral_compass/__init__.py +65 -0
  110. aimodelshare/moral_compass/_version.py +3 -0
  111. aimodelshare/moral_compass/api_client.py +601 -0
  112. aimodelshare/moral_compass/apps/__init__.py +69 -0
  113. aimodelshare/moral_compass/apps/ai_consequences.py +540 -0
  114. aimodelshare/moral_compass/apps/bias_detective.py +714 -0
  115. aimodelshare/moral_compass/apps/ethical_revelation.py +898 -0
  116. aimodelshare/moral_compass/apps/fairness_fixer.py +889 -0
  117. aimodelshare/moral_compass/apps/judge.py +888 -0
  118. aimodelshare/moral_compass/apps/justice_equity_upgrade.py +853 -0
  119. aimodelshare/moral_compass/apps/mc_integration_helpers.py +820 -0
  120. aimodelshare/moral_compass/apps/model_building_game.py +1104 -0
  121. aimodelshare/moral_compass/apps/model_building_game_beginner.py +687 -0
  122. aimodelshare/moral_compass/apps/moral_compass_challenge.py +858 -0
  123. aimodelshare/moral_compass/apps/session_auth.py +254 -0
  124. aimodelshare/moral_compass/apps/shared_activity_styles.css +349 -0
  125. aimodelshare/moral_compass/apps/tutorial.py +481 -0
  126. aimodelshare/moral_compass/apps/what_is_ai.py +853 -0
  127. aimodelshare/moral_compass/challenge.py +365 -0
  128. aimodelshare/moral_compass/config.py +187 -0
  129. aimodelshare/placeholders/model.onnx +0 -0
  130. aimodelshare/placeholders/preprocessor.zip +0 -0
  131. aimodelshare/playground.py +1968 -0
  132. aimodelshare/postprocessormodules.py +157 -0
  133. aimodelshare/preprocessormodules.py +373 -0
  134. aimodelshare/pyspark/1.txt +195 -0
  135. aimodelshare/pyspark/1B.txt +181 -0
  136. aimodelshare/pyspark/2.txt +220 -0
  137. aimodelshare/pyspark/3.txt +204 -0
  138. aimodelshare/pyspark/4.txt +187 -0
  139. aimodelshare/pyspark/5.txt +178 -0
  140. aimodelshare/pyspark/6.txt +174 -0
  141. aimodelshare/pyspark/7.txt +211 -0
  142. aimodelshare/pyspark/8.txt +206 -0
  143. aimodelshare/pyspark/__init__.py +1 -0
  144. aimodelshare/pyspark/authorization.txt +258 -0
  145. aimodelshare/pyspark/eval_classification.txt +79 -0
  146. aimodelshare/pyspark/eval_lambda.txt +1441 -0
  147. aimodelshare/pyspark/eval_regression.txt +80 -0
  148. aimodelshare/pyspark/lambda_function.txt +8 -0
  149. aimodelshare/pyspark/nst.txt +213 -0
  150. aimodelshare/python/my_preprocessor.py +58 -0
  151. aimodelshare/readme.md +26 -0
  152. aimodelshare/reproducibility.py +181 -0
  153. aimodelshare/sam/Dockerfile.txt +8 -0
  154. aimodelshare/sam/Dockerfile_PySpark.txt +24 -0
  155. aimodelshare/sam/__init__.py +1 -0
  156. aimodelshare/sam/buildspec.txt +11 -0
  157. aimodelshare/sam/codebuild_policies.txt +129 -0
  158. aimodelshare/sam/codebuild_trust_relationship.txt +12 -0
  159. aimodelshare/sam/codepipeline_policies.txt +173 -0
  160. aimodelshare/sam/codepipeline_trust_relationship.txt +12 -0
  161. aimodelshare/sam/spark-class.txt +2 -0
  162. aimodelshare/sam/template.txt +54 -0
  163. aimodelshare/tools.py +103 -0
  164. aimodelshare/utils/__init__.py +78 -0
  165. aimodelshare/utils/optional_deps.py +38 -0
  166. aimodelshare/utils.py +57 -0
  167. aimodelshare-0.3.7.dist-info/METADATA +298 -0
  168. aimodelshare-0.3.7.dist-info/RECORD +171 -0
  169. aimodelshare-0.3.7.dist-info/WHEEL +5 -0
  170. aimodelshare-0.3.7.dist-info/licenses/LICENSE +5 -0
  171. aimodelshare-0.3.7.dist-info/top_level.txt +1 -0
@@ -0,0 +1,129 @@
1
+ {
2
+ "Version": "2012-10-17",
3
+ "Statement": [
4
+ {
5
+ "Effect": "Allow",
6
+ "Resource": "*",
7
+ "Action": [
8
+ "logs:CreateLogGroup",
9
+ "logs:CreateLogStream",
10
+ "logs:PutLogEvents"
11
+ ]
12
+ },
13
+ {
14
+ "Effect": "Allow",
15
+ "Resource": "*",
16
+ "Action": [
17
+ "s3:PutObject",
18
+ "s3:GetObject",
19
+ "s3:GetObjectVersion",
20
+ "s3:GetBucketAcl",
21
+ "s3:GetBucketLocation"
22
+ ]
23
+ },
24
+ {
25
+ "Effect": "Allow",
26
+ "Action": [
27
+ "codebuild:CreateReportGroup",
28
+ "codebuild:CreateReport",
29
+ "codebuild:UpdateReport",
30
+ "codebuild:BatchPutTestCases",
31
+ "codebuild:BatchPutCodeCoverages"
32
+ ],
33
+ "Resource": "*"
34
+ },
35
+ {
36
+ "Effect": "Allow",
37
+ "Action": [
38
+ "ecr:*",
39
+ "cloudtrail:LookupEvents"
40
+ ],
41
+ "Resource": "*"
42
+ },
43
+ {
44
+ "Effect": "Allow",
45
+ "Action": [
46
+ "iam:CreateServiceLinkedRole"
47
+ ],
48
+ "Resource": "*",
49
+ "Condition": {
50
+ "StringEquals": {
51
+ "iam:AWSServiceName": [
52
+ "replication.ecr.amazonaws.com"
53
+ ]
54
+ }
55
+ }
56
+ },
57
+ {
58
+ "Effect": "Allow",
59
+ "Action": [
60
+ "cloudformation:*"
61
+ ],
62
+ "Resource": "*"
63
+ },
64
+ {
65
+ "Effect": "Allow",
66
+ "Action": [
67
+ "cloudformation:DescribeStacks",
68
+ "cloudformation:ListStackResources",
69
+ "cloudwatch:ListMetrics",
70
+ "cloudwatch:GetMetricData",
71
+ "ec2:DescribeSecurityGroups",
72
+ "ec2:DescribeSubnets",
73
+ "ec2:DescribeVpcs",
74
+ "kms:ListAliases",
75
+ "iam:GetPolicy",
76
+ "iam:GetPolicyVersion",
77
+ "iam:GetRole",
78
+ "iam:GetRolePolicy",
79
+ "iam:ListAttachedRolePolicies",
80
+ "iam:ListRolePolicies",
81
+ "iam:ListRoles",
82
+ "lambda:*",
83
+ "logs:DescribeLogGroups",
84
+ "states:DescribeStateMachine",
85
+ "states:ListStateMachines",
86
+ "tag:GetResources",
87
+ "xray:GetTraceSummaries",
88
+ "xray:BatchGetTraces"
89
+ ],
90
+ "Resource": "*"
91
+ },
92
+ {
93
+ "Effect": "Allow",
94
+ "Action": "iam:PassRole",
95
+ "Resource": "*",
96
+ "Condition": {
97
+ "StringEquals": {
98
+ "iam:PassedToService": "lambda.amazonaws.com"
99
+ }
100
+ }
101
+ },
102
+ {
103
+ "Effect": "Allow",
104
+ "Action": [
105
+ "logs:DescribeLogStreams",
106
+ "logs:GetLogEvents",
107
+ "logs:FilterLogEvents"
108
+ ],
109
+ "Resource": "arn:aws:logs:*:*:log-group:/aws/lambda/*"
110
+ },
111
+ {
112
+ "Effect": "Allow",
113
+ "Action": [
114
+ "iam:*",
115
+ "organizations:DescribeAccount",
116
+ "organizations:DescribeOrganization",
117
+ "organizations:DescribeOrganizationalUnit",
118
+ "organizations:DescribePolicy",
119
+ "organizations:ListChildren",
120
+ "organizations:ListParents",
121
+ "organizations:ListPoliciesForTarget",
122
+ "organizations:ListRoots",
123
+ "organizations:ListPolicies",
124
+ "organizations:ListTargetsForPolicy"
125
+ ],
126
+ "Resource": "*"
127
+ }
128
+ ]
129
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "Version": "2012-10-17",
3
+ "Statement": [
4
+ {
5
+ "Effect": "Allow",
6
+ "Principal": {
7
+ "Service": "codebuild.amazonaws.com"
8
+ },
9
+ "Action": "sts:AssumeRole"
10
+ }
11
+ ]
12
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "Version": "2012-10-17",
3
+ "Statement": [
4
+ {
5
+ "Action": "logs:*",
6
+ "Resource": "*",
7
+ "Effect": "Allow"
8
+ },
9
+ {
10
+ "Action": "s3:*",
11
+ "Resource": "*",
12
+ "Effect": "Allow"
13
+ }
14
+ ]
15
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "Version": "2012-10-17",
3
+ "Statement": [
4
+ {
5
+ "Effect": "Allow",
6
+ "Principal": {
7
+ "Service": "lambda.amazonaws.com"
8
+ },
9
+ "Action": "sts:AssumeRole"
10
+ }
11
+ ]
12
+ }
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,155 @@
1
+ {
2
+ "openapi": "3.0.1",
3
+ "info": {
4
+ "title": "modapi36146",
5
+ "description": "This is a copy of my first API",
6
+ "version": "2020-05-12T21:25:38Z"
7
+ },
8
+ "servers": [
9
+ {
10
+ "url": "https://8nee9nskdb.execute-api.$region.amazonaws.com/{basePath}",
11
+ "variables": {
12
+ "basePath": {
13
+ "default": "/prod"
14
+ }
15
+ }
16
+ }
17
+ ],
18
+ "paths": {
19
+ "/eval": {
20
+ "post": {
21
+ "responses": {
22
+ "200": {
23
+ "description": "200 response",
24
+ "headers": {
25
+ "Access-Control-Allow-Origin": {
26
+ "schema": {
27
+ "type": "string"
28
+ }
29
+ }
30
+ },
31
+ "content": {
32
+ "application/json": {
33
+ "schema": {
34
+ "$ref": "#/components/schemas/outputmodel"
35
+ }
36
+ }
37
+ }
38
+ }
39
+ }
40
+ },
41
+ "options": {
42
+ "responses": {
43
+ "200": {
44
+ "description": "200 response",
45
+ "headers": {
46
+ "Access-Control-Allow-Origin": {
47
+ "schema": {
48
+ "type": "string"
49
+ }
50
+ },
51
+ "Access-Control-Allow-Methods": {
52
+ "schema": {
53
+ "type": "string"
54
+ }
55
+ },
56
+ "Access-Control-Allow-Headers": {
57
+ "schema": {
58
+ "type": "string"
59
+ }
60
+ }
61
+ },
62
+ "content": {
63
+ "application/json": {
64
+ "schema": {
65
+ "$ref": "#/components/schemas/Empty"
66
+ }
67
+ }
68
+ }
69
+ }
70
+ }
71
+ }
72
+ },
73
+ "/m": {
74
+ "post": {
75
+ "responses": {
76
+ "200": {
77
+ "description": "200 response",
78
+ "headers": {
79
+ "Access-Control-Allow-Origin": {
80
+ "schema": {
81
+ "type": "string"
82
+ }
83
+ }
84
+ },
85
+ "content": {
86
+ "application/json": {
87
+ "schema": {
88
+ "$ref": "#/components/schemas/outputmodel"
89
+ }
90
+ }
91
+ }
92
+ }
93
+ }
94
+ },
95
+ "options": {
96
+ "responses": {
97
+ "200": {
98
+ "description": "200 response",
99
+ "headers": {
100
+ "Access-Control-Allow-Origin": {
101
+ "schema": {
102
+ "type": "string"
103
+ }
104
+ },
105
+ "Access-Control-Allow-Methods": {
106
+ "schema": {
107
+ "type": "string"
108
+ }
109
+ },
110
+ "Access-Control-Allow-Headers": {
111
+ "schema": {
112
+ "type": "string"
113
+ }
114
+ }
115
+ },
116
+ "content": {
117
+ "application/json": {
118
+ "schema": {
119
+ "$ref": "#/components/schemas/Empty"
120
+ }
121
+ }
122
+ }
123
+ }
124
+ }
125
+ }
126
+ }
127
+ },
128
+ "components": {
129
+ "schemas": {
130
+ "Empty": {
131
+ "title": "Empty Schema",
132
+ "type": "object"
133
+ },
134
+ "outputmodel": {
135
+ "title": "Output",
136
+ "type": "object",
137
+ "properties": {
138
+ "body": {
139
+ "type": "string"
140
+ }
141
+ }
142
+ }
143
+ }
144
+ },
145
+ "x-amazon-apigateway-policy": {
146
+ "Version": "2012-10-17",
147
+ "Statement": [
148
+ {
149
+ "Effect": "Allow",
150
+ "Principal": "*",
151
+ "Action": "execute-api:Invoke",
152
+ "Resource": "arn:aws:execute-api:us-east-1:517169013426:8nee9nskdb/prod/OPTIONS/*"
153
+ ]
154
+ }
155
+ }
@@ -0,0 +1 @@
1
+
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,5 @@
1
+ {
2
+ "method.response.header.Access-Control-Allow-Headers": "'Content-Type, X-Amz-Date, authorizationToken, Access-Control-Allow-Origin, X-Api-Key, X-Amz-Security-Token'",
3
+ "method.response.header.Access-Control-Allow-Methods": "'POST, OPTIONS'",
4
+ "method.response.header.Access-Control-Allow-Origin": "'*'"
5
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "Version": "2012-10-17",
3
+ "Statement": [
4
+ {
5
+ "Action": "logs:*",
6
+ "Resource": "*",
7
+ "Effect": "Allow"
8
+ },
9
+ {
10
+ "Action": "s3:*",
11
+ "Resource": "*",
12
+ "Effect": "Allow"
13
+ }
14
+ ]
15
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "Version":"2012-10-17",
3
+ "Statement": {
4
+ "Effect":"Allow",
5
+ "Action":"lambda:InvokeFunction",
6
+ "Resource":"*"
7
+ }
8
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "Version": "2012-10-17",
3
+ "Statement": [
4
+ {
5
+ "Action": "sts:AssumeRole",
6
+ "Principal": {
7
+ "Service": "lambda.amazonaws.com"
8
+ },
9
+ "Effect": "Allow"
10
+ }
11
+ ]
12
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "Version": "2012-10-17",
3
+ "Statement": [
4
+ {
5
+ "Action": "sts:AssumeRole",
6
+ "Principal": {
7
+ "Service": [
8
+ "lambda.amazonaws.com",
9
+ "apigateway.amazonaws.com"
10
+ ]
11
+ },
12
+ "Effect": "Allow",
13
+ "Sid": ""
14
+ }
15
+ ]
16
+ }
@@ -0,0 +1,174 @@
1
+ import json
2
+ import numpy as np
3
+ import pandas as pd
4
+ import os
5
+ import requests
6
+
7
+ import matplotlib.pyplot as plt
8
+
9
+ from collections import Counter
10
+ from aimodelshare.aws import run_function_on_lambda, get_aws_client
11
+ from aimodelshare.aimsonnx import _get_layer_names, layer_mapping
12
+
13
+
14
+ def get_leaderboard(apiurl, verbose=3, columns=None, submission_type="competition",token=None):
15
+ if token == None:
16
+ if all(["username" in os.environ,
17
+ "password" in os.environ]):
18
+ pass
19
+ else:
20
+ return print("'get_leaderboard()' unsuccessful. Please provide credentials with set_credentials().")
21
+ else:
22
+ pass
23
+
24
+ if columns == None:
25
+ columns = str(columns)
26
+
27
+ post_dict = {"y_pred": [],
28
+ "return_eval": "False",
29
+ "return_y": "False",
30
+ "inspect_model": "False",
31
+ "version": "None",
32
+ "compare_models": "False",
33
+ "version_list": "None",
34
+ "get_leaderboard": "True",
35
+ "submission_type": submission_type,
36
+ "verbose": verbose,
37
+ "columns": columns}
38
+ if token == None:
39
+ token=os.environ.get("AWS_TOKEN")
40
+ else:
41
+ pass
42
+ headers = { 'Content-Type':'application/json', 'authorizationToken': token,}
43
+
44
+ apiurl_eval=apiurl[:-1]+"eval"
45
+
46
+ leaderboard_json = requests.post(apiurl_eval,headers=headers,data=json.dumps(post_dict))
47
+
48
+ leaderboard_pd = pd.DataFrame(json.loads(leaderboard_json.text))
49
+
50
+ return leaderboard_pd
51
+
52
+
53
+
54
+ def stylize_leaderboard(leaderboard, naming_convention="keras"):
55
+
56
+ leaderboard = consolidate_leaderboard(leaderboard, naming_convention=naming_convention)
57
+
58
+ # Dropping some columns {{{
59
+ drop_cols = ["timestamp"]
60
+ leaderboard = leaderboard.drop(drop_cols, axis=1)
61
+
62
+ #truncate model config info
63
+
64
+ if "model_config" in leaderboard.columns:
65
+ leaderboard.model_config = leaderboard.model_config.fillna('None')
66
+ leaderboard.model_config = leaderboard.model_config.map(lambda x: x[0:30]+'...')
67
+
68
+ # }}}
69
+
70
+ # Setting default properties {{{
71
+ default_props = {"text-align": "center"}
72
+
73
+ board = leaderboard.style
74
+ board = board.set_properties(**default_props)
75
+ # }}}
76
+
77
+ # infer task type
78
+ if 'accuracy' in leaderboard.columns.tolist():
79
+ task_type = 'classification'
80
+ else:
81
+ task_type = 'regression'
82
+
83
+ # Setting percentage columns' properties {{{
84
+ if task_type == "regression":
85
+ percent_cols = ["mse", 'rmse', 'mae', "r2"]
86
+ percent_colors = ["#f5f8d6", "#c778c8", "#ff4971", "#aadbaa"]
87
+
88
+ percent_props = {"color": "#251e1b", "font-size": "12px"}
89
+
90
+ for col, color in zip(percent_cols, percent_colors):
91
+ board = board.bar(align="left", color=color, subset=col, vmin=0, vmax=leaderboard[col].max())
92
+
93
+ board = board.set_properties(**percent_props, subset=percent_cols)
94
+ board = board.format(lambda x: "{:.2f}".format(x), subset=percent_cols)
95
+
96
+
97
+ else:
98
+ percent_cols = ["accuracy", "f1_score", "precision", "recall"]
99
+ percent_colors = ["#f5f8d6", "#c778c8", "#ff4971", "#aadbaa"]
100
+
101
+ percent_props = {"color": "#251e1b", "font-size": "12px"}
102
+
103
+ for col, color in zip(percent_cols, percent_colors):
104
+ board = board.bar(align="left", color=color, subset=col, vmin=0, vmax=1)
105
+
106
+ board = board.set_properties(**percent_props, subset=percent_cols)
107
+ board = board.format(lambda x: "{:.2f}%".format(x * 100), subset=percent_cols)
108
+ # }}}
109
+
110
+ return board
111
+
112
+
113
+ def consolidate_leaderboard(data, naming_convention="keras"):
114
+
115
+ for i in data:
116
+
117
+ i = i.replace('_layers', '')
118
+ i = i.replace('_act', '')
119
+
120
+ if 'maxpooling2d_layers' in data.columns and 'maxpool2d_layers' in data.columns:
121
+ matched_cols = ['maxpooling2d_layers', 'maxpool2d_layers']
122
+ sum_cols = data[matched_cols].sum(axis=1)
123
+ data[matched_cols[1]] = sum_cols
124
+ data = data.drop(matched_cols[0], axis=1)
125
+
126
+ if naming_convention == 'keras':
127
+ mapping = layer_mapping('torch_to_keras')
128
+ mapping_inverse = layer_mapping('keras_to_torch')
129
+ elif naming_convention == 'pytorch':
130
+ mapping = layer_mapping('keras_to_torch')
131
+ mapping_inverse = layer_mapping('torch_to_keras')
132
+
133
+ mapping_lower = {i.lower(): mapping[i].lower() for i in mapping if i is not None and mapping[i] is not None}
134
+ mapping_inverse_lower = {i.lower(): mapping_inverse[i].lower() for i in mapping_inverse if i is not None and mapping_inverse[i] is not None}
135
+
136
+ try:
137
+
138
+ if i in mapping_lower.keys():
139
+
140
+ if not i == mapping_lower.get(i):
141
+
142
+ matched_cols = [i+"_layers", mapping_lower.get(i)+"_layers"]
143
+
144
+ sum_cols = data[matched_cols].sum(axis=1)
145
+
146
+ data[matched_cols[1]] = sum_cols
147
+
148
+ data = data.drop(matched_cols[0], axis=1)
149
+
150
+ except:
151
+ pass
152
+
153
+ try:
154
+ if i in mapping_inverse_lower.keys() and naming_convention == 'keras':
155
+
156
+ if not i == mapping_inverse_lower.get(i):
157
+
158
+ matched_cols = [i+"_layers", mapping_inverse_lower.get(i)+"_layers"]
159
+
160
+ sum_cols = data[matched_cols].sum(axis=1)
161
+
162
+ data[matched_cols[0]] = sum_cols
163
+
164
+ data = data.drop(matched_cols[1], axis=1)
165
+
166
+ except:
167
+ pass
168
+
169
+ return data
170
+
171
+
172
+
173
+ __all__ = [get_leaderboard,
174
+ stylize_leaderboard]