Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Data Normalization with PDL

by lin0 (Curate)
on Jul 07, 2007 at 16:22 UTC ( [id://625425]=note: print w/replies, xml ) Need Help??


in reply to Data Normalization with PDL

One typical practice is to use the code above to normalize the training data and to use the resulting mean and standard deviation to normalize the testing data as illustrated in the snippet below:

#!/usr/bin/perl use warnings; use strict; use PDL; use PDL::NiceSlice; # ================================ # normalize_testing_patterns # $output_data = # $normalized_testing_patterns( $input_data, # $mean_of_input, # $stdev_of_input) ) # # processess $input_data so that $output_data # has 0 mean and 1 stdev # # $output_data = ( $input_data - $mean_of_input ) / $stdev_of_input # ================================ sub normalize_testing_patterns { my ( $input_data, $mean, $stdev ) = @_; my ( $number_of_dimensions, $number_of_patterns ) = $input_data->dims(); my $output_data = ( $input_data - $mean->dummy(1, $number_of_patterns) ) / $stdev->dummy(1, $number_of_patterns); return $output_data; }

Cheers,

lin0

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://625425]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2024-03-19 08:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found