--1. 테이블 스크립터
CREATE TABLE TEST_RUNNING3
(
YEAR_ NUMBER(10,0),
ADDRESS VARCHAR2(50 BYTE),
PROPERTY_ NUMBER(38,0),
R_TOTAL NUMBER(38,0),
S_NAME VARCHAR2(30 BYTE),
S_1_TOTAL NUMBER(20,0)
);
insert into test_running3 values(2017,'강남구 은평동',5700,50000,'은평초',180);
insert into test_running3 values(2018,'강남구 은평동',5700,70000,'은평초',210);
insert into test_running3 values(2019,'강남구 은평동',5700,65000,'은평초',198);
insert into test_running3 values(2020,'강남구 은평동',5700,90000,'은평초',220);
insert into test_running3 values(2021,'강남구 은평동',5700,120000,'은평초',240);
insert into test_running3 values(2022,'강남구 은평동',5700,105000,'은평초',220);
insert into test_running3 values(2023,'강남구 은평동',5700,150000,'은평초',258);
insert into test_running3 values(2017,'강남구 은평동',5700,50000,'이충초',130);
insert into test_running3 values(2018,'강남구 은평동',5700,70000,'이충초',180);
insert into test_running3 values(2019,'강남구 은평동',5700,65000,'이충초',168);
insert into test_running3 values(2020,'강남구 은평동',5700,90000,'이충초',190);
insert into test_running3 values(2021,'강남구 은평동',5700,120000,'이충초',210);
insert into test_running3 values(2022,'강남구 은평동',5700,105000,'이충초',200);
insert into test_running3 values(2023,'강남구 은평동',5700,120000,'이충초',238);
insert into test_running3 values(2017,'강남구 은평동',5700,50000,'반지초',110);
insert into test_running3 values(2018,'강남구 은평동',5700,70000,'반지초',180);
insert into test_running3 values(2019,'강남구 은평동',5700,65000,'반지초',158);
insert into test_running3 values(2020,'강남구 은평동',5700,90000,'반지초',200);
insert into test_running3 values(2021,'강남구 은평동',5700,120000,'반지초',230);
insert into test_running3 values(2022,'강남구 은평동',5700,105000,'반지초',210);
insert into test_running3 values(2023,'강남구 은평동',5700,150000,'반지초',258);
insert into test_running3 values(2017,'강남구 은평동',5700,50000,'지산초',330);
insert into test_running3 values(2018,'강남구 은평동',5700,70000,'지산초',340);
insert into test_running3 values(2019,'강남구 은평동',5700,65000,'지산초',320);
insert into test_running3 values(2020,'강남구 은평동',5700,90000,'지산초',350);
insert into test_running3 values(2021,'강남구 은평동',5700,120000,'지산초',360);
insert into test_running3 values(2022,'강남구 은평동',5700,105000,'지산초',348);
insert into test_running3 values(2023,'강남구 은평동',5700,150000,'지산초',370);
--2. 위의 테이블에 rownum 부여
create table test_runrun
as
select rownum c_id,t.*
from( select * from test_running3) t;
drop table test_running3;
rename test_runrun to test_running3;
--3.훈련테이블 / 테스트 테이블 구분
create table ttrain_run
as
select *
from test_running3
where c_id <=24;
create table ttest_run
as
select *
from test_running3
where c_id >24;
--모델환경구성
DROP TABLE SETTINGS_GLM;
CREATE TABLE SETTINGS_GLM
AS
SELECT *
FROM TABLE (DBMS_DATA_MINING.GET_DEFAULT_SETTINGS)
WHERE SETTING_NAME LIKE '%GLM%';
BEGIN
INSERT INTO SETTINGS_GLM
VALUES (DBMS_DATA_MINING.ALGO_NAME, 'ALGO_RANDOM_FOREST');
INSERT INTO SETTINGS_GLM
VALUES (DBMS_DATA_MINING.PREP_AUTO, 'ON');
COMMIT;
END;
/
-- 모델 생성부터 오류가 발생합니다
BEGIN
DBMS_DATA_MINING.DROP_MODEL( 'MD_REGESSION_MODEL');
END;
/
BEGIN
DBMS_DATA_MINING.CREATE_MODEL(
model_name => 'MD_REGRESSION_MODEL',
mining_function => DBMS_DATA_MINING.REGRESSION,
data_table_name => 'ttrain_run',
case_id_column_name => 'c_id',
target_column_name => 's_1_total',
settings_table_name => 'SETTINGS_GLM');
END;
/
SELECT MODEL_NAME,
ALGORITHM,
MINING_FUNCTION
FROM ALL_MINING_MODELS
WHERE MODEL_NAME = 'MD_REG_MODEL2';
SELECT SETTING_NAME, SETTING_VALUE
FROM ALL_MINING_MODEL_SETTINGS
WHERE MODEL_NAME = 'MD_REG_MODEL2';
-- 결과확인
select s_name, s_1_total 실제값, prediction (md_reg_model2 using *) 예측값
from ttest_run;
첫댓글 회귀 알고리즘
서포트 벡터 머신 (SVM): ALGO_SUPPORT_VECTOR_MACHINES
선형 회귀 (Linear Regression): ALGO_LINEAR_REGRESSION
일반화 선형 모델 (GLM): ALGO_GLM
https://docs.oracle.com/cd/B19306_01/appdev.102/b14258/d_datmin.htm#BAJDHGDF