# random displacements.

random_state = np.random.RandomState(0)

sample_points = np.linspace(0, 1)
data = np.array([
    np.sin((sample_points + random_state.randn()) * 2 * np.pi)
    for _ in range(5)
])

###############################################################################
# The FDataGrid class is used for datasets containing discretized functions
# that are measured at the same points.

fd = FDataGrid(data,
               sample_points,
               dataset_label='Sinusoidal curves',
               axes_labels=['t', 'x(t)'])

fd = fd[:5]

###############################################################################
# We can plot the measured values of each function in a scatter plot.

fd.scatter(s=0.5)

###############################################################################
# We can also plot the interpolated functions.

fd.plot()
Ejemplo n.º 2
0
                            sample_points=fd.sample_points,
                            dataset_label=fd.dataset_label,
                            axes_labels=fd.axes_labels[0:2])
############################################################################################
# The data is plotted to show the curves we are working with. They are divided according to the
# target. In this case, it includes the different climates to which the weather stations belong to.

# Each climate is assigned a color. Defaults to grey.
colormap = plt.cm.get_cmap('seismic')
label_names = dataset["target_names"]
nlabels = len(label_names)
label_colors = colormap(np.arange(nlabels) / (nlabels - 1))

plt.figure()
fd_temperatures.plot(sample_labels=dataset["target"],
                     label_colors=label_colors,
                     label_names=label_names)

#############################################################################################
# The MS-Plot is generated. In order to show the results, the
# :func:`plot method <skfda.exploratory.visualization.magnitude_shape_plot.MagnitudeShapePlot.plot>` is used. Note that the
# colors have been specified before to distinguish between outliers or not. In particular the tones
# of the default colormap, (which is 'seismic' and can be customized), are assigned.

msplot = MagnitudeShapePlot(fdatagrid=fd_temperatures)

color = 0.3
outliercol = 0.7

plt.figure()
msplot.color = color
Ejemplo n.º 3
0
##############################################################################
# After, those values generated for one dimension on the domain are extruded
# along another dimension, obtaining a three-dimensional matrix or cube
# (two-dimensional domain and one-dimensional image).

cube = np.repeat(fd.data_matrix, n_features).reshape(
    (n_samples, n_features, n_features))

##############################################################################
# We can plot now the extruded trajectories.

fd_2 = FDataGrid(data_matrix=cube,
                 sample_points=np.tile(fd.sample_points, (2, 1)),
                 dataset_name="Extruded Brownian process")

fd_2.plot()

##############################################################################
# Since matplotlib was initially designed with only two-dimensional plotting
# in mind, the three-dimensional plotting utilities were built on top of
# matplotlib's two-dimensional display, and the result is a convenient (if
# 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()

##############################################################################
Ejemplo n.º 4
0
                            sample_points=fd.sample_points,
                            dataset_label=fd.dataset_label,
                            axes_labels=fd.axes_labels[0:2])
############################################################################################
# The data is plotted to show the curves we are working with. They are divided according to the
# target. In this case, it includes the different climates to which the weather stations belong to.

# Each climate is assigned a color. Defaults to grey.
colormap = plt.cm.get_cmap('seismic')
label_names = dataset["target_names"]
nlabels = len(label_names)
label_colors = colormap(numpy.arange(nlabels) / (nlabels - 1))

plt.figure()
fd_temperatures.plot(sample_labels=dataset["target"],
                     label_colors=label_colors,
                     label_names=label_names)

############################################################################################
# We instantiate a :func:`functional boxplot object <skfda.boxplot.Boxplot>` with the data,
# and we call its :func:`plot function <skfda.boxplot.Boxplot.plot>` 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

plt.figure()
fdBoxplot.plot()