ML_Ruby 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ML_Ruby.gemspec +1 -1
- data/README.md +19 -1
- data/lib/ML_Ruby/version.rb +1 -1
- data/lib/ML_Ruby.rb +14 -0
- data/lib/python/logistic_regression.py +27 -0
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d7da3da13e82053288079280a0a180b29129a1147329cb951d32ac3c34fc431
|
4
|
+
data.tar.gz: 15708947a613b924d67b7f0c67906d65c0a08cd05bd2b0aa517d4d993bf82871
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00f00c1a7bdfe410bc5975fccc91d4abbe3502ae95bf5e9f61a194318110e0485577511895766e54b3063b9962a7241078dfe1e4d6566a1febb6c008e11ca150
|
7
|
+
data.tar.gz: fdcb73dfccbc76118e21c66896b1d9518f0c1af1935f6903a73235c0da2413bd2db1f352bc17612e8696ad2bdcb096fd257053116ce21b496f8d07f124478897
|
data/ML_Ruby.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.email = ["barek2k2@gmail.com"]
|
10
10
|
|
11
11
|
spec.summary = "Ruby gem uses Machine Learning(ML) techniques to make predictions and classifications, and it's powered by Python3 under the hood."
|
12
|
-
spec.description = "This Ruby gem leverages Machine Learning(ML) techniques to make predictions(forecasts) and classifications in various applications. It provides capabilities such as predicting next month's billing, forecasting upcoming sales orders, determining user approval status, classifying text, generating similarity scores, and making recommendations. It uses Python3 under the hood, powered by popular machine learning techniques including NLP(Natural Language Processing), Decision Tree, K-Nearest Neighbors and Linear Regression algorithms."
|
12
|
+
spec.description = "This Ruby gem leverages Machine Learning(ML) techniques to make predictions(forecasts) and classifications in various applications. It provides capabilities such as predicting next month's billing, forecasting upcoming sales orders, identifying patient's potential findings(like Diabetes), determining user approval status, classifying text, generating similarity scores, and making recommendations. It uses Python3 under the hood, powered by popular machine learning techniques including NLP(Natural Language Processing), Decision Tree, K-Nearest Neighbors and Logistic Regression, Random Forest and Linear Regression algorithms."
|
13
13
|
spec.homepage = "https://github.com/barek2k2/ML_Ruby"
|
14
14
|
spec.required_ruby_version = ">= 2.6.0"
|
15
15
|
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# MLRuby
|
2
2
|
|
3
|
-
This Ruby gem leverages Machine Learning(ML) techniques to make predictions(forecasts) and classifications in various applications. It provides capabilities such as predicting next month's billing,
|
3
|
+
This Ruby gem leverages Machine Learning(ML) techniques to make predictions(forecasts) and classifications in various applications. It provides capabilities such as predicting next month's billing, forecasting upcoming sales orders, identifying patient's potential findings(like Diabetes), determining user approval status, classifying text, generating similarity scores, and making recommendations. It uses Python3 under the hood, powered by popular machine learning techniques including NLP(Natural Language Processing), Decision Tree, K-Nearest Neighbors and Logistic Regression, Random Forest and Linear Regression algorithms.
|
4
4
|
|
5
5
|
|
6
6
|
# Pre-requisite
|
@@ -42,6 +42,24 @@ bundle install
|
|
42
42
|
puts prediction
|
43
43
|
```
|
44
44
|
|
45
|
+
- ### Logistic Regression Algorithm - Diabetes detection Example in Health Industry
|
46
|
+
|
47
|
+
Imagine you possess some patients data encompassing vital attributes such as Blood Pressure, Glucose Level, and Age, meticulously arranged as input features, accompanied by corresponding predictions for diabetes as target variables. Now you can effortlessly predict the likelihood of diabetes for any new patient.
|
48
|
+
```
|
49
|
+
ml = MLRuby::LogisticRegression::Model.new(
|
50
|
+
[
|
51
|
+
[120, 80, 32],
|
52
|
+
[140, 90, 28],
|
53
|
+
[160, 75, 35],
|
54
|
+
[135, 88, 30],
|
55
|
+
[145, 92, 38]
|
56
|
+
],
|
57
|
+
[1, 0, 1, 0, 1]
|
58
|
+
)
|
59
|
+
predictions = ml.predict([[130, 85, 30], [80, 80, 90]])
|
60
|
+
puts predictions
|
61
|
+
```
|
62
|
+
|
45
63
|
- ### Random Forest Regression Algorithm - Real Estate House Pricing Example
|
46
64
|
|
47
65
|
Consider yourself in the dynamic field of the Real Estate market, you have some apartments/houses data(number of bed rooms, price, approval_status) represented as input features and their corresponding prices.
|
data/lib/ML_Ruby/version.rb
CHANGED
data/lib/ML_Ruby.rb
CHANGED
@@ -19,6 +19,20 @@ module MLRuby
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
module LogisticRegression
|
23
|
+
class Model
|
24
|
+
def initialize(x, y)
|
25
|
+
@x = x
|
26
|
+
@y = y
|
27
|
+
end
|
28
|
+
def predict(nexts)
|
29
|
+
script_path = "#{Gem.loaded_specs['ML_Ruby'].gem_dir}/lib/python/logistic_regression.py"
|
30
|
+
result = `#{MLRuby::PYTHON_PATH} #{script_path} "#{@x}, #{@y}, #{nexts}"`
|
31
|
+
result.gsub("\n","").gsub("[","").gsub("]","").split(" ").map(&:to_i)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
22
36
|
module RandomForestRegression
|
23
37
|
class Model
|
24
38
|
def initialize(x, y)
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import numpy as np
|
2
|
+
from sklearn.linear_model import LogisticRegression
|
3
|
+
from sklearn.metrics import classification_report, confusion_matrix
|
4
|
+
import sys
|
5
|
+
import ast
|
6
|
+
|
7
|
+
class LogisticRegressionModel:
|
8
|
+
def __init__(self, data):
|
9
|
+
self.data = data
|
10
|
+
|
11
|
+
def process_data(self):
|
12
|
+
self.X = self.data[0]
|
13
|
+
self.y = self.data[1]
|
14
|
+
|
15
|
+
def train(self):
|
16
|
+
self.model = LogisticRegression()
|
17
|
+
self.model.fit(self.X, self.y)
|
18
|
+
|
19
|
+
def predict(self, new_predictions):
|
20
|
+
return self.model.predict(new_predictions)
|
21
|
+
|
22
|
+
data = ast.literal_eval(sys.argv[1])
|
23
|
+
logistic_regression_model = LogisticRegressionModel(data)
|
24
|
+
logistic_regression_model.process_data()
|
25
|
+
logistic_regression_model.train()
|
26
|
+
predictions = data[2]
|
27
|
+
print(logistic_regression_model.predict(predictions))
|
metadata
CHANGED
@@ -1,21 +1,22 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ML_Ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Abdul Barek
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-09-
|
11
|
+
date: 2023-09-23 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: This Ruby gem leverages Machine Learning(ML) techniques to make predictions(forecasts)
|
14
14
|
and classifications in various applications. It provides capabilities such as predicting
|
15
|
-
next month's billing, forecasting upcoming sales orders,
|
16
|
-
status, classifying text, generating
|
17
|
-
It uses Python3 under the hood, powered
|
18
|
-
NLP(Natural Language Processing),
|
15
|
+
next month's billing, forecasting upcoming sales orders, identifying patient's potential
|
16
|
+
findings(like Diabetes), determining user approval status, classifying text, generating
|
17
|
+
similarity scores, and making recommendations. It uses Python3 under the hood, powered
|
18
|
+
by popular machine learning techniques including NLP(Natural Language Processing),
|
19
|
+
Decision Tree, K-Nearest Neighbors and Logistic Regression, Random Forest and Linear
|
19
20
|
Regression algorithms.
|
20
21
|
email:
|
21
22
|
- barek2k2@gmail.com
|
@@ -32,6 +33,7 @@ files:
|
|
32
33
|
- lib/python/decision_tree_classifier.py
|
33
34
|
- lib/python/k_nearest_neighbors.py
|
34
35
|
- lib/python/linear_regression.py
|
36
|
+
- lib/python/logistic_regression.py
|
35
37
|
- lib/python/natural_language_processing/support_vector_machine.py
|
36
38
|
- lib/python/natural_language_processing/text_classifier.py
|
37
39
|
- lib/python/random_forest.py
|