MLMachine 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/MLMachine.gemspec +27 -0
- data/README.md +44 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/MLMachine.rb +313 -0
- data/lib/MLMachine/version.rb +3 -0
- metadata +86 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 25fb5bc3398410b1c97d15dc3b84f65ad2e6b36843e67ab6fd716ef42ab8e003
|
4
|
+
data.tar.gz: 93fdfaed53432af4a781b6ddbaf3ee34e898e827d9f62b985f039f0a64a5241d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6014305d58580281707ed9b7b6ed872d14628452bb74f7e50a31491ffac40373a446458cb0d6bd93a8de81f15baf83edf4938350d2120a6d12575a818ea6659a
|
7
|
+
data.tar.gz: 745ebb0ad0f425780f50aab30c2c507802ee2520978949d58b3a9b3beca85bba5ae35766d160c482d102b0e22547ce0c223a059e267d22d083e441e92dc07765
|
data/.gitignore
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at gitea@fake.local. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [https://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: https://contributor-covenant.org
|
74
|
+
[version]: https://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Gitea
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/MLMachine.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require_relative 'lib/MLMachine/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "MLMachine"
|
5
|
+
spec.version = MLMachine::VERSION
|
6
|
+
spec.authors = ["Gitea"]
|
7
|
+
spec.email = ["gitea@fake.local"]
|
8
|
+
|
9
|
+
spec.summary = %q{This is a Ruby gem for placing different machine learning gems inside a state machine, to be called inside a Dynamic Case.}
|
10
|
+
spec.description = %q{If I completely implement all the functions I need in a state machine, the state machine that calls all the different machine learning would end up much longer than the command itself. This is a nightmare to bug test, so made a gem to call it with one line.}
|
11
|
+
spec.homepage = "https://lwflouisa.github.io/Weaver-AI"
|
12
|
+
spec.license = "MIT"
|
13
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
14
|
+
|
15
|
+
# Specify which files should be added to the gem when it is released.
|
16
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
17
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
18
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
19
|
+
end
|
20
|
+
|
21
|
+
spec.bindir = "exe"
|
22
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
|
+
spec.require_paths = ["lib"]
|
24
|
+
|
25
|
+
spec.add_runtime_dependency 'rules_ai', '~> 0.6.0'
|
26
|
+
spec.add_runtime_dependency 'naive_bayes', '~> 0.0.3'
|
27
|
+
end
|
data/README.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# MLMachine
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/MLMachine`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'MLMachine'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle install
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install MLMachine
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/MLMachine. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/MLMachine/blob/master/CODE_OF_CONDUCT.md).
|
36
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
41
|
+
|
42
|
+
## Code of Conduct
|
43
|
+
|
44
|
+
Everyone interacting in the MLMachine project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/MLMachine/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "MLMachine"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/MLMachine.rb
ADDED
@@ -0,0 +1,313 @@
|
|
1
|
+
require "MLMachine/version"
|
2
|
+
|
3
|
+
module MLMachine
|
4
|
+
class Error < StandardError; end
|
5
|
+
|
6
|
+
class StateMachine
|
7
|
+
def self.translate
|
8
|
+
number = File.read("data/input/number.txt").strip.to_i
|
9
|
+
input = File.read("data/input/input.txt")
|
10
|
+
|
11
|
+
active_input = input[number].downcase.split(" ")
|
12
|
+
|
13
|
+
translate = {
|
14
|
+
'ruh' => "the-masculine",
|
15
|
+
'rah' => "the-feminine",
|
16
|
+
'roh' => "the-neuter",
|
17
|
+
'yona' => "a",
|
18
|
+
'yonei' => "an",
|
19
|
+
'yonas' => "a-neuter",
|
20
|
+
'eneru' => "black",
|
21
|
+
'berena' => "white",
|
22
|
+
'erudi' => "red",
|
23
|
+
'eviyette' => "purple",
|
24
|
+
'beru' => "red",
|
25
|
+
'evene' => "green",
|
26
|
+
'yeru' => "yellow",
|
27
|
+
'eranige' => "orange",
|
28
|
+
'enesu' => "North",
|
29
|
+
'wesi' => "West",
|
30
|
+
'easi' => "East",
|
31
|
+
'siuha' => "South",
|
32
|
+
'upe' => "up",
|
33
|
+
'dio' => "down",
|
34
|
+
'feru' => "dorward",
|
35
|
+
'biosi' => "backward",
|
36
|
+
'iniwa' => "inward",
|
37
|
+
'utiwa' => "outward",
|
38
|
+
'esakeru' => "sneakers",
|
39
|
+
'deruesu' => "dress-shoes",
|
40
|
+
'eheru' => "heels",
|
41
|
+
'siabi' => "clogs",
|
42
|
+
'siabi-biesa' => "wooden-clogs",
|
43
|
+
'berukiesiti' => "birkenstocks",
|
44
|
+
'esiadi' => "sandals",
|
45
|
+
'tero' => "trousers",
|
46
|
+
'sikeru' => "skirt",
|
47
|
+
'deresi' => "dress",
|
48
|
+
'sehiere' => "shirt",
|
49
|
+
'sioki' => "stocking",
|
50
|
+
'sitaka' => "socks",
|
51
|
+
'sitaki' => "steak",
|
52
|
+
'siho-sitaki' => "chop-steak",
|
53
|
+
'befi' => "beef",
|
54
|
+
'shikini' => "chicken",
|
55
|
+
'tieru' => "turkey",
|
56
|
+
'liam' => "lamb",
|
57
|
+
'ehaki' => "elk",
|
58
|
+
'deru' => "deer",
|
59
|
+
'pirosi' => "porc",
|
60
|
+
'bieru' => "bear",
|
61
|
+
'siaro' => "carrot",
|
62
|
+
'pitat' => "potato",
|
63
|
+
'siaba' => "cabbage",
|
64
|
+
'sipinas' => "spinach",
|
65
|
+
'eretuce' => "lettuce",
|
66
|
+
'siwa-pitat' => "sweet-potato",
|
67
|
+
'ginie' => "ginger",
|
68
|
+
'siquasi' => "squash",
|
69
|
+
'piemaki' => "pumpkin",
|
70
|
+
'tea' => "tea",
|
71
|
+
'siofee' => "coffee",
|
72
|
+
'eribos' => "herbs",
|
73
|
+
'givimio' => 'give-me',
|
74
|
+
'ehieru' => 'hour',
|
75
|
+
'vieruti' => 'vortex',
|
76
|
+
'perumipito' => 'promptor',
|
77
|
+
'esipier' => 'cipher',
|
78
|
+
'digisi-esitimi' => 'digest estimate',
|
79
|
+
'ehypier-sierusutio' => 'hyper-calculation',
|
80
|
+
}
|
81
|
+
|
82
|
+
word_01 = translate[active_input[0]]
|
83
|
+
word_02 = translate[active_input[1]]
|
84
|
+
word_03 = translate[active_input[2]]
|
85
|
+
word_04 = translate[active_input[3]]
|
86
|
+
word_05 = translate[active_input[4]]
|
87
|
+
word_06 = translate[active_input[5]]
|
88
|
+
word_07 = translate[active_input[6]]
|
89
|
+
word_08 = translate[active_input[7]]
|
90
|
+
word_09 = translate[active_input[8]]
|
91
|
+
word_10 = translate[active_input[9]]
|
92
|
+
|
93
|
+
translated = "Translated: #{word_01} #{word_02} #{word_03} #{word_04} #{word_05} #{word_06} #{word_07} #{word_08} #{word_09} #{word_10}"
|
94
|
+
|
95
|
+
open("output/translator/translation.txt", "w") { |f|
|
96
|
+
f.puts translated
|
97
|
+
}
|
98
|
+
end
|
99
|
+
|
100
|
+
def self.classify
|
101
|
+
def self.download_data
|
102
|
+
system("cd data/baysian; w3m /home/sarah/public_sync/downloads/shared_dataset/language.nb")
|
103
|
+
end
|
104
|
+
|
105
|
+
def self.naive_bayes
|
106
|
+
require "naive_bayes"
|
107
|
+
|
108
|
+
a = NaiveBayes.load('data/baysian/language.nb')
|
109
|
+
|
110
|
+
# b = File.read("data/input/document.txt").split(' ')
|
111
|
+
|
112
|
+
number = File.read("data/input/number.txt").strip.to_i
|
113
|
+
input = File.read("data/input/input.txt")
|
114
|
+
|
115
|
+
b = input[number].downcase.split(" ")
|
116
|
+
|
117
|
+
word_one = a.classify(*b[0])
|
118
|
+
word_two = a.classify(*b[1])
|
119
|
+
word_tre = a.classify(*b[2])
|
120
|
+
word_fro = a.classify(*b[3])
|
121
|
+
word_fiv = a.classify(*b[4])
|
122
|
+
word_six = a.classify(*b[5])
|
123
|
+
word_sev = a.classify(*b[6])
|
124
|
+
|
125
|
+
## Labels
|
126
|
+
first_label = word_one[0]
|
127
|
+
second_label = word_two[0]
|
128
|
+
third_label = word_tre[0]
|
129
|
+
fourth_label = word_fro[0]
|
130
|
+
fifth_label = word_fiv[0]
|
131
|
+
sixth_label = word_six[0]
|
132
|
+
seven_label = word_sev[0]
|
133
|
+
|
134
|
+
## Probabilities
|
135
|
+
first_prob = word_one[1]
|
136
|
+
second_prob = word_two[1]
|
137
|
+
third_prob = word_tre[1]
|
138
|
+
fourth_prob = word_fro[1]
|
139
|
+
fifth_prob = word_fiv[1]
|
140
|
+
sixth_prob = word_six[1]
|
141
|
+
seven_prob = word_sev[1]
|
142
|
+
|
143
|
+
open("output/baysian/labels.txt", "w") { |f|
|
144
|
+
f.puts " Labels:\n #{first_label}\n #{second_label}\n #{third_label}\n #{fourth_label}\n #{fifth_label}\n #{sixth_label}\n #{seventh_label}"
|
145
|
+
}
|
146
|
+
|
147
|
+
open("output/baysian/probabilities.txt", "w") { |f|
|
148
|
+
f.puts " Probabilities:\n #{first_prob}\n #{second_prob}\n #{third_prob}\n #{fourth_prob}\n #{fifth_prob}\n #{sixth_prob}\n #{seventh_prob}"
|
149
|
+
}
|
150
|
+
|
151
|
+
puts " Labels:\n #{first_label}\n #{second_label}\n #{third_label}\n #{fourth_label}\n #{fifth_label}\n #{sixth_label}\n #{seventh_label}\n"
|
152
|
+
puts " Probabilities:\n #{first_prob}\n #{second_prob}\n #{third_prob}\n #{fourth_prob}\n #{fifth_prob}\n #{sixth_prob}\n #{seventh_prob}\n\n"
|
153
|
+
end
|
154
|
+
|
155
|
+
def self.remove_data
|
156
|
+
system("cd data/baysian; shred --remove language.nb")
|
157
|
+
end
|
158
|
+
|
159
|
+
MLMachine::StateMachine.classify.download_data
|
160
|
+
MLMachine::StateMachine.classify.naive_bayes
|
161
|
+
MLMachine::StateMachine.classify.remove_data
|
162
|
+
end
|
163
|
+
|
164
|
+
def self.ruleset
|
165
|
+
def self.download_data; system("git clone http://localhost:3000/LWFlouisa/evo_data.git"); end
|
166
|
+
|
167
|
+
def self.line; require "rules_ai"; RulesAi::Rules_Set.line; end
|
168
|
+
def self.square; require "rules_ai"; RulesAi::Rules_Set.square; end
|
169
|
+
def self.cube; require "rules_ai"; RulesAi::Rules_Set.cube; end
|
170
|
+
def self.hyper; require "rules_ai"; RulesAi::Rules_Set.hyper; end
|
171
|
+
|
172
|
+
def self.hours_passed; require "rules_ai"; RulesAi::Rules_Set.hours_passed; end
|
173
|
+
def self.tesla_multiplication; require "rules_ai"; RulesAi::Rules_Set.tesla_multiplication; end
|
174
|
+
def self.autonomous_prompting; require "rules_ai"; RulesAi::Rules_Set.autonomous_prompting; end
|
175
|
+
def self.mixed_13; require "rules_ai"; RulesAi::Rules_Set.mixed_13; end
|
176
|
+
def self.estimate_digest; require "rules_ai"; RulesAi::Rules_Set.estimate_digest; end
|
177
|
+
def self.caculate_hyper; require "rules_ai"; RulesAi::Rules_Set.caculate_hyper; end
|
178
|
+
|
179
|
+
## Fitness Function
|
180
|
+
def self.reset_evo
|
181
|
+
# Gets the bot shape.
|
182
|
+
bot_shape = File.readlines("evo_data/bot_shape/wings.txt")
|
183
|
+
|
184
|
+
# Create a new input vector based on bot data size.
|
185
|
+
bot_input = bot_shape.size.to_i
|
186
|
+
|
187
|
+
# Reset user input to zero.
|
188
|
+
reset_usr_input = 0
|
189
|
+
|
190
|
+
open("evo_data/number/input.txt", "w") { |f|
|
191
|
+
f.puts reset_usr_input
|
192
|
+
}
|
193
|
+
|
194
|
+
# Get random bot_input from bot reset.
|
195
|
+
bot_reset = rand(bot_input)
|
196
|
+
|
197
|
+
open("evo_data/bot_input/input.txt", "w") { |f|
|
198
|
+
f.puts bot_reset
|
199
|
+
}
|
200
|
+
end
|
201
|
+
|
202
|
+
def self.use_form
|
203
|
+
model_type = File.read("evo_data/model/model_type.txt").strip
|
204
|
+
|
205
|
+
puts 'Form status: Suitable...'
|
206
|
+
|
207
|
+
sleep(3)
|
208
|
+
|
209
|
+
number = File.read("evo_data/number/input.txt").strip.to_i
|
210
|
+
usr_wings = File.readlines("evo_data/usr_shape/wings.txt")
|
211
|
+
current_wingset = usr_wings[number].strip
|
212
|
+
|
213
|
+
puts "\nModel Type: #{model_type}\nAction: #{current_wingset}\n"
|
214
|
+
|
215
|
+
sleep(3)
|
216
|
+
|
217
|
+
if current_wingset == "hours_passed"; MLMachine::StateMachine.ruleset.hours_passed;
|
218
|
+
elsif current_wingset == "tesla_multiplication"; MLMachine::StateMachine.ruleset.tesla_multiplication;
|
219
|
+
elsif current_wingset == "autonomous_prompting"; MLMachine::StateMachine.ruleset.autonomous_prompting;
|
220
|
+
elsif current_wingset == "mixed_13"; MLMachine::StateMachine.reset_evo.mixed_13;
|
221
|
+
elsif current_wingset == "estimate_digest"; MLMachine::StateMachine.ruleset.estimate_digest;
|
222
|
+
elsif current_wingset == "calculate_hyper"; MLMachine::StateMachine.ruleset.calculate_hyper;
|
223
|
+
elsif current_wingset == "line"; MLMachine::StateMachine.ruleset.line;
|
224
|
+
elsif current_wingset == "square"; MLMachine::StateMachine.ruleset.square;
|
225
|
+
elsif current_wingset == "cube"; MLMachine::StateMachine.ruleset.cube;
|
226
|
+
elsif current_wingset == "hyper"; MLMachine::StateMachine.ruleset.hyper;
|
227
|
+
end
|
228
|
+
|
229
|
+
MLMachine::StateMachine.ruleset.reset_evo
|
230
|
+
|
231
|
+
abort
|
232
|
+
end
|
233
|
+
|
234
|
+
def self.reshape
|
235
|
+
system("clear")
|
236
|
+
|
237
|
+
model_type = File.read("evo_data/model/model_type.txt").strip
|
238
|
+
|
239
|
+
bot_choice = File.read("evo_data/bot_input/input.txt").strip.to_i
|
240
|
+
number = File.read("evo_data/number/input.txt").strip.to_i
|
241
|
+
|
242
|
+
usr_wings = File.readlines("evo_data/usr_shape/wings.txt")
|
243
|
+
bot_wings = File.readlines("evo_data/bot_shape/wings.txt")
|
244
|
+
|
245
|
+
current_wingset = usr_wings[number]
|
246
|
+
current_botwings = bot_wings[bot_choice]
|
247
|
+
|
248
|
+
puts "The user #{model_type} model is: #{current_wingset}"
|
249
|
+
puts "The bot #{model_type} model is: #{current_botwings}"
|
250
|
+
|
251
|
+
if current_wingset == current_botwings
|
252
|
+
MLMachine::StateMachine.ruleset.use_form
|
253
|
+
else
|
254
|
+
puts "Form status: Changing form..."
|
255
|
+
|
256
|
+
sleep(3)
|
257
|
+
|
258
|
+
new_value = number + 1
|
259
|
+
|
260
|
+
open("evo_data/number/input.txt", "w") { |f|
|
261
|
+
f.puts new_value
|
262
|
+
}
|
263
|
+
end
|
264
|
+
|
265
|
+
MLMachine::StateMachine.ruleset.reset_reshape
|
266
|
+
end
|
267
|
+
|
268
|
+
MLMachine::StateMachine.ruleset.download_data
|
269
|
+
MLMachine::StateMachine.ruleset.reset_evo
|
270
|
+
MLMachine::StateMachine.ruleset.reshape
|
271
|
+
end
|
272
|
+
|
273
|
+
def self.crunch_labels
|
274
|
+
require "finite_machine"
|
275
|
+
|
276
|
+
number = File.read("data/ml_machine/state_machine/input.txt").strip.to_i
|
277
|
+
|
278
|
+
ai_functions = [
|
279
|
+
"ai.init", "ai.translate", "ai.classify",
|
280
|
+
"ai.analyses", "ai.rules_ai"
|
281
|
+
]
|
282
|
+
|
283
|
+
ai = FiniteMachine.new do
|
284
|
+
|
285
|
+
# None turns off the state machine.
|
286
|
+
event :init, :none => :translation
|
287
|
+
event :translate, :translation => :classification
|
288
|
+
event :classify, :classification => :analyze_data
|
289
|
+
event :analyses, :analyze_data => :ruleset
|
290
|
+
event :rules_ai, :ruleset => :none
|
291
|
+
|
292
|
+
# What each event does.
|
293
|
+
on_enter(:translate) { |event|
|
294
|
+
MLMachine::StateMachine.translate
|
295
|
+
}
|
296
|
+
|
297
|
+
on_enter(:classify) { |event|
|
298
|
+
MLMachine::StateMachine.classify
|
299
|
+
}
|
300
|
+
|
301
|
+
on_enter(:analyses) { |event|
|
302
|
+
MLMachine::StateMachine.analyses
|
303
|
+
}
|
304
|
+
|
305
|
+
on_enter(:rules_ai) { |event|
|
306
|
+
MLMachine::StateMachine.ruleset
|
307
|
+
}
|
308
|
+
end
|
309
|
+
|
310
|
+
choose_routine = ai_function[number].to_s
|
311
|
+
end
|
312
|
+
end
|
313
|
+
end
|
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: MLMachine
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Gitea
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-11-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rules_ai
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.6.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.6.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: naive_bayes
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.0.3
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.0.3
|
41
|
+
description: If I completely implement all the functions I need in a state machine,
|
42
|
+
the state machine that calls all the different machine learning would end up much
|
43
|
+
longer than the command itself. This is a nightmare to bug test, so made a gem to
|
44
|
+
call it with one line.
|
45
|
+
email:
|
46
|
+
- gitea@fake.local
|
47
|
+
executables: []
|
48
|
+
extensions: []
|
49
|
+
extra_rdoc_files: []
|
50
|
+
files:
|
51
|
+
- ".gitignore"
|
52
|
+
- CODE_OF_CONDUCT.md
|
53
|
+
- Gemfile
|
54
|
+
- LICENSE.txt
|
55
|
+
- MLMachine.gemspec
|
56
|
+
- README.md
|
57
|
+
- Rakefile
|
58
|
+
- bin/console
|
59
|
+
- bin/setup
|
60
|
+
- lib/MLMachine.rb
|
61
|
+
- lib/MLMachine/version.rb
|
62
|
+
homepage: https://lwflouisa.github.io/Weaver-AI
|
63
|
+
licenses:
|
64
|
+
- MIT
|
65
|
+
metadata: {}
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options: []
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 2.3.0
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
requirements: []
|
81
|
+
rubygems_version: 3.1.2
|
82
|
+
signing_key:
|
83
|
+
specification_version: 4
|
84
|
+
summary: This is a Ruby gem for placing different machine learning gems inside a state
|
85
|
+
machine, to be called inside a Dynamic Case.
|
86
|
+
test_files: []
|