Class: ML::Data::Generator2D
- Defined in:
- lib/data/generator.rb
Overview
Generating sample points on 2D plane
Class Method Summary collapse
-
.point_from_line(coef, x) ⇒ Array
Generate point from line.
Instance Method Summary collapse
-
#initialize(x_range = 100, y_range = 100, noise = 0, model = :random) ⇒ Generator2D
constructor
Initialize a generator.
-
#points_2d(points, coef = [-1.0, 1.0, 0.0]) ⇒ Hash
Generate two groups of points on 2d plain.
Methods inherited from Generator
Constructor Details
#initialize(x_range = 100, y_range = 100, noise = 0, model = :random) ⇒ Generator2D
Initialize a generator
91 92 93 94 95 96 |
# File 'lib/data/generator.rb', line 91 def initialize x_range = 100, y_range = 100, noise = 0, model = :random @x_range = x_range @y_range = y_range @noise = noise @model = model end |
Class Method Details
.point_from_line(coef, x) ⇒ Array
Generate point from line
79 80 81 |
# File 'lib/data/generator.rb', line 79 def self.point_from_line coef, x [x, (-coef[2]-(coef[0] * x))/coef[1]] end |
Instance Method Details
#points_2d(points, coef = [-1.0, 1.0, 0.0]) ⇒ Hash
Generate two groups of points on 2d plain
103 104 105 |
# File 'lib/data/generator.rb', line 103 def points_2d points, coef = [-1.0, 1.0, 0.0] points(points, coef) end |