{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

131A_1_new_email_prob

131A_1_new_email_prob - Ps = for m=1:Number_words n=1 temp...

Info icon This preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % EE131A: Probabilities % % File: new_email_prob.m % % Author: Nikolaos Kontorinis % % Date: 12/01/04 % % Description: Perfoms a look-up of the spam probabilities of the words % in the new email. % % ATTENTION: % 1. The file train_filter.m should be run first and its % variables should not be altered. % 2. The new file must be specified externally as the string % new_file (e.g. new_file = 'new1_freq.txt'). % 3. The number of words in new_file must be specified % externally. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %clear Ps; % this is not necessary clear new_words; clear freq; fid_new= fopen(new_file,'r'); %new_file is a string %Read the words of the new_file and look-up their spam probs.
Image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Ps = ; for m=1:Number_words n=1; temp = fscanf(fid_new,'%1c',1); while(~isletter(temp)&&~isfinite(str2double(temp))) %Won't work temp = fscanf(fid_new,'%1c',1); %Without this end %--Ian Salman new_words(m,n)=temp; while(~isspace(temp)) new_words(m,n)=temp; temp = fscanf(fid_new,'%1c',1); n=n+1; end freq(m) = fscanf(fid_new,'%d \n',1); i = strmatch(new_words(m,:),words,'exact'); if isempty(i) %Check if the current word occurs in the training set Ps = [Ps; 0.4]; %If it is a new word, make it's spam prob almost % neutral ( slightly biased towards ham) else Ps = [Ps; prob(i)]; %. ..else use the existing prob. end end fclose('all');...
View Full Document

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern