Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Changelog

## 0.2.0
- BigML::Anomaly
- BigML::Cluster
- BigML::Centroid
- BigML::Score
- BigML::BatchCentroid
- BigML::BatchScore

## 0.1.4
- Update resources properties

## 0.1.2 or 0.1.3
- BigML::Ensemble
- BigML::Evaluation

## 0.1.1
- Casting method to_* added
- Update and destroy methods in the instances
Expand Down
3 changes: 2 additions & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
## Source

- implement creation by url
- implement creation using inline data
- implement creation using inline data
- support VPC (private enviroment for customer)
4 changes: 2 additions & 2 deletions big_ml.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
require File.expand_path('../lib/big_ml/version', __FILE__)

Gem::Specification.new do |gem|
gem.authors = ["Vicent Gozalbes", "Felipe Talavera"]
gem.email = ["vigosan@gmail.com", "felipe.talavera@gmail.com"]
gem.authors = ["Vicent Gozalbes", "Felipe Talavera", "Jose Ribes"]
gem.email = ["vigosan@gmail.com", "felipe.talavera@gmail.com", "jobez81@gmail.com"]
gem.description = %q{A Ruby wrapper for the BigML REST API}
gem.summary = %q{A Ruby wrapper for the BigML REST API}
gem.homepage = "http://vigosan.github.com/big_ml"
Expand Down
31 changes: 31 additions & 0 deletions lib/big_ml/anomaly.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
require 'big_ml/base'

module BigML
class Anomaly < Base
Copy link
Collaborator

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?

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
39 changes: 39 additions & 0 deletions lib/big_ml/batch_centroid.rb
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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll extract this code to its own module, f.e AttributesBuillder so all this logic will be encapsulated there.

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
37 changes: 37 additions & 0 deletions lib/big_ml/batch_score.rb
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
22 changes: 22 additions & 0 deletions lib/big_ml/centroid.rb
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
32 changes: 32 additions & 0 deletions lib/big_ml/cluster.rb
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
13 changes: 10 additions & 3 deletions lib/big_ml/dataset.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@ module BigML
class Dataset < Base
DATASET_PROPERTIES = [
:category, :code, :columns, :created, :credits,
:description, :fields, :locale, :name, :number_of_models,
:number_of_predictions, :private, :resource, :rows, :size,
:source, :source_status, :status, :tags, :updated
:description, :dev, :excluded_fields, :field_types,
:fields, :fields_meta, :input_fields, :locale, :name,
:number_of_batchpredictions, :number_of_ensembles,
:number_of_evaluations, :number_of_models,
:number_of_predictions, :objective_field, :out_of_bag, :price,
:private, :project, :range, :refresh_field_types,
:refresh_preferred, :replacement, :resource, :rows,
:sample_rate, :seed, :shared, :shared_hash, :sharing_key, :size,
:source, :source_status, :status, :subscription, :tags,
:term_limit, :updated
]

attr_reader *DATASET_PROPERTIES
Expand Down
14 changes: 7 additions & 7 deletions lib/big_ml/ensemble.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
module BigML
class Ensemble < Base
ENSEMBLE_PROPERTIES = [
:category, :code, :columns, :created, :credits,
:category, :code, :columns, :created, :credits, :credits_per_prediction,
:dataset, :dataset_status, :description, :dev, :distributions,
:holdout, :error_models, :excluded_fields, :finished_models,
:input_fields, :locale, :max_columns, :max_rows, :model_order,
:error_models, :excluded_fields, :finished_models, :input_fields,
:locale, :max_columns, :max_rows, :missing_splits, :model_order,
:models, :name, :node_threshold, :number_of_batchpredictions,
:number_of_evaluations, :number_of_models, :number_of_predictions,
:number_of_public_predictions, :objective_field, :ordering,
:out_of_bag, :price, :private, :randomize, :random_candidates,
:range, :replacement, :resource, :rows, :sample_rate, :seed,
:shared, :shared_hash, :sharing_key, :size, :source, :source_status,
:status, :subscription, :tags, :tlp, :updated
:out_of_bag, :price, :private, :project, :randomize, :random_candidates,
:random_candidate_ratio, :range, :replacement, :resource, :rows,
:sample_rate, :seed, :shared, :shared_hash, :sharing_key, :size, :source,
:source_status, :status, :subscription, :tags, :tlp, :updated
]

attr_reader *ENSEMBLE_PROPERTIES
Expand Down
14 changes: 8 additions & 6 deletions lib/big_ml/evaluation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
module BigML
class Evaluation < Base
EVALUATION_PROPERTIES = [
:category, :code, :combiner, :created, :credits, :dataset, :dataset_status,
:description, :dev, :ensemble, :fields_map, :locale, :max_rows, :missing_strategy,
:model, :model_status, :model_type, :name, :number_of_models, :ordering,
:out_of_bag, :private, :range, :replacement, :resource, :result, :rows, :sample_rate,
:shared, :shared_hash, :sharing_key, :size, :status, :subscription, :tags,
:threshold, :type, :updated
:category, :code, :combiner, :confidence_threshold, :created, :credits,
:dataset, :dataset_status, :description, :dev, :ensemble, :fields_map,
:locale, :max_rows, :missing_strategy, :model, :model_status,
:model_type, :name, :negative_class, :number_of_models, :ordering,
:out_of_bag, :positive_class, :private, :project, :range, :replacement,
:resource, :result, :rows, :sample_rate, :shared, :shared_hash,
:sharing_key, :size, :status, :subscription, :tags, :threshold, :type,
:updated
]

attr_reader *EVALUATION_PROPERTIES
Expand Down
18 changes: 12 additions & 6 deletions lib/big_ml/model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@
module BigML
class Model < Base
MODEL_PROPERTIES = [
:category, :code, :columns, :created, :credits,
:dataset, :dataset_status, :description, :holdout,
:input_fields, :locale, :max_columns, :max_rows, :model,
:name, :number_of_predictions, :objective_fields, :private,
:range, :resource, :rows, :size, :source, :source_status,
:status, :tags, :updated
:category, :code, :columns, :created, :credits, :credits_per_prediction,
:dataset, :dataset_field_types, :dataset_status, :description, :dev,
:ensemble, :ensemble_id, :ensemble_index, :excluded_fields, :fields_meta,
:input_fields, :locale, :max_columns, :max_rows, :missing_splits, :model,
:name, :node_threshold, :number_of_batchpredictions,
:number_of_evaluations, :number_of_predictions,
:number_of_publicpredictions, :objective_field, :objective_fields,
:ordering, :out_of_bag, :price, :private, :project, :randomize,
:random_candidates, :random_candidate_ratio, :range, :replacement,
:resource, :rows, :sample_rate, :seed, :selective_pruning, :shared,
:shared_hash, :sharing_key, :size, :source, :source_status,
:stat_pruning, :status, :subscription, :tags, :updated, :white_box
]

attr_reader *MODEL_PROPERTIES
Expand Down
13 changes: 9 additions & 4 deletions lib/big_ml/prediction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@
module BigML
class Prediction < Base
PREDICTION_PROPERTIES = [
:category, :code, :created, :credits, :dataset, :dataset_status,
:description, :fields, :input_data, :model, :model_status, :name,
:objective_fields, :prediction, :prediction_path, :private, :resource,
:source, :source_status, :status, :tags, :updated
:category, :code, :combiner, :confidence, :created, :credits, :dataset,
:dataset_status, :description, :dev, :ensemble, :error_predictions,
:fields, :finished_predictions, :input_data, :locale, :missing_strategy,
:model, :models, :model_type, :model_status, :name, :number_of_models,
:objective_field, :objective_fields, :objective_field_name, :output,
:prediction, :predictions, :prediction_path, :private, :project,
:resource, :query_string, :source, :source_status, :status, :subscription,
:tags, :task, :threshold, :tlp, :total_count, :updated, :votes,
:vote_confidence
]

attr_reader *PREDICTION_PROPERTIES
Expand Down
22 changes: 22 additions & 0 deletions lib/big_ml/score.rb
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))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is difficult to understand what anomaly.split('/').first.to_sym => anomaly is doing, also with no specs.

self.new(response) if response.success?
end
end
end
end
9 changes: 6 additions & 3 deletions lib/big_ml/source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
module BigML
class Source < Base
SOURCE_PROPERTIES = [
:code, :content_type, :created, :credits, :fields, :file_name, :md5,
:name, :number_of_datasets, :number_of_models, :number_of_predictions,
:private, :resource, :size, :source_parser, :status, :type, :updated
:category, :code, :content_type, :created, :credits, :description,
:dev, :disable_datetime, :fields, :fields_meta, :file_name, :md5,
:name, :number_of_datasets, :number_of_ensembles, :number_of_models,
:number_of_predictions, :private, :project, :remote, :resource, :shared,
:shared_hash, :sharing_key, :size, :source_parser, :status,
:subscription, :tags, :term_analysis, :type, :updated
]

attr_reader *SOURCE_PROPERTIES
Expand Down
2 changes: 1 addition & 1 deletion lib/big_ml/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module BigML
VERSION = "0.1.3"
VERSION = "0.1.4"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not in sync with the changelog

end