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

📄 unit2.pas

📁 基于libsvm
💻 PAS
字号:
unit Unit2;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TParamSet = class(TForm)
    Label1: TLabel;
    GroupBox1: TGroupBox;
    c_svc: TRadioButton;
    nu_svc: TRadioButton;
    one_class: TRadioButton;
    e_svr: TRadioButton;
    nu_svr: TRadioButton;
    GroupBox2: TGroupBox;
    Label2: TLabel;
    linear: TRadioButton;
    Polynomial: TRadioButton;
    Rbf: TRadioButton;
    Sigmoid: TRadioButton;
    degree: TLabel;
    degree_text: TEdit;
    gamma: TLabel;
    gamma_text: TEdit;
    Label3: TLabel;
    C_text: TEdit;
    Nu: TLabel;
    Nu_text: TEdit;
    Label4: TLabel;
    eps_text: TEdit;
    Label5: TLabel;
    Cachesize_text: TEdit;
    Button1: TButton;
    Label6: TLabel;
    subset_no_text: TEdit;
    GroupBox3: TGroupBox;
    one_against_one: TRadioButton;
    one_against_all: TRadioButton;
    Label7: TLabel;
    Label8: TLabel;
    nr_fold_text: TEdit;
    Label9: TLabel;
    p_text: TEdit;
    Edit1: TEdit;
    Label10: TLabel;
    Edit2: TEdit;
    Label11: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure c_svcClick(Sender: TObject);
    procedure nu_svcClick(Sender: TObject);
    procedure one_classClick(Sender: TObject);
    procedure e_svrClick(Sender: TObject);
    procedure nu_svrClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;


var
  ParamSet: TParamSet;

implementation

uses main;

{$R *.dfm}
     // c_svc","nu_svc","one_class","epsilon_svr","nu_svr"
procedure TParamSet.Button1Click(Sender: TObject);
var svm_type : integer;
    kernel_type : integer;
    classification_type : integer;
    nr_fold : integer;
    workingsetsize : integer;
    subset_no : integer;

    degree, C, gamma, coef0, nu, p, cache_size, eps : real;
begin
      if c_svc.Checked then
     svm_type := 0
   else if nu_svc.Checked then
     svm_type := 1
   else if one_class.Checked then
     svm_type := 2
   else if e_svr.Checked then
     svm_type := 3
   else if nu_svr.Checked then
     svm_type := 4;

   if linear.Checked then
     kernel_type := 0
   else if Polynomial.Checked then
     kernel_type := 1
   else if Rbf.Checked then
     kernel_type := 2
   else if Sigmoid.Checked then
     kernel_type := 3;

     if one_against_one.Checked then
        classification_type := 0
     else if one_against_all.Checked then
        classification_type := 1;

     degree := StrToFloat(degree_text.Text);
     gamma := 1/(2*StrToFloat(gamma_text.Text)*StrToFloat(gamma_text.Text));
     C := StrToFloat(C_text.Text);
     Nu := StrToFloat(Nu_text.Text);
     eps := StrToFloat(eps_text.Text);
     Cache_size := StrToFloat(Cachesize_text.Text);
     subset_no := StrToInt(subset_no_text.Text);
     nr_fold := StrToInt(nr_fold_text.Text);
     p := StrToFloat(p_text.Text);
     workingsetsize := StrToInt(Edit1.Text);
     coef0 := StrToFloat(Edit2.Text);

     param.set_param(degree, C, gamma, coef0, Nu, p, Cache_size, eps, kernel_type, svm_type, classification_type,nr_fold,
     workingsetsize,subset_no);

     ParamSet.Visible := false;
end;

procedure TParamSet.c_svcClick(Sender: TObject);
begin
   if c_svc.Checked then
   begin
      GroupBox3.Enabled := true;
      one_against_one.Enabled := true;
      one_against_all.Enabled := true;
   end
end;

procedure TParamSet.nu_svcClick(Sender: TObject);
begin
   if nu_svc.Checked then
   begin
      GroupBox3.Enabled := true;
      one_against_one.Enabled := true;
      one_against_all.Enabled := true;

   end
end;

procedure TParamSet.one_classClick(Sender: TObject);
begin
   if one_class.Checked then
   begin
      GroupBox3.Enabled := false;
      one_against_one.Enabled := false;
      one_against_all.Enabled := false;
   end
end;

procedure TParamSet.e_svrClick(Sender: TObject);
begin
   if e_svr.Checked then
   begin
      GroupBox3.Enabled := false;
      one_against_one.Enabled := false;
      one_against_all.Enabled := false;
   end
end;

procedure TParamSet.nu_svrClick(Sender: TObject);
begin
   if nu_svr.Checked then
   begin
      GroupBox3.Enabled := false;
      one_against_one.Enabled := false;
      one_against_all.Enabled := false;
   end
end;

end.

⌨️ 快捷键说明

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