def test_fdboxplot_univariate(self): data_matrix = [[1, 1, 2, 3, 2.5, 2], [0.5, 0.5, 1, 2, 1.5, 1], [-1, -1, -0.5, 1, 1, 0.5], [-0.5, -0.5, -0.5, -1, -1, -1]] grid_points = [0, 2, 4, 6, 8, 10] fd = FDataGrid(data_matrix, grid_points) fdataBoxplot = Boxplot(fd, depth_method=IntegratedDepth()) np.testing.assert_array_equal(fdataBoxplot.median.ravel(), np.array([-1., -1., -0.5, 1., 1., 0.5])) np.testing.assert_array_equal( fdataBoxplot.central_envelope[0].ravel(), np.array([-1., -1., -0.5, -1., -1., -1.])) np.testing.assert_array_equal( fdataBoxplot.central_envelope[1].ravel(), np.array([-0.5, -0.5, -0.5, 1., 1., 0.5])) np.testing.assert_array_equal( fdataBoxplot.non_outlying_envelope[0].ravel(), np.array([-1., -1., -0.5, -1., -1., -1.])) np.testing.assert_array_equal( fdataBoxplot.non_outlying_envelope[1].ravel(), np.array([-0.5, -0.5, -0.5, 1., 1., 0.5])) self.assertEqual(len(fdataBoxplot.envelopes), 1) np.testing.assert_array_equal(fdataBoxplot.envelopes[0], fdataBoxplot.central_envelope) np.testing.assert_array_equal(fdataBoxplot.outliers, np.array([True, True, False, False]))
# somewhat limited) set of tools for three-dimensional data visualization as # we can observe. # # For this reason, the profiles of the surfaces, which are contained in the # first two generated functional data objects, are plotted below, to help to # visualize the data. fd.plot() ############################################################################## # To terminate the example, the instantiation of the # :class:`~skfda.exploratory.visualization.SurfaceBoxplot` object is # made, showing the surface boxplot which corresponds to our FDataGrid surfaceBoxplot = SurfaceBoxplot(fd_2) surfaceBoxplot.plot() ############################################################################## # The surface boxplot contains the median, the central envelope and the # outlying envelope plotted from darker to lighter colors, although they can # be customized. # # Analogous to the procedure followed before of plotting the three-dimensional # data and their correponding profiles, we can obtain also the functional # boxplot for one-dimensional data with the # :class:`~skfda.exploratory.visualization.Boxplot` passing as arguments the # first FdataGrid object. The profile of the surface boxplot is obtained. boxplot1 = Boxplot(fd) boxplot1.plot()
fd_temperatures.plot(sample_labels=dataset["target"], label_colors=label_colors, label_names=label_names) ############################################################################## # We instantiate a :class:`~skfda.exploratory.visualization.Boxplot` # object with the data, and we call its # :func:`~skfda.exploratory.visualization.Boxplot.plot` function to show the # graph. # # By default, only the part of the outlier curves which falls out of the # central regions is plotted. We want the entire curve to be shown, that is # why the ``show_full_outliers`` parameter is set to True. fdBoxplot = Boxplot(fd_temperatures) fdBoxplot.show_full_outliers = True fdBoxplot.plot() ############################################################################## # We can observe in the boxplot the median in black, the central region (where # the 50% of the most centered samples reside) in pink and the envelopes and # vertical lines in blue. The outliers detected, those samples with at least a # point outside the outlying envelope, are represented with a red dashed line. # The colors can be customized. # # The outliers are shown below with respect to the other samples. color = 0.3 outliercol = 0.7
fd_temperatures.plot(group=y.values.codes, group_colors=label_colors, group_names=label_names) ############################################################################## # We instantiate a :class:`~skfda.exploratory.visualization.Boxplot` # object with the data, and we call its # :func:`~skfda.exploratory.visualization.Boxplot.plot` function to show the # graph. # # By default, only the part of the outlier curves which falls out of the # central regions is plotted. We want the entire curve to be shown, that is # why the ``show_full_outliers`` parameter is set to True. fdBoxplot = Boxplot(fd_temperatures) fdBoxplot.show_full_outliers = True fdBoxplot.plot() ############################################################################## # We can observe in the boxplot the median in black, the central region (where # the 50% of the most centered samples reside) in pink and the envelopes and # vertical lines in blue. The outliers detected, those samples with at least a # point outside the outlying envelope, are represented with a red dashed line. # The colors can be customized. # # The outliers are shown below with respect to the other samples. color = 0.3 outliercol = 0.7