big_ml 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +19 -0
- data/.rspec +2 -0
- data/.rvmrc +1 -0
- data/.rvmrc.example +1 -0
- data/.travis.yml +4 -0
- data/CHANGELOG.md +8 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +49 -0
- data/Rakefile +6 -0
- data/TODO.md +6 -0
- data/big_ml.gemspec +23 -0
- data/lib/big_ml/authenticable.rb +10 -0
- data/lib/big_ml/base.rb +51 -0
- data/lib/big_ml/client.rb +29 -0
- data/lib/big_ml/config.rb +30 -0
- data/lib/big_ml/dataset.rb +19 -0
- data/lib/big_ml/model.rb +21 -0
- data/lib/big_ml/prediction.rb +19 -0
- data/lib/big_ml/request.rb +29 -0
- data/lib/big_ml/source.rb +18 -0
- data/lib/big_ml/version.rb +3 -0
- data/lib/big_ml.rb +13 -0
- data/spec/fixtures/iris.csv +151 -0
- data/spec/integration/dataset_spec.rb +51 -0
- data/spec/integration/model_spec.rb +53 -0
- data/spec/integration/prediction_spec.rb +55 -0
- data/spec/integration/source_spec.rb +55 -0
- data/spec/spec_helper.rb +22 -0
- data/spec/units/client_spec.rb +50 -0
- data/spec/units/source_spec.rb +20 -0
- data/spec/vcr_cassettes/BigML_Dataset/no_dataset/_all/must_be_empty.yml +136 -0
- data/spec/vcr_cassettes/BigML_Dataset/one_dataset/must_be_able_to_be_find_using_the_reference.yml +293 -0
- data/spec/vcr_cassettes/BigML_Dataset/one_dataset/must_be_able_to_remove_the_dataset.yml +318 -0
- data/spec/vcr_cassettes/BigML_Dataset/one_dataset/must_be_able_to_update_the_name.yml +360 -0
- data/spec/vcr_cassettes/BigML_Dataset/one_dataset/must_have_only_one_item.yml +265 -0
- data/spec/vcr_cassettes/BigML_Dataset/one_dataset/must_have_the_same_file_name.yml +265 -0
- data/spec/vcr_cassettes/BigML_Dataset/one_dataset/was_created_successfully.yml +149 -0
- data/spec/vcr_cassettes/BigML_Model/no_model/_all/must_be_empty.yml +166 -0
- data/spec/vcr_cassettes/BigML_Model/one_model/must_be_able_to_be_find_using_the_reference.yml +446 -0
- data/spec/vcr_cassettes/BigML_Model/one_model/must_be_able_to_remove_the_model.yml +426 -0
- data/spec/vcr_cassettes/BigML_Model/one_model/must_be_able_to_update_the_name.yml +558 -0
- data/spec/vcr_cassettes/BigML_Model/one_model/must_have_only_one_item.yml +258 -0
- data/spec/vcr_cassettes/BigML_Model/one_model/must_have_the_same_file_name.yml +375 -0
- data/spec/vcr_cassettes/BigML_Model/one_model/must_have_the_same_size.yml +375 -0
- data/spec/vcr_cassettes/BigML_Model/one_model/was_created_successfully.yml +298 -0
- data/spec/vcr_cassettes/BigML_Prediction/no_prediction/_all/must_be_empty.yml +305 -0
- data/spec/vcr_cassettes/BigML_Prediction/one_prediction/must_be_able_to_be_find_using_the_reference.yml +502 -0
- data/spec/vcr_cassettes/BigML_Prediction/one_prediction/must_be_able_to_remove_the_prediction.yml +547 -0
- data/spec/vcr_cassettes/BigML_Prediction/one_prediction/must_be_able_to_update_the_name.yml +546 -0
- data/spec/vcr_cassettes/BigML_Prediction/one_prediction/must_have_only_one_item.yml +503 -0
- data/spec/vcr_cassettes/BigML_Prediction/one_prediction/must_have_the_same_name.yml +420 -0
- data/spec/vcr_cassettes/BigML_Prediction/one_prediction/was_created_successfully.yml +297 -0
- data/spec/vcr_cassettes/BigML_Source/no_source/_all/must_be_empty.yml +136 -0
- data/spec/vcr_cassettes/BigML_Source/one_source/must_be_able_to_be_find_using_the_reference.yml +191 -0
- data/spec/vcr_cassettes/BigML_Source/one_source/must_be_able_to_remove_the_source.yml +195 -0
- data/spec/vcr_cassettes/BigML_Source/one_source/must_be_able_to_update_the_name.yml +279 -0
- data/spec/vcr_cassettes/BigML_Source/one_source/must_have_only_one_item.yml +192 -0
- data/spec/vcr_cassettes/BigML_Source/one_source/must_have_the_same_file_name.yml +192 -0
- data/spec/vcr_cassettes/BigML_Source/one_source/was_created_successfully.yml +105 -0
- metadata +224 -0
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use --create ruby-1.9.3-p194@bigml > /dev/null
|
data/.rvmrc.example
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use --create ruby-1.9.3-p194@bigml > /dev/null
|
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Vicent Gozalbes
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# BigML
|
2
|
+
|
3
|
+
A Ruby wrapper for the [BigML REST API](https://bigml.com/developers)
|
4
|
+
|
5
|
+
## Compile into system gems
|
6
|
+
|
7
|
+
rake build; rake install
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
gem 'big_ml'
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
require 'big_ml'
|
23
|
+
|
24
|
+
BigML.configure do |c|
|
25
|
+
c.username = 'foo'
|
26
|
+
c.api_key = 'bar'
|
27
|
+
end
|
28
|
+
|
29
|
+
source = BigML::Source.create("spec/fixtures/iris.csv")
|
30
|
+
dataset = BigML::Dataset.create(source.resource)
|
31
|
+
model = BigML::Model.create(dataset.resource)
|
32
|
+
prediction = BigML::Prediction.create(model.resource, { :input_data => { "000001" => 3 }})
|
33
|
+
```
|
34
|
+
|
35
|
+
## Ruby Interpreter Compatibility
|
36
|
+
This library has been tested on the following ruby interpreters:
|
37
|
+
|
38
|
+
* MRI 1.9.2
|
39
|
+
* MRI 1.9.3
|
40
|
+
|
41
|
+
[![Build Status](https://secure.travis-ci.org/vigosan/big_ml.png?branch=master)](http://travis-ci.org/vigosan/big_ml)
|
42
|
+
|
43
|
+
## Contributing
|
44
|
+
|
45
|
+
1. Fork it
|
46
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
47
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
48
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
49
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/TODO.md
ADDED
data/big_ml.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/big_ml/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Vicent Gozalbes", "Felipe Talavera"]
|
6
|
+
gem.email = ["vigosan@gmail.com", "felipe.talavera@gmail.com"]
|
7
|
+
gem.description = %q{A Ruby wrapper for the BigML REST API}
|
8
|
+
gem.summary = %q{A Ruby wrapper for the BigML REST API}
|
9
|
+
gem.homepage = "https://bigml.com"
|
10
|
+
|
11
|
+
gem.add_dependency "httmultiparty"
|
12
|
+
gem.add_development_dependency "rake"
|
13
|
+
gem.add_development_dependency "rspec"
|
14
|
+
gem.add_development_dependency "vcr"
|
15
|
+
gem.add_development_dependency "fakeweb"
|
16
|
+
|
17
|
+
gem.files = `git ls-files`.split($\)
|
18
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
19
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
20
|
+
gem.name = "big_ml"
|
21
|
+
gem.require_paths = ["lib"]
|
22
|
+
gem.version = BigML::VERSION
|
23
|
+
end
|
data/lib/big_ml/base.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
module BigML
|
2
|
+
class Base
|
3
|
+
attr_accessor :attrs
|
4
|
+
|
5
|
+
def initialize(attrs = {})
|
6
|
+
@attrs = attrs.dup
|
7
|
+
@attrs.each { |key, value|
|
8
|
+
instance_variable_set("@#{key}".to_sym, value)
|
9
|
+
}
|
10
|
+
end
|
11
|
+
|
12
|
+
def id
|
13
|
+
resource.split('/').last
|
14
|
+
end
|
15
|
+
|
16
|
+
class << self
|
17
|
+
def all(options = {})
|
18
|
+
response = client.get("/#{resource_name}", options)
|
19
|
+
response['objects'].map { |source| self.new(source) } if response.success?
|
20
|
+
end
|
21
|
+
|
22
|
+
def find(id, options = {})
|
23
|
+
response = client.get("/#{resource_name}/#{id}", options)
|
24
|
+
self.new(response) if response.success?
|
25
|
+
end
|
26
|
+
|
27
|
+
def update(id, options = {})
|
28
|
+
client.put("/#{resource_name}/#{id}", {}, options)
|
29
|
+
end
|
30
|
+
|
31
|
+
def delete(id)
|
32
|
+
response = client.delete("/#{resource_name}/#{id}")
|
33
|
+
response.success?
|
34
|
+
end
|
35
|
+
|
36
|
+
def delete_all
|
37
|
+
all.each {|s| delete(s.id) }
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def client
|
43
|
+
@client ||= Client.new
|
44
|
+
end
|
45
|
+
|
46
|
+
def resource_name
|
47
|
+
self.name.split("::").last.downcase
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'httmultiparty'
|
2
|
+
require 'big_ml/authenticable'
|
3
|
+
require 'big_ml/config'
|
4
|
+
require 'big_ml/request'
|
5
|
+
require 'big_ml/base'
|
6
|
+
require 'big_ml/source'
|
7
|
+
require 'big_ml/dataset'
|
8
|
+
require 'big_ml/model'
|
9
|
+
require 'big_ml/prediction'
|
10
|
+
|
11
|
+
module BigML
|
12
|
+
class Client
|
13
|
+
include HTTMultiParty
|
14
|
+
include Authenticable
|
15
|
+
include Request
|
16
|
+
format :json
|
17
|
+
|
18
|
+
base_uri Config::BIGML_ENDPOINT
|
19
|
+
|
20
|
+
attr_accessor *Config::VALID_OPTIONS_KEYS
|
21
|
+
|
22
|
+
def initialize(attrs={})
|
23
|
+
attrs = BigML.options.merge(attrs)
|
24
|
+
Config::VALID_OPTIONS_KEYS.each { |key|
|
25
|
+
instance_variable_set("@#{key}".to_sym, attrs[key])
|
26
|
+
}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module BigML
|
2
|
+
module Config
|
3
|
+
# The endpoint that will be used to connect if none is set
|
4
|
+
BIGML_ENDPOINT = "https://bigml.io/andromeda"
|
5
|
+
# The username if none is set
|
6
|
+
DEFAULT_BIGML_USERNAME = nil
|
7
|
+
# The api key if none is set
|
8
|
+
DEFAULT_BIGML_API_KEY = nil
|
9
|
+
# An array of valid keys in the options hash when configuring a {BigML::Client}
|
10
|
+
VALID_OPTIONS_KEYS = [:username, :api_key]
|
11
|
+
|
12
|
+
attr_accessor *VALID_OPTIONS_KEYS
|
13
|
+
|
14
|
+
def configure
|
15
|
+
yield self
|
16
|
+
self
|
17
|
+
end
|
18
|
+
|
19
|
+
def options
|
20
|
+
options = {}
|
21
|
+
VALID_OPTIONS_KEYS.each{ |k| options[k] = send(k) }
|
22
|
+
options
|
23
|
+
end
|
24
|
+
|
25
|
+
def reset
|
26
|
+
self.username = DEFAULT_BIGML_USERNAME
|
27
|
+
self.api_key = DEFAULT_BIGML_API_KEY
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module BigML
|
2
|
+
class Dataset < Base
|
3
|
+
DATASET_PROPERTIES = [
|
4
|
+
:category, :code, :columns, :created, :credits,
|
5
|
+
:description, :fields, :locale, :name, :number_of_models,
|
6
|
+
:number_of_predictions, :private, :resource, :rows, :size,
|
7
|
+
:source, :source_status, :status, :tags, :updated
|
8
|
+
]
|
9
|
+
|
10
|
+
attr_reader *DATASET_PROPERTIES
|
11
|
+
|
12
|
+
class << self
|
13
|
+
def create(source, options = {})
|
14
|
+
response = client.post("/#{resource_name}", options, { :source => source })
|
15
|
+
self.new(response) if response.success?
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/big_ml/model.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
module BigML
|
2
|
+
class Model < Base
|
3
|
+
MODEL_PROPERTIES = [
|
4
|
+
:category, :code, :columns, :created, :credits,
|
5
|
+
:dataset, :dataset_status, :description, :holdout,
|
6
|
+
:input_fields, :locale, :max_columns, :max_rows, :model,
|
7
|
+
:name, :number_of_predictions, :objective_fields, :private,
|
8
|
+
:range, :resource, :rows, :size, :source, :source_status,
|
9
|
+
:status, :tags, :updated
|
10
|
+
]
|
11
|
+
|
12
|
+
attr_reader *MODEL_PROPERTIES
|
13
|
+
|
14
|
+
class << self
|
15
|
+
def create(dataset, options = {})
|
16
|
+
response = client.post("/#{resource_name}", options, { :dataset => dataset })
|
17
|
+
self.new(response) if response.success?
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module BigML
|
2
|
+
class Prediction < Base
|
3
|
+
PREDICTION_PROPERTIES = [
|
4
|
+
:category, :code, :created, :credits, :dataset, :dataset_status,
|
5
|
+
:description, :fields, :input_data, :model, :model_status, :name,
|
6
|
+
:objective_fields, :prediction, :prediction_path, :private, :resource,
|
7
|
+
:source, :source_status, :status, :tags, :updated
|
8
|
+
]
|
9
|
+
|
10
|
+
attr_reader *PREDICTION_PROPERTIES
|
11
|
+
|
12
|
+
class << self
|
13
|
+
def create(model, options = {})
|
14
|
+
response = client.post("/#{resource_name}", {}, { :model => model }.merge!(options))
|
15
|
+
self.new(response) if response.success?
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module BigML
|
2
|
+
module Request
|
3
|
+
def get(path, options = {}, body = {})
|
4
|
+
self.class.get(path, prepare_options(options, body))
|
5
|
+
end
|
6
|
+
|
7
|
+
def put(path, options = {}, body = {})
|
8
|
+
self.class.put(path, prepare_options(options, body))
|
9
|
+
end
|
10
|
+
|
11
|
+
def post(path, options = {}, body = {})
|
12
|
+
self.class.post(path, prepare_options(options, body))
|
13
|
+
end
|
14
|
+
|
15
|
+
def delete(path, options = {}, body = {})
|
16
|
+
self.class.delete(path, prepare_options(options, body))
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
def prepare_options(options, body)
|
21
|
+
options.merge!(credentials)
|
22
|
+
if body.empty?
|
23
|
+
{ :query => options }
|
24
|
+
else
|
25
|
+
{ :headers => {'content-type' => 'application/json'}, :query => options, :body => body.to_json }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module BigML
|
2
|
+
class Source < Base
|
3
|
+
SOURCE_PROPERTIES = [
|
4
|
+
:code, :content_type, :created, :credits, :fields, :file_name, :md5,
|
5
|
+
:name, :number_of_datasets, :number_of_models, :number_of_predictions,
|
6
|
+
:private, :resource, :size, :source_parser, :status, :type, :updated
|
7
|
+
]
|
8
|
+
|
9
|
+
attr_reader *SOURCE_PROPERTIES
|
10
|
+
|
11
|
+
class << self
|
12
|
+
def create(file, options = {})
|
13
|
+
response = client.post("/#{resource_name}", options.merge(:multipart => true, :file => File.new(file)))
|
14
|
+
self.new(response) if response.success?
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/big_ml.rb
ADDED
@@ -0,0 +1,151 @@
|
|
1
|
+
sepal length,sepal width,petal length,petal width,species
|
2
|
+
5.1,3.5,1.4,0.2,Iris-setosa
|
3
|
+
4.9,3.0,1.4,0.2,Iris-setosa
|
4
|
+
4.7,3.2,1.3,0.2,Iris-setosa
|
5
|
+
4.6,3.1,1.5,0.2,Iris-setosa
|
6
|
+
5.0,3.6,1.4,0.2,Iris-setosa
|
7
|
+
5.4,3.9,1.7,0.4,Iris-setosa
|
8
|
+
4.6,3.4,1.4,0.3,Iris-setosa
|
9
|
+
5.0,3.4,1.5,0.2,Iris-setosa
|
10
|
+
4.4,2.9,1.4,0.2,Iris-setosa
|
11
|
+
4.9,3.1,1.5,0.1,Iris-setosa
|
12
|
+
5.4,3.7,1.5,0.2,Iris-setosa
|
13
|
+
4.8,3.4,1.6,0.2,Iris-setosa
|
14
|
+
4.8,3.0,1.4,0.1,Iris-setosa
|
15
|
+
4.3,3.0,1.1,0.1,Iris-setosa
|
16
|
+
5.8,4.0,1.2,0.2,Iris-setosa
|
17
|
+
5.7,4.4,1.5,0.4,Iris-setosa
|
18
|
+
5.4,3.9,1.3,0.4,Iris-setosa
|
19
|
+
5.1,3.5,1.4,0.3,Iris-setosa
|
20
|
+
5.7,3.8,1.7,0.3,Iris-setosa
|
21
|
+
5.1,3.8,1.5,0.3,Iris-setosa
|
22
|
+
5.4,3.4,1.7,0.2,Iris-setosa
|
23
|
+
5.1,3.7,1.5,0.4,Iris-setosa
|
24
|
+
4.6,3.6,1.0,0.2,Iris-setosa
|
25
|
+
5.1,3.3,1.7,0.5,Iris-setosa
|
26
|
+
4.8,3.4,1.9,0.2,Iris-setosa
|
27
|
+
5.0,3.0,1.6,0.2,Iris-setosa
|
28
|
+
5.0,3.4,1.6,0.4,Iris-setosa
|
29
|
+
5.2,3.5,1.5,0.2,Iris-setosa
|
30
|
+
5.2,3.4,1.4,0.2,Iris-setosa
|
31
|
+
4.7,3.2,1.6,0.2,Iris-setosa
|
32
|
+
4.8,3.1,1.6,0.2,Iris-setosa
|
33
|
+
5.4,3.4,1.5,0.4,Iris-setosa
|
34
|
+
5.2,4.1,1.5,0.1,Iris-setosa
|
35
|
+
5.5,4.2,1.4,0.2,Iris-setosa
|
36
|
+
4.9,3.1,1.5,0.2,Iris-setosa
|
37
|
+
5.0,3.2,1.2,0.2,Iris-setosa
|
38
|
+
5.5,3.5,1.3,0.2,Iris-setosa
|
39
|
+
4.9,3.6,1.4,0.1,Iris-setosa
|
40
|
+
4.4,3.0,1.3,0.2,Iris-setosa
|
41
|
+
5.1,3.4,1.5,0.2,Iris-setosa
|
42
|
+
5.0,3.5,1.3,0.3,Iris-setosa
|
43
|
+
4.5,2.3,1.3,0.3,Iris-setosa
|
44
|
+
4.4,3.2,1.3,0.2,Iris-setosa
|
45
|
+
5.0,3.5,1.6,0.6,Iris-setosa
|
46
|
+
5.1,3.8,1.9,0.4,Iris-setosa
|
47
|
+
4.8,3.0,1.4,0.3,Iris-setosa
|
48
|
+
5.1,3.8,1.6,0.2,Iris-setosa
|
49
|
+
4.6,3.2,1.4,0.2,Iris-setosa
|
50
|
+
5.3,3.7,1.5,0.2,Iris-setosa
|
51
|
+
5.0,3.3,1.4,0.2,Iris-setosa
|
52
|
+
7.0,3.2,4.7,1.4,Iris-versicolor
|
53
|
+
6.4,3.2,4.5,1.5,Iris-versicolor
|
54
|
+
6.9,3.1,4.9,1.5,Iris-versicolor
|
55
|
+
5.5,2.3,4.0,1.3,Iris-versicolor
|
56
|
+
6.5,2.8,4.6,1.5,Iris-versicolor
|
57
|
+
5.7,2.8,4.5,1.3,Iris-versicolor
|
58
|
+
6.3,3.3,4.7,1.6,Iris-versicolor
|
59
|
+
4.9,2.4,3.3,1.0,Iris-versicolor
|
60
|
+
6.6,2.9,4.6,1.3,Iris-versicolor
|
61
|
+
5.2,2.7,3.9,1.4,Iris-versicolor
|
62
|
+
5.0,2.0,3.5,1.0,Iris-versicolor
|
63
|
+
5.9,3.0,4.2,1.5,Iris-versicolor
|
64
|
+
6.0,2.2,4.0,1.0,Iris-versicolor
|
65
|
+
6.1,2.9,4.7,1.4,Iris-versicolor
|
66
|
+
5.6,2.9,3.6,1.3,Iris-versicolor
|
67
|
+
6.7,3.1,4.4,1.4,Iris-versicolor
|
68
|
+
5.6,3.0,4.5,1.5,Iris-versicolor
|
69
|
+
5.8,2.7,4.1,1.0,Iris-versicolor
|
70
|
+
6.2,2.2,4.5,1.5,Iris-versicolor
|
71
|
+
5.6,2.5,3.9,1.1,Iris-versicolor
|
72
|
+
5.9,3.2,4.8,1.8,Iris-versicolor
|
73
|
+
6.1,2.8,4.0,1.3,Iris-versicolor
|
74
|
+
6.3,2.5,4.9,1.5,Iris-versicolor
|
75
|
+
6.1,2.8,4.7,1.2,Iris-versicolor
|
76
|
+
6.4,2.9,4.3,1.3,Iris-versicolor
|
77
|
+
6.6,3.0,4.4,1.4,Iris-versicolor
|
78
|
+
6.8,2.8,4.8,1.4,Iris-versicolor
|
79
|
+
6.7,3.0,5.0,1.7,Iris-versicolor
|
80
|
+
6.0,2.9,4.5,1.5,Iris-versicolor
|
81
|
+
5.7,2.6,3.5,1.0,Iris-versicolor
|
82
|
+
5.5,2.4,3.8,1.1,Iris-versicolor
|
83
|
+
5.5,2.4,3.7,1.0,Iris-versicolor
|
84
|
+
5.8,2.7,3.9,1.2,Iris-versicolor
|
85
|
+
6.0,2.7,5.1,1.6,Iris-versicolor
|
86
|
+
5.4,3.0,4.5,1.5,Iris-versicolor
|
87
|
+
6.0,3.4,4.5,1.6,Iris-versicolor
|
88
|
+
6.7,3.1,4.7,1.5,Iris-versicolor
|
89
|
+
6.3,2.3,4.4,1.3,Iris-versicolor
|
90
|
+
5.6,3.0,4.1,1.3,Iris-versicolor
|
91
|
+
5.5,2.5,4.0,1.3,Iris-versicolor
|
92
|
+
5.5,2.6,4.4,1.2,Iris-versicolor
|
93
|
+
6.1,3.0,4.6,1.4,Iris-versicolor
|
94
|
+
5.8,2.6,4.0,1.2,Iris-versicolor
|
95
|
+
5.0,2.3,3.3,1.0,Iris-versicolor
|
96
|
+
5.6,2.7,4.2,1.3,Iris-versicolor
|
97
|
+
5.7,3.0,4.2,1.2,Iris-versicolor
|
98
|
+
5.7,2.9,4.2,1.3,Iris-versicolor
|
99
|
+
6.2,2.9,4.3,1.3,Iris-versicolor
|
100
|
+
5.1,2.5,3.0,1.1,Iris-versicolor
|
101
|
+
5.7,2.8,4.1,1.3,Iris-versicolor
|
102
|
+
6.3,3.3,6.0,2.5,Iris-virginica
|
103
|
+
5.8,2.7,5.1,1.9,Iris-virginica
|
104
|
+
7.1,3.0,5.9,2.1,Iris-virginica
|
105
|
+
6.3,2.9,5.6,1.8,Iris-virginica
|
106
|
+
6.5,3.0,5.8,2.2,Iris-virginica
|
107
|
+
7.6,3.0,6.6,2.1,Iris-virginica
|
108
|
+
4.9,2.5,4.5,1.7,Iris-virginica
|
109
|
+
7.3,2.9,6.3,1.8,Iris-virginica
|
110
|
+
6.7,2.5,5.8,1.8,Iris-virginica
|
111
|
+
7.2,3.6,6.1,2.5,Iris-virginica
|
112
|
+
6.5,3.2,5.1,2.0,Iris-virginica
|
113
|
+
6.4,2.7,5.3,1.9,Iris-virginica
|
114
|
+
6.8,3.0,5.5,2.1,Iris-virginica
|
115
|
+
5.7,2.5,5.0,2.0,Iris-virginica
|
116
|
+
5.8,2.8,5.1,2.4,Iris-virginica
|
117
|
+
6.4,3.2,5.3,2.3,Iris-virginica
|
118
|
+
6.5,3.0,5.5,1.8,Iris-virginica
|
119
|
+
7.7,3.8,6.7,2.2,Iris-virginica
|
120
|
+
7.7,2.6,6.9,2.3,Iris-virginica
|
121
|
+
6.0,2.2,5.0,1.5,Iris-virginica
|
122
|
+
6.9,3.2,5.7,2.3,Iris-virginica
|
123
|
+
5.6,2.8,4.9,2.0,Iris-virginica
|
124
|
+
7.7,2.8,6.7,2.0,Iris-virginica
|
125
|
+
6.3,2.7,4.9,1.8,Iris-virginica
|
126
|
+
6.7,3.3,5.7,2.1,Iris-virginica
|
127
|
+
7.2,3.2,6.0,1.8,Iris-virginica
|
128
|
+
6.2,2.8,4.8,1.8,Iris-virginica
|
129
|
+
6.1,3.0,4.9,1.8,Iris-virginica
|
130
|
+
6.4,2.8,5.6,2.1,Iris-virginica
|
131
|
+
7.2,3.0,5.8,1.6,Iris-virginica
|
132
|
+
7.4,2.8,6.1,1.9,Iris-virginica
|
133
|
+
7.9,3.8,6.4,2.0,Iris-virginica
|
134
|
+
6.4,2.8,5.6,2.2,Iris-virginica
|
135
|
+
6.3,2.8,5.1,1.5,Iris-virginica
|
136
|
+
6.1,2.6,5.6,1.4,Iris-virginica
|
137
|
+
7.7,3.0,6.1,2.3,Iris-virginica
|
138
|
+
6.3,3.4,5.6,2.4,Iris-virginica
|
139
|
+
6.4,3.1,5.5,1.8,Iris-virginica
|
140
|
+
6.0,3.0,4.8,1.8,Iris-virginica
|
141
|
+
6.9,3.1,5.4,2.1,Iris-virginica
|
142
|
+
6.7,3.1,5.6,2.4,Iris-virginica
|
143
|
+
6.9,3.1,5.1,2.3,Iris-virginica
|
144
|
+
5.8,2.7,5.1,1.9,Iris-virginica
|
145
|
+
6.8,3.2,5.9,2.3,Iris-virginica
|
146
|
+
6.7,3.3,5.7,2.5,Iris-virginica
|
147
|
+
6.7,3.0,5.2,2.3,Iris-virginica
|
148
|
+
6.3,2.5,5.0,1.9,Iris-virginica
|
149
|
+
6.5,3.0,5.2,2.0,Iris-virginica
|
150
|
+
6.2,3.4,5.4,2.3,Iris-virginica
|
151
|
+
5.9,3.0,5.1,1.8,Iris-virginica
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe BigML::Dataset, :vcr do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
BigML::Source.delete_all
|
7
|
+
BigML::Dataset.delete_all
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "no dataset" do
|
11
|
+
describe ".all" do
|
12
|
+
it "must be empty" do
|
13
|
+
BigML::Dataset.all.should == []
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "one dataset" do
|
19
|
+
before do
|
20
|
+
@source = BigML::Source.create("spec/fixtures/iris.csv")
|
21
|
+
@dataset = BigML::Dataset.create(@source.resource)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "was created successfully" do
|
25
|
+
@dataset.code.should == 201
|
26
|
+
end
|
27
|
+
|
28
|
+
it "must have only one item" do
|
29
|
+
BigML::Dataset.all.should have(1).datasets
|
30
|
+
end
|
31
|
+
|
32
|
+
it "must have the same file_name" do
|
33
|
+
BigML::Dataset.all.first.size.should == 4608
|
34
|
+
end
|
35
|
+
|
36
|
+
it "must be able to be find using the reference" do
|
37
|
+
BigML::Dataset.find(@dataset.id) == @dataset
|
38
|
+
end
|
39
|
+
|
40
|
+
it "must be able to update the name" do
|
41
|
+
BigML::Dataset.update(@dataset.id, { :name => 'foo name' }).code.should == 202
|
42
|
+
BigML::Dataset.find(@dataset.id).name.should == 'foo name'
|
43
|
+
end
|
44
|
+
|
45
|
+
it "must be able to remove the dataset" do
|
46
|
+
BigML::Dataset.delete(@dataset.id)
|
47
|
+
BigML::Dataset.find(@dataset.id).should be_nil
|
48
|
+
BigML::Dataset.all.should have(0).datasets
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe BigML::Model, :vcr do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
BigML::Source.delete_all
|
7
|
+
BigML::Dataset.delete_all
|
8
|
+
BigML::Model.delete_all
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "no model" do
|
12
|
+
describe ".all" do
|
13
|
+
it "must be empty" do
|
14
|
+
BigML::Model.all.should == []
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "one model" do
|
20
|
+
before do
|
21
|
+
@source = BigML::Source.create("spec/fixtures/iris.csv")
|
22
|
+
@dataset = BigML::Dataset.create(@source.resource)
|
23
|
+
@model = BigML::Model.create(@dataset.resource)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "was created successfully" do
|
27
|
+
@model.code.should == 201
|
28
|
+
end
|
29
|
+
|
30
|
+
it "must have only one item" do
|
31
|
+
BigML::Model.all.should have(1).models
|
32
|
+
end
|
33
|
+
|
34
|
+
it "must have the same size" do
|
35
|
+
BigML::Model.all.first.size.should == 4608
|
36
|
+
end
|
37
|
+
|
38
|
+
it "must be able to be find using the reference" do
|
39
|
+
BigML::Model.find(@model.id) == @model
|
40
|
+
end
|
41
|
+
|
42
|
+
it "must be able to update the name" do
|
43
|
+
BigML::Model.update(@model.id, { :name => 'foo name' }).code.should == 202
|
44
|
+
BigML::Model.find(@model.id).name.should == 'foo name'
|
45
|
+
end
|
46
|
+
|
47
|
+
it "must be able to remove the model" do
|
48
|
+
BigML::Model.delete(@model.id)
|
49
|
+
BigML::Model.find(@model.id).should be_nil
|
50
|
+
BigML::Model.all.should have(0).models
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|