Ejemplo n.º 1
0
    def test_KernelSmoothedFromBatchClassificationResult(self):
        """Kernel Smoothed Probability density graph from a single split"""

        testfilename = 'test_graph_kernel_smoothed.npy'
        graph = PredictedValuesGraph(self.batch_result)
        graph.KernelSmoothedDensityGraph()
        self.CompareGraphs(graph, testfilename)
Ejemplo n.º 2
0
    def test_ErrMsgIfMatplotibNotInstalled(self):
        """Fail gracefully with informative message if matplotlib"""

        graph = PredictedValuesGraph(self.batch_result)
        with self.assertRaises(ImportError):
            graph.RankOrderedPredictedValuesGraph()
        with self.assertRaises(ImportError):
            graph.KernelSmoothedDensityGraph()
Ejemplo n.º 3
0
rank_ordered_graphs = []
ks_density_graphs = []

norm_full_set = full_set.Normalize()
# arg _all=True performs rank order sort without reducing number of features
sorted_full_set_pearson_weights = PearsonFeatureWeights.NewFromFeatureSpace( norm_full_set ).Threshold( _all=True ) 

for bin_index in range( num_bins ):
    name = "{0}\nFeatures ranked {1}-{2}".format( full_set.source_path,
                                         bin_offset + 1, bin_offset + num_features_per_bin )
    print name

    sliced_pearson_weights = sorted_full_set_pearson_weights.Slice( bin_offset, bin_offset + num_features_per_bin )
    sliced_fs = full_set.FeatureReduce( sliced_pearson_weights )
    experiment = FeatureSpaceRegressionExperiment.NewShuffleSplit( sliced_fs )

    grapher = PredictedValuesGraph( experiment )
    grapher.RankOrderedPredictedValuesGraph( name )
    grapher.SaveToFile( "rank_ordered_features_{0:03d}-{1:03d}".format( bin_offset + 1, bin_offset + num_features_per_bin  ) )

    grapher.KernelSmoothedDensityGraph( name )
    grapher.SaveToFile( "ks_density_features_{0:03d}-{1:03d}".format( bin_offset + 1, bin_offset + num_features_per_bin ) )

    bin_offset += num_features_per_bin 


import subprocess
subprocess.call( [ "convert", "rank_ordered_features*", "rank_ordered.pdf"] )
subprocess.call( [ "convert", "ks_density_features*", "ks_density.pdf"] )