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

📄 demo.pl

📁 SVM经典调试程序,内有说明,应用简便,可用做回归分类方面的计算
💻 PL
字号:
#!/usr/bin/perl########################################################################### This script demonstrates the syntax and usage of # ginisvm toolkit##########################################################################print "###################################################################\n";print "# GiniSVM toolkit data format is in a column format where each     \n";print "# entity is seperated by a newline character.                      \n";print "# Each file (training/test) has a header file which contains the   \n";print "# information of the data dimension, total number of classes and   \n";print "# total number of data points present in the file.                 \n";print "#                                                                  \n";print "# A sample header for a 2 feature dimension, 9 classes and 1000    \n";print "# data points look like this                                       \n";print "# 2                                                                \n";print "# 9                                                                \n";print "# 1000                                                             \n";print "#                                                                  \n";print "# The training data is then arranged as                            \n";print "# <label>                                                          \n";print "# <C weight>                                                       \n";print "# <features>                                                       \n";print "#                                                                  \n";print "# GiniSVM toolkit supports labels in two formats                   \n";print "# Case 1)  If your aim is just classification: You know the        \n";print "#          which class this feature belongs to. In this case the   \n";print "#          label is simply a single scalar number representing the \n";print "#          membership class                                        \n";print "#                                                                  \n";print "# Case 2) If you have the prior information of the probabilities   \n";print "#         of different classes for this data and want to do a      \n";print "#         probability regression then the label is a vector of     \n";print "#         prior probabilities. For eg for a 2 class problem a      \n";print "#         possible labels could be   0      0.9    0.2             \n";print "#                                    1      0.1    0.8             \n";print "#                                                                  \n";print "# <C weight> is a optional parameter which specifies the weight    \n";print "#            of the current data point. More noisy the point lesser\n";print "#            value it gets. This information is used when ginisvm  \n";print "#            is used in an EM training loop. If -cflag is present  \n";print "#            then ginitrain assumes that <C weight> is not present \n";print "#            This weight is multiplied by the global C specified   \n";print "#            at the input argument to obtain effective C for each  \n";print "#            data point                                            \n";print "#                                                                  \n";print "# <features> can be represented in a sparse or non-sparse format   \n";print "# Case 1)    Non-sparse format, the features are in a column format\n";print "#            with entries equal to the dimension value in the      \n";print "#            header.                                               \n";print "#                                                                  \n";print "# Case 2)    Sparse format, the first entry is the total number of \n";print "#            non-zero entries in this vector, and then index of    \n";print "#            non-zero entries with its value. For a feature with   \n";print "#            2 non zero entries for eg   2                         \n";print "#                                        10                        \n";print "#                                        0.32412                   \n";print "#                                        21                        \n";print "#                                        -0.1232                   \n";print "###################################################################\n";print "# TEST File Format                                                 \n";print "###################################################################\n";print "# Test file header is similar to training file but it may / maynot \n";print "# contain <C weight> or <labels> whose presence is indicated by    \n";print "# -cflag and -label training option. However the label format for  \n";print "# test file is fixed and is a scale value                          \n";print "###################################################################\n";print "# Demo run with sample data (Press any key to continue )           \n";print "###################################################################\n";$inpkey =<STDIN>;$TRAIN_MOD = "./ginitrain";$TEST_MOD = "./ginitest";print "###################################################################\n";print "# Training                                                         \n";print "###################################################################\n";print "# 9 class, 2 dimension, 1000 data points, non-sparse format, gaussian \n";print "# kernel with parameter 1.0, simple labels, no data C weight present, globa C = 1 \n";print "###################################################################\n";print "$TRAIN_MOD -k 1 -p1 1 -C 1 ../data/train_9c2d1000_nsp.dat ../data/train.cfg\n";print "# (Press any key to continue )                                     \n";print "###################################################################\n";$inpkey =<STDIN>;system("$TRAIN_MOD -k 1 -p1 1 -C 1 ../data/train_9c2d1000_nsp.dat ../data/train.cfg");print "###################################################################\n";print "# Testing with labels present                                      \n";print "###################################################################\n";print "$TEST_MOD -k 1 -label ../data/cv_9c2d1000_nsp.dat ../data/train.cfg ../data/train.out\n";print "# (Press any key to continue )                                     \n";print "###################################################################\n";$inpkey =<STDIN>;system("$TEST_MOD -k 1 -label ../data/cv_9c2d1000_nsp.dat ../data/train.cfg ../data/train.out");print "###################################################################\n";print "# Training                                                         \n";print "###################################################################\n";print "# 9 class, 2 dimension, 1000 data points, SPARSE format, gaussian \n";print "# kernel with parameter 1.0, simple labels, no data C weight present, globa C = 1 \n";print "###################################################################\n";print "$TRAIN_MOD -k 1 -p1 1 -C 1 -sp ../data/train_9c2d1000_sp.dat ../data/train.cfg\n";print "# (Press any key to continue )                                     \n";print "###################################################################\n";$inpkey =<STDIN>;system("$TRAIN_MOD -k 1 -p1 1 -C 1 -sp ../data/train_9c2d1000_sp.dat ../data/train.cfg");print "###################################################################\n";print "# Testing                                                         \n";print "###################################################################\n";print "$TEST_MOD -k 1 -sp -label ../data/cv_9c2d1000_sp.dat ../data/train.cfg ../data/train.out\n";print "# (Press any key to continue )                                     \n";print "###################################################################\n";$inpkey =<STDIN>;system("$TEST_MOD -k 1 -sp -label ../data/cv_9c2d1000_sp.dat ../data/train.cfg ../data/train.out");print "###################################################################\n";print "# Training                                                         \n";print "###################################################################\n";print "# 9 class, 2 dimension, 1000 data points, non-sparse format, gaussian \n";print "# kernel with parameter 1.0, VECTOR labels, no data C weight present, globa C = 1 \n";print "###################################################################\n";print "$TRAIN_MOD -k 1 -p1 1 -C 1 -pflag ../data/train_9c2d1000_nsp_pflag.dat ../data/train.cfg\n";print "# (Press any key to continue )                                     \n";print "###################################################################\n";$inpkey =<STDIN>;system("$TRAIN_MOD -k 1 -p1 1 -C 1 -pflag ../data/train_9c2d1000_nsp_pflag.dat ../data/train.cfg");print "###################################################################\n";print "# Testing                                                         \n";print "###################################################################\n";print "$TEST_MOD -k 1 -label ../data/cv_9c2d1000_nsp.dat ../data/train.cfg ../data/train.out\n";print "# (Press any key to continue )                                     \n";print "###################################################################\n";$inpkey =<STDIN>;system("$TEST_MOD -k 1 -label ../data/cv_9c2d1000_nsp.dat ../data/train.cfg ../data/train.out");print "###################################################################\n";print "# END DEMO !!                                                      \n";print "###################################################################\n";

⌨️ 快捷键说明

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