Server IP : 103.119.228.120 / Your IP : 3.15.6.140 Web Server : Apache System : Linux v8.techscape8.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64 User : nobody ( 99) PHP Version : 5.6.40 Disable Function : shell_exec,symlink,system,exec,proc_get_status,proc_nice,proc_terminate,define_syslog_variables,syslog,openlog,closelog,escapeshellcmd,passthru,ocinum cols,ini_alter,leak,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dl,dll,myshellexec,proc_open,socket_bind,proc_close,escapeshellarg,parse_ini_filepopen,fpassthru,exec,passthru,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,popen,show_source,proc_nice,proc_terminate,proc_get_status,proc_close,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,dl,symlink,shell_exec,system,dl,passthru,escapeshellarg,escapeshellcmd,myshellexec,c99_buff_prepare,c99_sess_put,fpassthru,getdisfunc,fx29exec,fx29exec2,is_windows,disp_freespace,fx29sh_getupdate,fx29_buff_prepare,fx29_sess_put,fx29shexit,fx29fsearch,fx29ftpbrutecheck,fx29sh_tools,fx29sh_about,milw0rm,imagez,sh_name,myshellexec,checkproxyhost,dosyayicek,c99_buff_prepare,c99_sess_put,c99getsource,c99sh_getupdate,c99fsearch,c99shexit,view_perms,posix_getpwuid,posix_getgrgid,posix_kill,parse_perms,parsesort,view_perms_color,set_encoder_input,ls_setcheckboxall,ls_reverse_all,rsg_read,rsg_glob,selfURL,dispsecinfo,unix2DosTime,addFile,system,get_users,view_size,DirFiles,DirFilesWide,DirPrintHTMLHeaders,GetFilesTotal,GetTitles,GetTimeTotal,GetMatchesCount,GetFileMatchesCount,GetResultFiles,fs_copy_dir,fs_copy_obj,fs_move_dir,fs_move_obj,fs_rmdir,SearchText,getmicrotime MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/local/ssl/local/ssl/local/share/man/man1/ |
Upload File : |
.\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "SA-LEARN 1" .TH SA-LEARN 1 "2016-08-24" "perl v5.16.3" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" sa\-learn \- train SpamAssassin's Bayesian classifier .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBsa-learn\fR [options] [file]... .PP \&\fBsa-learn\fR [options] \-\-dump [ all | data | magic ] .PP Options: .PP .Vb 10 \& \-\-ham Learn messages as ham (non\-spam) \& \-\-spam Learn messages as spam \& \-\-forget Forget a message \& \-\-use\-ignores Use bayes_ignore_from and bayes_ignore_to \& \-\-sync Synchronize the database and the journal if needed \& \-\-force\-expire Force a database sync and expiry run \& \-\-dbpath <path> Allows commandline override (in bayes_path form) \& for where to read the Bayes DB from \& \-\-dump [all|data|magic] Display the contents of the Bayes database \& Takes optional argument for what to display \& \-\-regexp <re> For dump only, specifies which tokens to \& dump based on a regular expression. \& \-f file, \-\-folders=file Read list of files/directories from file \& \-\-dir Ignored; historical compatibility \& \-\-file Ignored; historical compatibility \& \-\-mbox Input sources are in mbox format \& \-\-mbx Input sources are in mbx format \& \-\-max\-size <b> Skip messages larger than b bytes; \& defaults to 256 KB, 0 implies no limit \& \-\-showdots Show progress using dots \& \-\-progress Show progress using progress bar \& \-\-no\-sync Skip synchronizing the database and journal \& after learning \& \-L, \-\-local Operate locally, no network accesses \& \-\-import Migrate data from older version/non DB_File \& based databases \& \-\-clear Wipe out existing database \& \-\-backup Backup, to STDOUT, existing database \& \-\-restore <filename> Restore a database from filename \& \-u username, \-\-username=username \& Override username taken from the runtime \& environment, used with SQL \& \-C path, \-\-configpath=path, \-\-config\-file=path \& Path to standard configuration dir \& \-p prefs, \-\-prefspath=file, \-\-prefs\-file=file \& Set user preferences file \& \-\-siteconfigpath=path Path for site configs \& (default: /etc/mail/spamassassin) \& \-\-cf=\*(Aqconfig line\*(Aq Additional line of configuration \& \-D, \-\-debug [area=n,...] Print debugging messages \& \-V, \-\-version Print version \& \-h, \-\-help Print usage message .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Given a typical selection of your incoming mail classified as spam or ham (non-spam), this tool will feed each mail to SpamAssassin, allowing it to 'learn' what signs are likely to mean spam, and which are likely to mean ham. .PP Simply run this command once for each of your mail folders, and it will \&''learn'' from the mail therein. .PP Note that csh-style \fIglobbing\fR in the mail folder names is supported; in other words, listing a folder name as \f(CW\*(C`*\*(C'\fR will scan every folder that matches. See \f(CW\*(C`Mail::SpamAssassin::ArchiveIterator\*(C'\fR for more details. .PP SpamAssassin remembers which mail messages it has learnt already, and will not re-learn those messages again, unless you use the \fB\-\-forget\fR option. Messages learnt as spam will have SpamAssassin markup removed, on the fly. .PP If you make a mistake and scan a mail as ham when it is spam, or vice versa, simply rerun this command with the correct classification, and the mistake will be corrected. SpamAssassin will automatically 'forget' the previous indications. .PP Users of \f(CW\*(C`spamd\*(C'\fR who wish to perform training remotely, over a network, should investigate the \f(CW\*(C`spamc \-L\*(C'\fR switch. .SH "OPTIONS" .IX Header "OPTIONS" .IP "\fB\-\-ham\fR" 4 .IX Item "--ham" Learn the input message(s) as ham. If you have previously learnt any of the messages as spam, SpamAssassin will forget them first, then re-learn them as ham. Alternatively, if you have previously learnt them as ham, it'll skip them this time around. If the messages have already been filtered through SpamAssassin, the learner will ignore any modifications SpamAssassin may have made. .IP "\fB\-\-spam\fR" 4 .IX Item "--spam" Learn the input message(s) as spam. If you have previously learnt any of the messages as ham, SpamAssassin will forget them first, then re-learn them as spam. Alternatively, if you have previously learnt them as spam, it'll skip them this time around. If the messages have already been filtered through SpamAssassin, the learner will ignore any modifications SpamAssassin may have made. .IP "\fB\-\-folders\fR=\fIfilename\fR, \fB\-f\fR \fIfilename\fR" 4 .IX Item "--folders=filename, -f filename" sa-learn will read in the list of folders from the specified file, one folder per line in the file. If the folder is prefixed with \f(CW\*(C`ham:type:\*(C'\fR or \f(CW\*(C`spam:type:\*(C'\fR, sa-learn will learn that folder appropriately, otherwise the folders will be assumed to be of the type specified by \fB\-\-ham\fR or \fB\-\-spam\fR. .Sp \&\f(CW\*(C`type\*(C'\fR above is optional, but is the same as the standard for ArchiveIterator: mbox, mbx, dir, file, or detect (the default if not specified). .IP "\fB\-\-mbox\fR" 4 .IX Item "--mbox" sa-learn will read in the file(s) containing the emails to be learned, and will process them in mbox format (one or more emails per file). .IP "\fB\-\-mbx\fR" 4 .IX Item "--mbx" sa-learn will read in the file(s) containing the emails to be learned, and will process them in mbx format (one or more emails per file). .IP "\fB\-\-use\-ignores\fR" 4 .IX Item "--use-ignores" Don't learn the message if a from address matches configuration file item \f(CW\*(C`bayes_ignore_from\*(C'\fR or a to address matches \f(CW\*(C`bayes_ignore_to\*(C'\fR. The option might be used when learning from a large file of messages from which the hammy spam messages or spammy ham messages have not been removed. .IP "\fB\-\-sync\fR" 4 .IX Item "--sync" Synchronize the journal and databases. Upon successfully syncing the database with the entries in the journal, the journal file is removed. .IP "\fB\-\-force\-expire\fR" 4 .IX Item "--force-expire" Forces an expiry attempt, regardless of whether it may be necessary or not. Note: This doesn't mean any tokens will actually expire. Please see the \s-1EXPIRATION\s0 section below. .Sp Note: \f(CW\*(C`\-\-force\-expire\*(C'\fR also causes the journal data to be synchronized into the Bayes databases. .IP "\fB\-\-forget\fR" 4 .IX Item "--forget" Forget a given message previously learnt. .IP "\fB\-\-dbpath\fR" 4 .IX Item "--dbpath" Allows a commandline override of the \fIbayes_path\fR configuration option. .IP "\fB\-\-dump\fR \fIoption\fR" 4 .IX Item "--dump option" Display the contents of the Bayes database. Without an option or with the \fIall\fR option, all magic tokens and data tokens will be displayed. \&\fImagic\fR will only display magic tokens, and \fIdata\fR will only display the data tokens. .Sp Can also use the \fB\-\-regexp\fR \fI\s-1RE\s0\fR option to specify which tokens to display based on a regular expression. .IP "\fB\-\-clear\fR" 4 .IX Item "--clear" Clear an existing Bayes database by removing all traces of the database. .Sp \&\s-1WARNING:\s0 This is destructive and should be used with care. .IP "\fB\-\-backup\fR" 4 .IX Item "--backup" Performs a dump of the Bayes database in machine/human readable format. .Sp The dump will include token and seen data. It is suitable for input back into the \-\-restore command. .IP "\fB\-\-restore\fR=\fIfilename\fR" 4 .IX Item "--restore=filename" Performs a restore of the Bayes database defined by \fIfilename\fR. .Sp \&\s-1WARNING:\s0 This is a destructive operation, previous Bayes data will be wiped out. .IP "\fB\-h\fR, \fB\-\-help\fR" 4 .IX Item "-h, --help" Print help message and exit. .IP "\fB\-u\fR \fIusername\fR, \fB\-\-username\fR=\fIusername\fR" 4 .IX Item "-u username, --username=username" If specified this username will override the username taken from the runtime environment. You can use this option to specify users in a virtual user configuration when using \s-1SQL\s0 as the Bayes backend. .Sp \&\s-1NOTE:\s0 This option will not change to the given \fIusername\fR, it will only attempt to act on behalf of that user. Because of this you will need to have proper permissions to be able to change files owned by \fIusername\fR. In the case of \s-1SQL\s0 this generally is not a problem. .IP "\fB\-C\fR \fIpath\fR, \fB\-\-configpath\fR=\fIpath\fR, \fB\-\-config\-file\fR=\fIpath\fR" 4 .IX Item "-C path, --configpath=path, --config-file=path" Use the specified path for locating the distributed configuration files. Ignore the default directories (usually \f(CW\*(C`/usr/share/spamassassin\*(C'\fR or similar). .IP "\fB\-\-siteconfigpath\fR=\fIpath\fR" 4 .IX Item "--siteconfigpath=path" Use the specified path for locating site-specific configuration files. Ignore the default directories (usually \f(CW\*(C`/etc/mail/spamassassin\*(C'\fR or similar). .IP "\fB\-\-cf='config line'\fR" 4 .IX Item "--cf='config line'" Add additional lines of configuration directly from the command-line, parsed after the configuration files are read. Multiple \fB\-\-cf\fR arguments can be used, and each will be considered a separate line of configuration. .IP "\fB\-p\fR \fIprefs\fR, \fB\-\-prefspath\fR=\fIprefs\fR, \fB\-\-prefs\-file\fR=\fIprefs\fR" 4 .IX Item "-p prefs, --prefspath=prefs, --prefs-file=prefs" Read user score preferences from \fIprefs\fR (usually \f(CW\*(C`$HOME/.spamassassin/user_prefs\*(C'\fR). .IP "\fB\-\-progress\fR" 4 .IX Item "--progress" Prints a progress bar (to \s-1STDERR\s0) showing the current progress. In the case where no valid terminal is found this option will behave very much like the \&\-\-showdots option. .IP "\fB\-D\fR [\fIarea,...\fR], \fB\-\-debug\fR [\fIarea,...\fR]" 4 .IX Item "-D [area,...], --debug [area,...]" Produce debugging output. If no areas are listed, all debugging information is printed. Diagnostic output can also be enabled for each area individually; \&\fIarea\fR is the area of the code to instrument. For example, to produce diagnostic output on bayes, learn, and dns, use: .Sp .Vb 1 \& spamassassin \-D bayes,learn,dns .Ve .Sp For more information about which areas (also known as channels) are available, please see the documentation at: .Sp .Vb 1 \& C<http://wiki.apache.org/spamassassin/DebugChannels> .Ve .Sp Higher priority informational messages that are suitable for logging in normal circumstances are available with an area of \*(L"info\*(R". .IP "\fB\-\-no\-sync\fR" 4 .IX Item "--no-sync" Skip the slow synchronization step which normally takes place after changing database entries. If you plan to learn from many folders in a batch, or to learn many individual messages one-by-one, it is faster to use this switch and run \f(CW\*(C`sa\-learn \-\-sync\*(C'\fR once all the folders have been scanned. .Sp Clarification: The state of \fI\-\-no\-sync\fR overrides the \&\fIbayes_learn_to_journal\fR configuration option. If not specified, sa-learn will learn to the database directly. If specified, sa-learn will learn to the journal file. .Sp Note: \fI\-\-sync\fR and \fI\-\-no\-sync\fR can be specified on the same commandline, which is slightly confusing. In this case, the \fI\-\-no\-sync\fR option is ignored since there is no learn operation. .IP "\fB\-L\fR, \fB\-\-local\fR" 4 .IX Item "-L, --local" Do not perform any network accesses while learning details about the mail messages. This will speed up the learning process, but may result in a slightly lower accuracy. .Sp Note that this is currently ignored, as current versions of SpamAssassin will not perform network access while learning; but future versions may. .IP "\fB\-\-import\fR" 4 .IX Item "--import" If you previously used SpamAssassin's Bayesian learner without the \f(CW\*(C`DB_File\*(C'\fR module installed, it will have created files in other formats, such as \&\f(CW\*(C`GDBM_File\*(C'\fR, \f(CW\*(C`NDBM_File\*(C'\fR, or \f(CW\*(C`SDBM_File\*(C'\fR. This switch allows you to migrate that old data into the \f(CW\*(C`DB_File\*(C'\fR format. It will overwrite any data currently in the \f(CW\*(C`DB_File\*(C'\fR. .Sp Can also be used with the \fB\-\-dbpath\fR \fIpath\fR option to specify the location of the Bayes files to use. .SH "MIGRATION" .IX Header "MIGRATION" There are now multiple backend storage modules available for storing user's bayesian data. As such you might want to migrate from one backend to another. Here is a simple procedure for migrating from one backend to another. .PP Note that if you have individual user databases you will have to perform a similar procedure for each one of them. .IP "sa-learn \-\-sync" 4 .IX Item "sa-learn --sync" This will sync any outstanding journal entries .IP "sa-learn \-\-backup > backup.txt" 4 .IX Item "sa-learn --backup > backup.txt" This will save all your Bayes data to a plain text file. .IP "sa-learn \-\-clear" 4 .IX Item "sa-learn --clear" This is optional, but good to do to clear out the old database. .IP "Repeat!" 4 .IX Item "Repeat!" At this point, if you have multiple databases, you should perform the procedure above for each of them. (i.e. each user's database needs to be backed up before continuing.) .IP "Switch backends" 4 .IX Item "Switch backends" Once you have backed up all databases you can update your configuration for the new database backend. This will involve at least the bayes_store_module config option and may involve some additional config options depending on what is required by the module. (For example, you may need to configure an \s-1SQL\s0 database.) .IP "sa-learn \-\-restore backup.txt" 4 .IX Item "sa-learn --restore backup.txt" Again, you need to do this for every database. .PP If you are migrating to \s-1SQL\s0 you can make use of the \-u <username> option in sa-learn to populate each user's database. Otherwise, you must run sa-learn as the user who database you are restoring. .SH "INTRODUCTION TO BAYESIAN FILTERING" .IX Header "INTRODUCTION TO BAYESIAN FILTERING" (Thanks to Michael Bell for this section!) .PP For a more lengthy description of how this works, go to http://www.paulgraham.com/ and see \*(L"A Plan for Spam\*(R". It's reasonably readable, even if statistics make me break out in hives. .PP The short semi-inaccurate version: Given training, a spam heuristics engine can take the most \*(L"spammy\*(R" and \*(L"hammy\*(R" words and apply probabilistic analysis. Furthermore, once given a basis for the analysis, the engine can continue to learn iteratively by applying both the non-Bayesian and Bayesian rulesets together to create evolving \*(L"intelligence\*(R". .PP SpamAssassin 2.50 and later supports Bayesian spam analysis, in the form of the \s-1BAYES\s0 rules. This is a new feature, quite powerful, and is disabled until enough messages have been learnt. .PP The pros of Bayesian spam analysis: .IP "Can greatly reduce false positives and false negatives." 4 .IX Item "Can greatly reduce false positives and false negatives." It learns from your mail, so it is tailored to your unique e\-mail flow. .IP "Once it starts learning, it can continue to learn from SpamAssassin and improve over time." 4 .IX Item "Once it starts learning, it can continue to learn from SpamAssassin and improve over time." .PP And the cons: .IP "A decent number of messages are required before results are useful for ham/spam determination." 4 .IX Item "A decent number of messages are required before results are useful for ham/spam determination." .PD 0 .IP "It's hard to explain why a message is or isn't marked as spam." 4 .IX Item "It's hard to explain why a message is or isn't marked as spam." .PD i.e.: a straightforward rule, that matches, say, \*(L"\s-1VIAGRA\*(R"\s0 is easy to understand. If it generates a false positive or false negative, it is fairly easy to understand why. .Sp With Bayesian analysis, it's all probabilities \- \*(L"because the past says it is likely as this falls into a probabilistic distribution common to past spam in your systems\*(R". Tell that to your users! Tell that to the client when he asks \*(L"what can I do to change this\*(R". (By the way, the answer in this case is \*(L"use whitelisting\*(R".) .IP "It will take disk space and memory." 4 .IX Item "It will take disk space and memory." The databases it maintains take quite a lot of resources to store and use. .SH "GETTING STARTED" .IX Header "GETTING STARTED" Still interested? Ok, here's the guidelines for getting this working. .PP First a high-level overview: .IP "Build a significant sample of both ham and spam." 4 .IX Item "Build a significant sample of both ham and spam." I suggest several thousand of each, placed in \s-1SPAM\s0 and \s-1HAM\s0 directories or mailboxes. Yes, you \s-1MUST\s0 hand-sort this \- otherwise the results won't be much better than SpamAssassin on its own. Verify the spamminess/haminess of \s-1EVERY\s0 message. You're urged to avoid using a publicly available corpus (sample) \- this must be taken from \s-1YOUR\s0 mail server, if it is to be statistically useful. Otherwise, the results may be pretty skewed. .IP "Use this tool to teach SpamAssassin about these samples, like so:" 4 .IX Item "Use this tool to teach SpamAssassin about these samples, like so:" .Vb 3 \& sa\-learn \-\-spam /path/to/spam/folder \& sa\-learn \-\-ham /path/to/ham/folder \& ... .Ve .Sp Let SpamAssassin proceed, learning stuff. When it finds ham and spam it will add the \*(L"interesting tokens\*(R" to the database. .IP "If you need SpamAssassin to forget about specific messages, use the \fB\-\-forget\fR option." 4 .IX Item "If you need SpamAssassin to forget about specific messages, use the --forget option." This can be applied to either ham or spam that has run through the \&\fBsa-learn\fR processes. It's a bit of a hammer, really, lowering the weighting of the specific tokens in that message (only if that message has been processed before). .IP "Learning from single messages uses a command like this:" 4 .IX Item "Learning from single messages uses a command like this:" .Vb 1 \& sa\-learn \-\-ham \-\-no\-sync mailmessage .Ve .Sp This is handy for binding to a key in your mail user agent. It's very fast, as all the time-consuming stuff is deferred until you run with the \f(CW\*(C`\-\-sync\*(C'\fR option. .IP "Autolearning is enabled by default" 4 .IX Item "Autolearning is enabled by default" If you don't have a corpus of mail saved to learn, you can let SpamAssassin automatically learn the mail that you receive. If you are autolearning from scratch, the amount of mail you receive will determine how long until the BAYES_* rules are activated. .SH "EFFECTIVE TRAINING" .IX Header "EFFECTIVE TRAINING" Learning filters require training to be effective. If you don't train them, they won't work. In addition, you need to train them with new messages regularly to keep them up-to-date, or their data will become stale and impact accuracy. .PP You need to train with both spam \fIand\fR ham mails. One type of mail alone will not have any effect. .PP Note that if your mail folders contain things like forwarded spam, discussions of spam-catching rules, etc., this will cause trouble. You should avoid scanning those messages if possible. (An easy way to do this is to move them aside, into a folder which is not scanned.) .PP If the messages you are learning from have already been filtered through SpamAssassin, the learner will compensate for this. In effect, it learns what each message would look like if you had run \f(CW\*(C`spamassassin \-d\*(C'\fR over it in advance. .PP Another thing to be aware of, is that typically you should aim to train with at least 1000 messages of spam, and 1000 ham messages, if possible. More is better, but anything over about 5000 messages does not improve accuracy significantly in our tests. .PP Be careful that you train from the same source \*(-- for example, if you train on old spam, but new ham mail, then the classifier will think that a mail with an old date stamp is likely to be spam. .PP It's also worth noting that training with a very small quantity of ham, will produce atrocious results. You should aim to train with at least the same amount (or more if possible!) of ham data than spam. .PP On an on-going basis, it is best to keep training the filter to make sure it has fresh data to work from. There are various ways to do this: .IP "1. Supervised learning" 4 .IX Item "1. Supervised learning" This means keeping a copy of all or most of your mail, separated into spam and ham piles, and periodically re-training using those. It produces the best results, but requires more work from you, the user. .Sp (An easy way to do this, by the way, is to create a new folder for \&'deleted' messages, and instead of deleting them from other folders, simply move them in there instead. Then keep all spam in a separate folder and never delete it. As long as you remember to move misclassified mails into the correct folder set, it is easy enough to keep up to date.) .IP "2. Unsupervised learning from Bayesian classification" 4 .IX Item "2. Unsupervised learning from Bayesian classification" Another way to train is to chain the results of the Bayesian classifier back into the training, so it reinforces its own decisions. This is only safe if you then retrain it based on any errors you discover. .Sp SpamAssassin does not support this method, due to experimental results which strongly indicate that it does not work well, and since Bayes is only one part of the resulting score presented to the user (while Bayes may have made the wrong decision about a mail, it may have been overridden by another system). .IP "3. Unsupervised learning from SpamAssassin rules" 4 .IX Item "3. Unsupervised learning from SpamAssassin rules" Also called 'auto\-learning' in SpamAssassin. Based on statistical analysis of the SpamAssassin success rates, we can automatically train the Bayesian database with a certain degree of confidence that our training data is accurate. .Sp It should be supplemented with some supervised training in addition, if possible. .Sp This is the default, but can be turned off by setting the SpamAssassin configuration parameter \f(CW\*(C`bayes_auto_learn\*(C'\fR to 0. .IP "4. Mistake-based training" 4 .IX Item "4. Mistake-based training" This means training on a small number of mails, then only training on messages that SpamAssassin classifies incorrectly. This works, but it takes longer to get it right than a full training session would. .SH "FILES" .IX Header "FILES" \&\fBsa-learn\fR and the other parts of SpamAssassin's Bayesian learner, use a set of persistent database files to store the learnt tokens, as follows. .IP "bayes_toks" 4 .IX Item "bayes_toks" The database of tokens, containing the tokens learnt, their count of occurrences in ham and spam, and the timestamp when the token was last seen in a message. .Sp This database also contains some 'magic' tokens, as follows: the version number of the database, the number of ham and spam messages learnt, the number of tokens in the database, and timestamps of: the last journal sync, the last expiry run, the last expiry token reduction count, the last expiry timestamp delta, the oldest token timestamp in the database, and the newest token timestamp in the database. .Sp This is a database file, using \f(CW\*(C`DB_File\*(C'\fR. The database 'version number' is 0 for databases from 2.5x, 1 for databases from certain 2.6x development releases, 2 for 2.6x, and 3 for 3.0 and later releases. .IP "bayes_seen" 4 .IX Item "bayes_seen" A map of Message-Id and some data from headers and body to what that message was learnt as. This is used so that SpamAssassin can avoid re-learning a message it has already seen, and so it can reverse the training if you later decide that message was learnt incorrectly. .Sp This is a database file, using \f(CW\*(C`DB_File\*(C'\fR. .IP "bayes_journal" 4 .IX Item "bayes_journal" While SpamAssassin is scanning mails, it needs to track which tokens it uses in its calculations. To avoid the contention of having each SpamAssassin process attempting to gain write access to the Bayes \s-1DB,\s0 the token timestamps are written to a 'journal' file which will later (either automatically or via \f(CW\*(C`sa\-learn \-\-sync\*(C'\fR) be used to synchronize the Bayes \s-1DB.\s0 .Sp Also, through the use of \f(CW\*(C`bayes_learn_to_journal\*(C'\fR, or when using the \&\f(CW\*(C`\-\-no\-sync\*(C'\fR option with sa-learn, the actual learning data will take be placed into the journal for later synchronization. This is typically useful for high-traffic sites to avoid the same contention as stated above. .SH "EXPIRATION" .IX Header "EXPIRATION" Since SpamAssassin can auto-learn messages, the Bayes database files could increase perpetually until they fill your disk. To control this, SpamAssassin performs journal synchronization and bayes expiration periodically when certain criteria (listed below) are met. .PP SpamAssassin can sync the journal and expire the \s-1DB\s0 tokens either manually or opportunistically. A journal sync is due if \fI\-\-sync\fR is passed to sa-learn (manual), or if the following is true (opportunistic): .IP "\- bayes_journal_max_size does not equal 0 (means don't sync)" 4 .IX Item "- bayes_journal_max_size does not equal 0 (means don't sync)" .PD 0 .IP "\- the journal file exists" 4 .IX Item "- the journal file exists" .PD .PP and either: .IP "\- the journal file has a size greater than bayes_journal_max_size" 4 .IX Item "- the journal file has a size greater than bayes_journal_max_size" .PP or .IP "\- a journal sync has previously occurred, and at least 1 day has passed since that sync" 4 .IX Item "- a journal sync has previously occurred, and at least 1 day has passed since that sync" .PP Expiry is due if \fI\-\-force\-expire\fR is passed to sa-learn (manual), or if all of the following are true (opportunistic): .IP "\- the last expire was attempted at least 12hrs ago" 4 .IX Item "- the last expire was attempted at least 12hrs ago" .PD 0 .IP "\- bayes_auto_expire does not equal 0" 4 .IX Item "- bayes_auto_expire does not equal 0" .IP "\- the number of tokens in the \s-1DB\s0 is > 100,000" 4 .IX Item "- the number of tokens in the DB is > 100,000" .IP "\- the number of tokens in the \s-1DB\s0 is > bayes_expiry_max_db_size" 4 .IX Item "- the number of tokens in the DB is > bayes_expiry_max_db_size" .IP "\- there is at least a 12 hr difference between the oldest and newest token atimes" 4 .IX Item "- there is at least a 12 hr difference between the oldest and newest token atimes" .PD .SS "\s-1EXPIRE LOGIC\s0" .IX Subsection "EXPIRE LOGIC" If either the manual or opportunistic method causes an expire run to start, here is the logic that is used: .IP "\- figure out how many tokens to keep. take the larger of either bayes_expiry_max_db_size * 75% or 100,000 tokens. therefore, the goal reduction is number of tokens \- number of tokens to keep." 4 .IX Item "- figure out how many tokens to keep. take the larger of either bayes_expiry_max_db_size * 75% or 100,000 tokens. therefore, the goal reduction is number of tokens - number of tokens to keep." .PD 0 .IP "\- if the reduction number is < 1000 tokens, abort (not worth the effort)." 4 .IX Item "- if the reduction number is < 1000 tokens, abort (not worth the effort)." .IP "\- if an expire has been done before, guesstimate the new atime delta based on the old atime delta. (new_atime_delta = old_atime_delta * old_reduction_count / goal)" 4 .IX Item "- if an expire has been done before, guesstimate the new atime delta based on the old atime delta. (new_atime_delta = old_atime_delta * old_reduction_count / goal)" .ie n .IP "\- if no expire has been done before, or the last expire looks ""weird"", do an estimation pass. The definition of ""weird"" is:" 4 .el .IP "\- if no expire has been done before, or the last expire looks ``weird'', do an estimation pass. The definition of ``weird'' is:" 4 .IX Item "- if no expire has been done before, or the last expire looks weird, do an estimation pass. The definition of weird is:" .RS 4 .IP "\- last expire over 30 days ago" 8 .IX Item "- last expire over 30 days ago" .IP "\- last atime delta was < 12 hrs" 8 .IX Item "- last atime delta was < 12 hrs" .IP "\- last reduction count was < 1000 tokens" 8 .IX Item "- last reduction count was < 1000 tokens" .IP "\- estimated new atime delta is < 12 hrs" 8 .IX Item "- estimated new atime delta is < 12 hrs" .IP "\- the difference between the last reduction count and the goal reduction count is > 50%" 8 .IX Item "- the difference between the last reduction count and the goal reduction count is > 50%" .RE .RS 4 .RE .PD .SS "\s-1ESTIMATION PASS LOGIC\s0" .IX Subsection "ESTIMATION PASS LOGIC" Go through each of the \s-1DB\s0's tokens. Starting at 12hrs, calculate whether or not the token would be expired (based on the difference between the token's atime and the db's newest token atime) and keep the count. Work out from 12hrs exponentially by powers of 2. ie: 12hrs * 1, 12hrs * 2, 12hrs * 4, 12hrs * 8, and so on, up to 12hrs * 512 (6144hrs, or 256 days). .PP The larger the delta, the smaller the number of tokens that will be expired. Conversely, the number of tokens goes up as the delta gets smaller. So starting at the largest atime delta, figure out which delta will expire the most tokens without going above the goal expiration count. Use this to choose the atime delta to use, unless one of the following occurs: .IP "\- the largest atime (smallest reduction count) would expire too many tokens. this means the learned tokens are mostly old and there needs to be new tokens learned before an expire can occur." 8 .IX Item "- the largest atime (smallest reduction count) would expire too many tokens. this means the learned tokens are mostly old and there needs to be new tokens learned before an expire can occur." .PD 0 .IP "\- all of the atime choices result in 0 tokens being removed. this means the tokens are all newer than 12 hours and there needs to be new tokens learned before an expire can occur." 8 .IX Item "- all of the atime choices result in 0 tokens being removed. this means the tokens are all newer than 12 hours and there needs to be new tokens learned before an expire can occur." .IP "\- the number of tokens that would be removed is < 1000. the benefit isn't worth the effort. more tokens need to be learned." 8 .IX Item "- the number of tokens that would be removed is < 1000. the benefit isn't worth the effort. more tokens need to be learned." .PD .PP If the expire run gets past this point, it will continue to the end. A new \s-1DB\s0 is created since the majority of \s-1DB\s0 libraries don't shrink the \&\s-1DB\s0 file when tokens are removed. So we do the \*(L"create new, migrate old to new, remove old, rename new\*(R" shuffle. .SS "\s-1EXPIRY RELATED CONFIGURATION SETTINGS\s0" .IX Subsection "EXPIRY RELATED CONFIGURATION SETTINGS" .ie n .IP """bayes_auto_expire"" is used to specify whether or not SpamAssassin ought to opportunistically attempt to expire the Bayes database. The default is 1 (yes)." 4 .el .IP "\f(CWbayes_auto_expire\fR is used to specify whether or not SpamAssassin ought to opportunistically attempt to expire the Bayes database. The default is 1 (yes)." 4 .IX Item "bayes_auto_expire is used to specify whether or not SpamAssassin ought to opportunistically attempt to expire the Bayes database. The default is 1 (yes)." .PD 0 .ie n .IP """bayes_expiry_max_db_size"" specifies both the auto-expire token count point, as well as the resulting number of tokens after expiry as described above. The default value is 150,000, which is roughly equivalent to a 6Mb database file if you're using DB_File." 4 .el .IP "\f(CWbayes_expiry_max_db_size\fR specifies both the auto-expire token count point, as well as the resulting number of tokens after expiry as described above. The default value is 150,000, which is roughly equivalent to a 6Mb database file if you're using DB_File." 4 .IX Item "bayes_expiry_max_db_size specifies both the auto-expire token count point, as well as the resulting number of tokens after expiry as described above. The default value is 150,000, which is roughly equivalent to a 6Mb database file if you're using DB_File." .ie n .IP """bayes_journal_max_size"" specifies how large the Bayes journal will grow before it is opportunistically synced. The default value is 102400." 4 .el .IP "\f(CWbayes_journal_max_size\fR specifies how large the Bayes journal will grow before it is opportunistically synced. The default value is 102400." 4 .IX Item "bayes_journal_max_size specifies how large the Bayes journal will grow before it is opportunistically synced. The default value is 102400." .PD .SH "INSTALLATION" .IX Header "INSTALLATION" The \fBsa-learn\fR command is part of the \fBMail::SpamAssassin\fR Perl module. Install this as a normal Perl module, using \f(CW\*(C`perl \-MCPAN \-e shell\*(C'\fR, or by hand. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIspamassassin\fR\|(1) \&\fIspamc\fR\|(1) \&\fIMail::SpamAssassin\fR\|(3) \&\fIMail::SpamAssassin::ArchiveIterator\fR\|(3) .PP <http://www.paulgraham.com/> Paul Graham's \*(L"A Plan For Spam\*(R" paper .PP <http://www.linuxjournal.com/article/6467> Gary Robinson's f(x) and combining algorithms, as used in SpamAssassin .PP <http://www.bgl.nu/~glouis/bogofilter/> \&'Training on error' page. A discussion of various Bayes training regimes, including 'train on error' and unsupervised training. .SH "PREREQUISITES" .IX Header "PREREQUISITES" \&\f(CW\*(C`Mail::SpamAssassin\*(C'\fR .SH "AUTHORS" .IX Header "AUTHORS" The SpamAssassin(tm) Project <http://spamassassin.apache.org/>