easy_ml 0.2.0.pre.rc38 → 0.2.0.pre.rc39
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a53f346d534b4333dcc9f8880c9d0fd4d14acf7a596be57caf42ea789490e4e4
|
4
|
+
data.tar.gz: 912b118a2c82f2397afce24d39a5c556d98fc58a310647de7232851f7ee606b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d641839d982e782d5921cc7086ef583f3ae0f5901446d0c132deacb5a7101b420428cbbb52f58b0a4f9a94fb3ed6cd7f72cb1705eb2c7c3c4f938c4a7e9702d
|
7
|
+
data.tar.gz: b19d313ece15cb343138f4d6e036947ba764708b80695ef6d7b502c45e3e34662dec959d8e1c1f423109f89ac87101b3383d64b80da3d32cc7e9bee7b30c6f5c
|
@@ -3,12 +3,23 @@ module EasyML
|
|
3
3
|
skip_before_action :verify_authenticity_token, only: [:create]
|
4
4
|
|
5
5
|
def create
|
6
|
+
unless params.key?(:input)
|
7
|
+
return render json: { error: "Must provide key: input" }, status: :not_found
|
8
|
+
end
|
9
|
+
input = params[:input].permit!.to_h
|
10
|
+
|
11
|
+
unless input.is_a?(Hash)
|
12
|
+
return render json: { error: "Input must be a hash" }, status: :not_found
|
13
|
+
end
|
14
|
+
|
6
15
|
model_name = params[:model]
|
7
|
-
|
16
|
+
unless EasyML::Model.find_by(name: model_name).present?
|
17
|
+
return render json: { error: "Model not found" }, status: :not_found
|
18
|
+
end
|
8
19
|
|
9
|
-
|
20
|
+
prediction = EasyML::Predict.predict(model_name, input)
|
10
21
|
|
11
|
-
render json: { prediction:
|
22
|
+
render json: { prediction: EasyML::PredictionSerializer.new(prediction).serializable_hash.dig(:data, :attributes) }, status: :ok
|
12
23
|
rescue ActiveRecord::RecordNotFound
|
13
24
|
render json: { error: "Model not found" }, status: :not_found
|
14
25
|
rescue StandardError => e
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "jsonapi/serializer"
|
2
|
+
|
3
|
+
module EasyML
|
4
|
+
class PredictionSerializer
|
5
|
+
include JSONAPI::Serializer
|
6
|
+
|
7
|
+
attribute :prediction do |object|
|
8
|
+
object.prediction_value.symbolize_keys.dig(:value)
|
9
|
+
end
|
10
|
+
|
11
|
+
attributes :id,
|
12
|
+
:prediction_type,
|
13
|
+
:raw_input,
|
14
|
+
:normalized_input
|
15
|
+
end
|
16
|
+
end
|
data/config/routes.rb
CHANGED
data/lib/easy_ml/predict.rb
CHANGED
data/lib/easy_ml/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easy_ml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.0.pre.
|
4
|
+
version: 0.2.0.pre.rc39
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brett Shollenberger
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-01-
|
11
|
+
date: 2025-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -594,6 +594,7 @@ files:
|
|
594
594
|
- app/serializers/easy_ml/datasource_serializer.rb
|
595
595
|
- app/serializers/easy_ml/feature_serializer.rb
|
596
596
|
- app/serializers/easy_ml/model_serializer.rb
|
597
|
+
- app/serializers/easy_ml/prediction_serializer.rb
|
597
598
|
- app/serializers/easy_ml/retraining_job_serializer.rb
|
598
599
|
- app/serializers/easy_ml/retraining_run_serializer.rb
|
599
600
|
- app/serializers/easy_ml/settings_serializer.rb
|