function [U,w,MU] = trainptonsample(M,X) alf = M.ALF; X = lensort(X); U = {}; MU = {}; w = []; w(1) = b2y(run_dfsa(M,'')); U{1} = ''; MU{1} = shuf2dfsa('',alf); PROGstart(length(X),'training'); for i=1:length(X) x = X{i}; %fprintf('main loop: x = [%s] \n',x); [U,w,MU,b] = add_feature(U,w,MU,M,x); PROGupdate(i); end PROGend; return function [U,w,MU,b] = add_feature(U,w,MU,M,x) xi = embedX(x,MU); yh = sign(xi*w); yt = b2y(run_dfsa(M,x)); b = (yh == yt); if ~b % signs disagree N = length(U)+1; U{N,1} = x; %fprintf('processing x = %s \n',x); %MU{N,1} = bool2fsa_pt(['(' x ')'],M.ALF); MU{N,1} = shuf2dfsa(x,M.ALF); w(N,1) = yt * (1+abs(xi*w)); %%w(N,1) = yt * (1+sum(abs(w))); %w(N,1) = yt * 1.01 * abs(xi*w); end return