<jupyter_start><jupyter_text>Sklearn  sklearn.datasets документация: http://scikit-learn.org/stable/datasets/<jupyter_code>from sklearn import datasets
%pylab inline<jupyter_output>Populating the interactive namespace from numpy and matplotlib<jupyter_text>Генерация выборок **Способы генерации данных:** * make_classification* make_regression* make_circles* make_checkerboard* etc  datasets.make_circles<jupyter_code>circles = datasets.make_circles()
print("features: {}".format(circles[0][:10]))
print("target: {}".format(circles[1][:10]))
from matplotlib.colors import ListedColormap
colors = ListedColormap(['blue', 'green'])

pyplot.figure(figsize(8, 8))
pyplot.scatter(list(map(lambda x: x[0], circles[0])), list(map(lambda x: x[1], circles[0])), c = circles[1], cmap = colors)
def plot_2d_dataset(data, colors):
    pyplot.figure(figsize(8, 8))
    pyplot.scatter(list(map(lambda x: x[0], data[0])), list(map(lambda x: x[1], data[0])), c = data[1], cmap = colors)
noisy_circles = datasets.make_circles(noise = 0.15)
plot_2d_dataset(noisy_circles, colors)<jupyter_output><empty_output><jupyter_text>datasets.make_classification<jupyter_code>simple_classification_problem = datasets.make_classification(n_features = 2, n_informative = 1, 
                                                            n_redundant = 1, n_clusters_per_class = 1,
                                                            random_state = 1 )
plot_2d_dataset(simple_classification_problem, colors)
classification_problem = datasets.make_classification(n_features = 2, n_informative = 2, n_classes = 4, 
                                                      n_redundant = 0, n_clusters_per_class = 1, random_state = 1)

colors = ListedColormap(['red', 'blue', 'green', 'orange'])
plot_2d_dataset(classification_problem, colors)<jupyter_output><empty_output><jupyter_text>"Игрушечные" наборы данных **Наборы данных:** * load_iris * load_boston* load_diabetes* load_digits* load_linnerud* etc  datasets.load_iris<jupyter_code>iris = datasets.load_iris()
iris
iris.keys()
print(iris.DESCR)
print("feature names: {}".format(iris.feature_names))
print("target names: {names}".format(names = iris.target_names))
iris.data[:10]
iris.target<jupyter_output><empty_output><jupyter_text>Визуализация выбокри<jupyter_code>from pandas import DataFrame
iris_frame = DataFrame(iris.data)
iris_frame.columns = iris.feature_names
iris_frame['target'] = iris.target
iris_frame.head()
iris_frame.target = iris_frame.target.apply(lambda x : iris.target_names[x])
iris_frame.head()
iris_frame[iris_frame.target == 'setosa'].hist('sepal length (cm)')
pyplot.figure(figsize(20, 24))

plot_number = 0
for feature_name in iris['feature_names']:
    for target_name in iris['target_names']:
        plot_number += 1
        pyplot.subplot(4, 3, plot_number)
        pyplot.hist(iris_frame[iris_frame.target == target_name][feature_name])
        pyplot.title(target_name)
        pyplot.xlabel('cm')
        pyplot.ylabel(feature_name[:-4])<jupyter_output><empty_output><jupyter_text>Бонус: библиотека seaborn<jupyter_code>import seaborn as sns
sns.pairplot(iris_frame, hue = 'target')
?sns.set()
sns.set(font_scale = 1.3)
data = sns.load_dataset("iris")
sns.pairplot(data, hue = "species")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12973137973137974, 'fraction_numerical': 0.015567765567765568, 'mean_word_length': 5.194706994328922, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '11086', 'license': 'MIT', 'n_tokens_mistral': 1205, 'n_tokens_neox': 1171, 'n_words': 188, 'path': 'LearningOnMarkedData/week2/sklearn.datasets.ipynb', 'repo_name': 'ishatserka/MachineLearningAndDataAnalysisCoursera', 'size': '3276'}