-
Notifications
You must be signed in to change notification settings - Fork 18
update properties of initial resources #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
7aa26e0
e822494
397f3ea
f597c04
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| require 'big_ml/base' | ||
|
|
||
| module BigML | ||
| class Anomaly < Base | ||
| ANOMALY_PROPERTIES = [ | ||
| :anomaly_seed, :category, :code, :columns, :created, :credits, | ||
| :credits_per_prediction, :dataset, :dataset_field_types, | ||
| :dataset_status, :description, :dev, :excluded_fields, :fields_meta, | ||
| :forest_size, :id_fields, :input_fields, :locale, :max_columns, | ||
| :max_rows, :model, :name, :number_of_anomalyscores, | ||
| :number_of_batchanomalyscores, :number_of_public_anomalyscores, | ||
| :out_of_bag, :price, :private, :project, :range, :replacement, :resource, | ||
| :rows, :sample_rate, :seed, :shared, :shared_hash, :sharing_key, :size, | ||
| :source, :source_status, :status, :subscription, :tags, :top_n, :updated, | ||
| :white_box | ||
| ] | ||
|
|
||
| attr_reader *ANOMALY_PROPERTIES | ||
|
|
||
| def to_score(options) | ||
| Score.create(resource, options) | ||
| end | ||
|
|
||
| class << self | ||
| def create(dataset, options = {}) | ||
| response = client.post("/#{resource_name}", options, { :dataset => dataset }) | ||
| self.new(response) if response.success? | ||
| end | ||
| end | ||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| require 'big_ml/base' | ||
|
|
||
| module BigML | ||
| class BatchPrediction < Base | ||
| BATCH_PREDICTION_PROPERTIES = [ | ||
| :category, :code, :created, :credits, :dataset, :dataset_status, | ||
| :description, :fields, :dataset, :model, :model_status, :name, | ||
| :objective_fields, :prediction, :prediction_path, :private, :resource, | ||
| :source, :source_status, :status, :tags, :updated | ||
| ] | ||
|
|
||
| attr_reader *BATCH_PREDICTION_PROPERTIES | ||
|
|
||
| class << self | ||
| def create(model_or_ensemble, dataset, options = {}) | ||
| arguments = { dataset: dataset } | ||
| if model_or_ensemble.start_with? 'model' | ||
| arguments[:model] = model_or_ensemble | ||
| elsif model_or_ensemble.start_with? 'ensemble' | ||
| arguments[:ensemble] = model_or_ensemble | ||
| else | ||
| raise ArgumentError, "Expected model or ensemble, got #{model_or_ensemble}" | ||
| end | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll extract this code to its own module, f.e |
||
| response = client.post("/#{resource_name}", {}, arguments.merge(options)) | ||
| self.new(response) if response.success? | ||
| end | ||
|
|
||
| def download(id) | ||
| response = client.get("/#{resource_name}/#{id}/download") | ||
| response.body if response.success? | ||
| end | ||
| end | ||
|
|
||
| def download | ||
| self.class.download(id) | ||
| end | ||
|
|
||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| require 'big_ml/base' | ||
|
|
||
| module BigML | ||
| class BatchScore < Base | ||
| BATCH_SCORE_PROPERTIES = [ | ||
| :category, :code, :created, :credits, :dataset, :dataset_status, | ||
| :description, :fields, :dataset, :model, :model_status, :name, | ||
| :objective_fields, :prediction, :prediction_path, :private, :resource, | ||
| :source, :source_status, :status, :tags, :updated | ||
| ] | ||
|
|
||
| attr_reader *BATCH_SCORE_PROPERTIES | ||
|
|
||
| class << self | ||
| def create(anomaly, dataset, options = {}) | ||
| arguments = { dataset: dataset } | ||
| if cluster.start_with? 'anomaly' | ||
| arguments[:anomaly] = anomaly | ||
| else | ||
| raise ArgumentError, "Expected cluster, got #{anomaly}" | ||
| end | ||
| response = client.post("/#{resource_name}", {}, arguments.merge(options)) | ||
| self.new(response) if response.success? | ||
| end | ||
|
|
||
| def download(id) | ||
| response = client.get("/#{resource_name}/#{id}/download") | ||
| response.body if response.success? | ||
| end | ||
| end | ||
|
|
||
| def download | ||
| self.class.download(id) | ||
| end | ||
|
|
||
| end | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| require 'big_ml/base' | ||
|
|
||
| module BigML | ||
| class Centroid < Base | ||
| CENTROID_PROPERTIES = [ | ||
| :category, :centroid, :centroid_id, :centroid_name, :cluster, | ||
| :cluster_type, :cluster_status, :code, :created, :credits, :dataset, | ||
| :dataset_status, :description, :dev, :distance, :input_data, :locale, | ||
| :name, :private, :project, :resource, :query_string, :source, | ||
| :source_status, :status, :subscription, :tags, :updated | ||
| ] | ||
|
|
||
| attr_reader *CENTROID_PROPERTIES | ||
|
|
||
| class << self | ||
| def create(cluster, options = {}) | ||
| response = client.post("/#{resource_name}", {}, { cluster.split('/').first.to_sym => cluster }.merge!(options)) | ||
| self.new(response) if response.success? | ||
| end | ||
| end | ||
| end | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| require 'big_ml/base' | ||
|
|
||
| module BigML | ||
| class Cluster < Base | ||
| CLUSTER_PROPERTIES = [ | ||
| :balance_fields, :category, :cluster_datasets, :cluster_seed, | ||
| :clusters, :code, :columns, :created, :credits, | ||
| :credits_per_prediction, :dataset, :dataset_field_types, | ||
| :dataset_status, :description, :dev, :excluded_fields, :fields_meta, | ||
| :field_scale, :input_fields, :k, :locale, :max_columns, :max_rows, | ||
| :model_clusters, :name, :number_of_batchcentroids, :number_of_centroids, | ||
| :number_of_public_centroids, :out_of_bag, :price, :private, :project, | ||
| :range, :replacement, :resource, :rows, :sample_rate, :scales, :seed, | ||
| :shared, :shared_hash, :sharing_key, :size, :source, :source_status, | ||
| :status, :subscription, :summary_fields, :tags, :updated, | ||
| :wheight_field, :white_box | ||
| ] | ||
|
|
||
| attr_reader *CLUSTER_PROPERTIES | ||
|
|
||
| def to_centroid(options) | ||
| Centroid.create(resource, options) | ||
| end | ||
|
|
||
| class << self | ||
| def create(dataset, options = {}) | ||
| response = client.post("/#{resource_name}", options, { :dataset => dataset }) | ||
| self.new(response) if response.success? | ||
| end | ||
| end | ||
| end | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| require 'big_ml/base' | ||
|
|
||
| module BigML | ||
| class Score < Base | ||
| SCORE_PROPERTIES = [ | ||
| :anomaly, :anomaly_status, :anomaly_type, | ||
| :category, :code, :created, :credits, :dataset, :dataset_status, | ||
| :description, :dev, :importance, :input_data, :locale, :name, | ||
| :private, :project, :resource, :score, :query_string, | ||
| :source, :source_status, :status, :subscription, :tags, :updated | ||
| ] | ||
|
|
||
| attr_reader *SCORE_PROPERTIES | ||
|
|
||
| class << self | ||
| def create(anomaly, options = {}) | ||
| response = client.post("/#{resource_name}", {}, { anomaly.split('/').first.to_sym => anomaly }.merge!(options)) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is difficult to understand what |
||
| self.new(response) if response.success? | ||
| end | ||
| end | ||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| module BigML | ||
| VERSION = "0.1.3" | ||
| VERSION = "0.1.4" | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not in sync with the changelog |
||
| end | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this are new endpoint integration, probably make sense to add them into the integration specs to make sure they 're still working in some time form now.
https://github.com/joseribes/big_ml/tree/propertiesupdate/spec/integration
What do you think?