treefit.data.generate_2d_n_arms_star_data

treefit.data.generate_2d_n_arms_star_data(n_samples, n_arms, fatness)[source]

Generate a 2-dimensional star tree data that contain n_samples data points and fit a star tree with n_arms arms.

Parameters
  • n_samples (int) – The number of samples to be generated.

  • n_arms (int) – The number of arms to be generated.

  • fatness (float) – How fat from the based star tree. [0.0, 1.0] is available value range.

Returns

star – A generated numpy.array. The rows and columns correspond to samples and features.

Return type

numpy.array

Examples

>>> import treefit
>>> from matplotlib.pyplot as plt
# Generate a 2-dimensional star tree data that contain 500 data points
# and fit a star tree with 3 arms. The generated data are a bit noisy but
# tree-like.
>>> star_tree_like = treefit.data.generate_2d_n_arms_star_data(500, 3, 0.1)
>>> plt.figure()
>>> plt.scatter(star_tree_like[:, 0], star_tree_like[:, 1])
# Generate a 2-dimensional star tree data that contain 600 data points
# and fit a star tree with 5 arms. The generated data are very noisy and
# less tree-like.
>>> star_less_tree_like = treefit.data.generate_2d_n_arms_star_data(600, 5, 0.9)
>>> plt.figure()
>>> plt.scatter(star_less_tree_like[:, 0],     ...             star_less_tree_like[:, 1])