⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 reduction.m

📁 Variable Reduction Testbench通过对变量进行相关性分析来实现减少变量的目的。
💻 M
📖 第 1 页 / 共 3 页
字号:

    if strcmp(get(handles.Preprocessor_menu,'Checked'),'on')
        check_vars = 'y';
    else
        check_vars = 'n';
    end

    if strcmp(get(handles.Preprocessor2_menu,'Checked'),'on')
        check_missing = 'y';
    else
        check_missing = 'n';
    end

    if (strcmp(check_vars,'y') || strcmp(check_missing,'y'))
        [proc_ans, proc_data, proc_headers] = preprocess(handles.loaded_data, hd, ...
            check_vars,check_missing, -999);
        if ~isempty(proc_ans)
            handles.loaded_data = proc_data;
            handles.loaded_headers = proc_headers;
            hd = proc_headers;
            guidata(hObject, handles);
            wb = warning_box(proc_ans);
            waitfor(wb);
        end
    end

    correlation_matrix(handles.loaded_data,hd);
    
else
    warning_box('No data selected');
end




%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% GUI objects HANDLERS
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function ws_listbox_Callback(hObject, eventdata, handles)% Executes on selection change in ws_listbox.
% hObject    handle to ws_listbox (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% Hints: contents = get(hObject,'String') returns ws_listbox contents as cell array%        contents{get(hObject,'Value')} returns selected item from ws_listbox
box_strings = get(hObject,'String');
cur_string = box_strings{get(hObject,'Value')};
handles.cur_var = whos('-file',handles.cur_file,cur_string);

set(handles.var_name_text,'String',[handles.cur_var.name ':']);
set(handles.var_dim_text,'String',[num2str(handles.cur_var.size(1)) ' x ' num2str(handles.cur_var.size(2))]);
set(handles.var_size_text,'String',[num2str(handles.cur_var.bytes) ' bytes']);

% Update handles structure
guidata(hObject, handles);

% --------------------------------------------------------------------

function load_data_pushbutton_Callback(hObject, eventdata, handles)% Executes on button press in load_data_pushbutton.
% hObject    handle to load_data_pushbutton (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)if (isfield(handles,'cur_var'))
    set(handles.loaded_data_text,'String',[handles.cur_var.name ' (' ...
        num2str(handles.cur_var.size(1)) 'x' num2str(handles.cur_var.size(2)) ')']);

    tmp_data = load(handles.cur_file,handles.cur_var.name);
    tmp_data = struct2cell(tmp_data);
    handles.loaded_data = tmp_data{1,1};

    handles.data_present=1;

    % Update handles structure
    guidata(hObject, handles);
else
    warning_box('No data selected');
end


% --------------------------------------------------------------------

function load_headers_pushbutton_Callback(hObject, eventdata, handles)% Executes on button press in load_headers_pushbutton.
% hObject    handle to load_headers_pushbutton (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)if (isfield(handles,'cur_var'))
    set(handles.loaded_headers_text,'String',[handles.cur_var.name ' (' ...
        num2str(handles.cur_var.size(1)) 'x' num2str(handles.cur_var.size(2)) ')']);
    tmp_data = load(handles.cur_file,handles.cur_var.name);
    tmp_data = struct2cell(tmp_data);
    handles.loaded_headers = tmp_data{1,1};

    handles.headers_present=1;

    % Update handles structure
    guidata(hObject, handles);
else
    warning_box('No data selected');
end


% --------------------------------------------------------------------
function radio_method_1_Callback(hObject, eventdata, handles)% Executes on button press in radio_method_1.
% hObject    handle to radio_method_1 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% Hint: get(hObject,'Value') returns toggle state of radio_method_1
off = [handles.radio_method_2,handles.radio_method_3,handles.radio_method_4, ...
        handles.radio_method_5, handles.radio_method_6, handles.radio_method_7, ...
        handles.radio_method_8, handles.radio_method_9, handles.radio_method_10];
mutual_exclude(off);set(hObject,'Value',1);


% --------------------------------------------------------------------

function radio_method_2_Callback(hObject, eventdata, handles)% Executes on button press in radio_method_2.
% hObject    handle to radio_method_2 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% Hint: get(hObject,'Value') returns toggle state of radio_method_2
off = [handles.radio_method_1,handles.radio_method_3,handles.radio_method_4, ...
        handles.radio_method_5, handles.radio_method_6, handles.radio_method_7, ...
        handles.radio_method_8, handles.radio_method_9, handles.radio_method_10];
mutual_exclude(off);
set(hObject,'Value',1);

% --------------------------------------------------------------------

function radio_method_3_Callback(hObject, eventdata, handles)% Executes on button press in radio_method_3.
% hObject    handle to radio_method_3 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% Hint: get(hObject,'Value') returns toggle state of radio_method_3
off = [handles.radio_method_1,handles.radio_method_2,handles.radio_method_4, ...
        handles.radio_method_5, handles.radio_method_6, handles.radio_method_7, ...
        handles.radio_method_8, handles.radio_method_9, handles.radio_method_10];
mutual_exclude(off);
set(hObject,'Value',1);

% --------------------------------------------------------------------

function radio_method_4_Callback(hObject, eventdata, handles)% Executes on button press in radio_method_4.
% hObject    handle to radio_method_4 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% Hint: get(hObject,'Value') returns toggle state of radio_method_4
off = [handles.radio_method_1,handles.radio_method_2,handles.radio_method_3, ...
        handles.radio_method_5, handles.radio_method_6, handles.radio_method_7, ...
        handles.radio_method_8, handles.radio_method_9, handles.radio_method_10];
mutual_exclude(off);
set(hObject,'Value',1);


% --------------------------------------------------------------------


function radio_method_5_Callback(hObject, eventdata, handles)
% Executes on button press in radio_method_5.
% hObject    handle to radio_method_5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radio_method_5

off = [handles.radio_method_1,handles.radio_method_2,handles.radio_method_3, ...
        handles.radio_method_4, handles.radio_method_6, handles.radio_method_7, ...
        handles.radio_method_8, handles.radio_method_9, handles.radio_method_10];
mutual_exclude(off);
set(hObject,'Value',1);


% --------------------------------------------------------------------


function radio_method_6_Callback(hObject, eventdata, handles)
% --- Executes on button press in radio_method_6.
% hObject    handle to radio_method_6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radio_method_6

off = [handles.radio_method_1,handles.radio_method_2,handles.radio_method_3, ...
        handles.radio_method_4, handles.radio_method_5, handles.radio_method_7, ...
        handles.radio_method_8, handles.radio_method_9, handles.radio_method_10];
mutual_exclude(off);
set(hObject,'Value',1);


% --------------------------------------------------------------------


function radio_method_7_Callback(hObject, eventdata, handles)
% --- Executes on button press in radio_method_7.
% hObject    handle to radio_method_7 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radio_method_7

off = [handles.radio_method_1,handles.radio_method_2,handles.radio_method_3, ...
        handles.radio_method_4, handles.radio_method_5, handles.radio_method_6, ...
        handles.radio_method_8, handles.radio_method_9, handles.radio_method_10];
mutual_exclude(off);
set(hObject,'Value',1);


% --------------------------------------------------------------------


function radio_method_8_Callback(hObject, eventdata, handles)
% --- Executes on button press in radio_method_8.
% hObject    handle to radio_method_8 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radio_method_8

off = [handles.radio_method_1,handles.radio_method_2,handles.radio_method_3, ...
        handles.radio_method_4, handles.radio_method_5, handles.radio_method_6, ...
        handles.radio_method_7, handles.radio_method_9, handles.radio_method_10];
mutual_exclude(off);
set(hObject,'Value',1);


% --------------------------------------------------------------------


function radio_method_9_Callback(hObject, eventdata, handles)
% --- Executes on button press in radio_method_9.
% hObject    handle to radio_method_9 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radio_method_9

off = [handles.radio_method_1,handles.radio_method_2,handles.radio_method_3, ...
        handles.radio_method_4, handles.radio_method_5, handles.radio_method_6, ...
        handles.radio_method_7, handles.radio_method_8, handles.radio_method_10];
mutual_exclude(off);
set(hObject,'Value',1);


% --------------------------------------------------------------------


function radio_method_10_Callback(hObject, eventdata, handles)
% hObject    handle to radio_method_10 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radio_method_10

off = [handles.radio_method_1,handles.radio_method_2,handles.radio_method_3, ...
        handles.radio_method_4, handles.radio_method_5, handles.radio_method_6, ...
        handles.radio_method_7, handles.radio_method_8, handles.radio_method_9];
mutual_exclude(off);
set(hObject,'Value',1);


% --------------------------------------------------------------------


function start_button_Callback(hObject, eventdata, handles)% Executes on button press in start_button.
% hObject    handle to start_button (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)
% Checks if is it possible to proceed, otherwise warns the user

err_state = 0;

if (get(handles.save_txt_checkbox,'Value') == get(handles.save_txt_checkbox,'Max')) && ...
        (strcmp(handles.txt_file,' '))
    err_state = 1;
    err_msg = 'No file for txt output selected';
end

if (get(handles.save_mat_checkbox,'Value') == get(handles.save_mat_checkbox,'Max')) && ...
        (strcmp(handles.mat_file,' '))
    err_state = 1;
    err_msg = 'No file for mat output selected';
end

if (~handles.data_present)
    err_state = 1;
    err_msg = 'No data selected';
end


if (err_state)    warning_box(err_msg);
else
    
    if (handles.headers_present)
        hd = handles.loaded_headers;
    else
        hd = [];
    end

    if strcmp(get(handles.Preprocessor_menu,'Checked'),'on')
        check_vars = 'y';
    else
        check_vars = 'n';
    end

    if strcmp(get(handles.Preprocessor2_menu,'Checked'),'on')
        check_missing = 'y';
    else
        check_missing = 'n';
    end

    if (strcmp(check_vars,'y') || strcmp(check_missing,'y'))
        [proc_ans, proc_data, proc_headers] = preprocess(handles.loaded_data, hd, ...
            check_vars,check_missing, -999);
        if ~isempty(proc_ans)
            handles.loaded_data = proc_data;
            handles.loaded_headers = proc_headers;
            guidata(hObject, handles);
            wb = warning_box(proc_ans);
            waitfor(wb);
        end
    end

    if (get(handles.corrmat_checkbox,'Value') == get(handles.corrmat_checkbox,'Max'))
        data_corrmat = 1;
    else
        data_corrmat = 0;
    end
    
    m1 = get(handles.radio_method_1,'Value');
    m2 = get(handles.radio_method_2,'Value');
    m3 = get(handles.radio_method_3,'Value');
    m4 = get(handles.radio_method_4,'Value');
    m5 = get(handles.radio_method_5,'Value');
    m6 = get(handles.radio_method_6,'Value');
    m7 = get(handles.radio_method_7,'Value');
    m8 = get(handles.radio_method_8,'Value');
    m9 = get(handles.radio_method_9,'Value');
    m10 = get(handles.radio_method_10,'Value');

    set(handles.reduction_form,'Pointer','watch');

    if (m1==1)
        logging_checked = get(handles.logging_menu,'Checked');
        if strcmp(logging_checked,'on')
            [handles.result_ranking handles.result_values handles.result_cutoff] = method_KIF(handles.loaded_data,data_corrmat,'y');
        else
            [handles.result_ranking handles.result_values handles.result_cutoff] = method_KIF(handles.loaded_data,data_corrmat,'n');
        end
        handles.cur_expl = 'KIF Method (''value'' field stands for the KIF value) ';
    elseif (m2==1)
        [handles.result_ranking handles.result_values handles.result_cutoff] = method_B2(handles.loaded_data,data_corrmat,'i');        
        handles.cur_expl = 'B2 Method - iterative (''value'' field stands for the EV% value) ';
    elseif (m3==1)
        [handles.result_ranking handles.result_values handles.result_cutoff] = method_B2(handles.loaded_data,data_corrmat,'n'); 
        handles.cur_expl = 'B2 Method - non iterative (''value'' field stands for the EV% value) ';
    elseif (m4==1)
        [handles.result_ranking handles.result_values handles.result_cutoff] = method_B4(handles.loaded_data,data_corrmat);        
        handles.cur_expl = 'B4 Method (''value'' field stands for the EV% value) ';
    elseif (m5==1)
        [handles.result_ranking handles.result_values] = method_firsteig(handles.loaded_data,data_corrmat);        

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -