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: cc708b35e777f41f67dbf4e769db3c326b01e1e65f29f293c9536d625a60a197
4
- data.tar.gz: c2ba6d165128c9cbeae2cef19ddc40e823208cc75750aa31d1e167fe8c623cd8
3
+ metadata.gz: a53f346d534b4333dcc9f8880c9d0fd4d14acf7a596be57caf42ea789490e4e4
4
+ data.tar.gz: 912b118a2c82f2397afce24d39a5c556d98fc58a310647de7232851f7ee606b4
5
5
  SHA512:
6
- metadata.gz: '07835e0557a01b1db47cbbddcd9149813b0cbbd7083eb951613fa31b32234b5c60a348bca5e3a57446ad21fad017882bf9262a4a2f81c4a6962f6bbd1771de0f'
7
- data.tar.gz: 427e065c5b4e83161c030738aa891ad855c6ca89e8b14d729e6602a0285682ac04712b62e5e226dc521bce05f292f783e0728a9c4a517e3aa8417a632b7b5e65
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
- input = params[:input]
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
- predictions = EasyML::Predict.predict(model_name, input)
20
+ prediction = EasyML::Predict.predict(model_name, input)
10
21
 
11
- render json: { prediction: predictions.first }
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
@@ -1,4 +1,5 @@
1
1
  require "zhong/web"
2
+ require "resque/server"
2
3
 
3
4
  EasyML::Engine.routes.draw do
4
5
  root to: "models#index"
@@ -29,8 +29,6 @@ module EasyML
29
29
  raw_input: raw_input,
30
30
  normalized_input: df.to_hashes&.first,
31
31
  )
32
-
33
- preds
34
32
  end
35
33
 
36
34
  def self.train(model_name, tuner: nil, evaluator: nil)
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EasyML
4
- VERSION = "0.2.0-rc38"
4
+ VERSION = "0.2.0-rc39"
5
5
 
6
6
  module Version
7
7
  end
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.rc38
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-22 00:00:00.000000000 Z
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