refactor file structure
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
# typed: true
|
||||
class CreateTrainedRegressionModels < ActiveRecord::Migration[7.2]
|
||||
def change
|
||||
mirai_tablespace!
|
||||
|
||||
create_table :trained_regression_models do |t|
|
||||
# Model identification and metadata
|
||||
t.string :name, null: false
|
||||
t.text :description
|
||||
t.string :model_type, null: false # linear, quadratic, logarithmic, square_root
|
||||
|
||||
# Data source information
|
||||
t.integer :total_records_count, null: false
|
||||
t.integer :training_records_count, null: false
|
||||
t.integer :evaluation_records_count, null: false
|
||||
t.float :train_test_split_ratio, null: false, default: 0.8
|
||||
t.integer :random_seed, null: false, default: 42
|
||||
t.integer :max_points_limit # null means no limit
|
||||
|
||||
# Normalizer parameters for reconstruction
|
||||
t.float :x_min, null: false
|
||||
t.float :x_max, null: false
|
||||
t.float :y_min, null: false
|
||||
t.float :y_max, null: false
|
||||
|
||||
# Trained coefficients (stored as JSON array)
|
||||
t.jsonb :coefficients, null: false, default: []
|
||||
|
||||
# Performance metrics
|
||||
t.float :training_r_squared, null: false
|
||||
t.float :evaluation_r_squared, null: false
|
||||
|
||||
# Model equation in human-readable format
|
||||
t.text :equation_string, null: false
|
||||
|
||||
# Additional metadata
|
||||
t.jsonb :metadata, default: {} # for any additional info
|
||||
|
||||
t.timestamps
|
||||
|
||||
# Indexes for efficient querying
|
||||
t.index :name
|
||||
t.index :model_type
|
||||
t.index :created_at
|
||||
t.index :training_r_squared
|
||||
t.index :evaluation_r_squared
|
||||
end
|
||||
end
|
||||
end
|
||||
103
db/structure.sql
103
db/structure.sql
@@ -3683,6 +3683,58 @@ CREATE TABLE public.schema_migrations (
|
||||
);
|
||||
|
||||
|
||||
SET default_tablespace = mirai;
|
||||
|
||||
--
|
||||
-- Name: trained_regression_models; Type: TABLE; Schema: public; Owner: -; Tablespace: mirai
|
||||
--
|
||||
|
||||
CREATE TABLE public.trained_regression_models (
|
||||
id bigint NOT NULL,
|
||||
name character varying NOT NULL,
|
||||
description text,
|
||||
model_type character varying NOT NULL,
|
||||
total_records_count integer NOT NULL,
|
||||
training_records_count integer NOT NULL,
|
||||
evaluation_records_count integer NOT NULL,
|
||||
train_test_split_ratio double precision DEFAULT 0.8 NOT NULL,
|
||||
random_seed integer DEFAULT 42 NOT NULL,
|
||||
max_points_limit integer,
|
||||
x_min double precision NOT NULL,
|
||||
x_max double precision NOT NULL,
|
||||
y_min double precision NOT NULL,
|
||||
y_max double precision NOT NULL,
|
||||
coefficients jsonb DEFAULT '[]'::jsonb NOT NULL,
|
||||
training_r_squared double precision NOT NULL,
|
||||
evaluation_r_squared double precision NOT NULL,
|
||||
equation_string text NOT NULL,
|
||||
metadata jsonb DEFAULT '{}'::jsonb,
|
||||
created_at timestamp(6) without time zone NOT NULL,
|
||||
updated_at timestamp(6) without time zone NOT NULL
|
||||
);
|
||||
|
||||
|
||||
--
|
||||
-- Name: trained_regression_models_id_seq; Type: SEQUENCE; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE SEQUENCE public.trained_regression_models_id_seq
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
|
||||
--
|
||||
-- Name: trained_regression_models_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER SEQUENCE public.trained_regression_models_id_seq OWNED BY public.trained_regression_models.id;
|
||||
|
||||
|
||||
SET default_tablespace = '';
|
||||
|
||||
--
|
||||
-- Name: users; Type: TABLE; Schema: public; Owner: -
|
||||
--
|
||||
@@ -4879,6 +4931,13 @@ ALTER TABLE ONLY public.pghero_query_stats ALTER COLUMN id SET DEFAULT nextval('
|
||||
ALTER TABLE ONLY public.pghero_space_stats ALTER COLUMN id SET DEFAULT nextval('public.pghero_space_stats_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: trained_regression_models id; Type: DEFAULT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public.trained_regression_models ALTER COLUMN id SET DEFAULT nextval('public.trained_regression_models_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: users id; Type: DEFAULT; Schema: public; Owner: -
|
||||
--
|
||||
@@ -5772,6 +5831,14 @@ ALTER TABLE ONLY public.schema_migrations
|
||||
ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version);
|
||||
|
||||
|
||||
--
|
||||
-- Name: trained_regression_models trained_regression_models_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: mirai
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public.trained_regression_models
|
||||
ADD CONSTRAINT trained_regression_models_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
SET default_tablespace = '';
|
||||
|
||||
--
|
||||
@@ -7802,6 +7869,41 @@ CREATE INDEX index_pghero_query_stats_on_database_and_captured_at ON public.pghe
|
||||
CREATE INDEX index_pghero_space_stats_on_database_and_captured_at ON public.pghero_space_stats USING btree (database, captured_at);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_trained_regression_models_on_created_at; Type: INDEX; Schema: public; Owner: -; Tablespace: mirai
|
||||
--
|
||||
|
||||
CREATE INDEX index_trained_regression_models_on_created_at ON public.trained_regression_models USING btree (created_at);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_trained_regression_models_on_evaluation_r_squared; Type: INDEX; Schema: public; Owner: -; Tablespace: mirai
|
||||
--
|
||||
|
||||
CREATE INDEX index_trained_regression_models_on_evaluation_r_squared ON public.trained_regression_models USING btree (evaluation_r_squared);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_trained_regression_models_on_model_type; Type: INDEX; Schema: public; Owner: -; Tablespace: mirai
|
||||
--
|
||||
|
||||
CREATE INDEX index_trained_regression_models_on_model_type ON public.trained_regression_models USING btree (model_type);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_trained_regression_models_on_name; Type: INDEX; Schema: public; Owner: -; Tablespace: mirai
|
||||
--
|
||||
|
||||
CREATE INDEX index_trained_regression_models_on_name ON public.trained_regression_models USING btree (name);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_trained_regression_models_on_training_r_squared; Type: INDEX; Schema: public; Owner: -; Tablespace: mirai
|
||||
--
|
||||
|
||||
CREATE INDEX index_trained_regression_models_on_training_r_squared ON public.trained_regression_models USING btree (training_r_squared);
|
||||
|
||||
|
||||
SET default_tablespace = '';
|
||||
|
||||
--
|
||||
@@ -9138,6 +9240,7 @@ ALTER TABLE ONLY public.domain_twitter_tweets
|
||||
SET search_path TO "$user", public;
|
||||
|
||||
INSERT INTO "schema_migrations" (version) VALUES
|
||||
('20250710204708'),
|
||||
('20250709235107'),
|
||||
('20250628000003'),
|
||||
('20250628000002'),
|
||||
|
||||
Reference in New Issue
Block a user