{ "cells": [ { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "from sklearn.datasets import make_blobs" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(10, 2)\n" ] } ], "source": [ "###6.3.1 生成用于聚类的各向同性高斯斑点\n", "## sklearn.datasets.make_blobs(n_samples=100, n_features=2, *, centers=None, cluster_std=1.0, \n", "# center_box=(-10.0, 10.0), shuffle=True, random_state=None, return_centers=False)\n", "X, y = make_blobs(n_samples=10, centers=3, n_features=2,random_state=0)\n", "print(X.shape)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([0, 0, 1, 0, 2, 2, 2, 1, 1, 0])" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "y" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "## 总结\n", "\n", "#1、为了在控制数据的统计特性(通常是特征的 correlation (相关性)和 informativeness (信息性))的同时\n", "# 评估数据集 (n_samples 和 n_features) 的规模的影响,也可以生成综合数据。\n", "#2、此处只列举了make_blobs方法,更多的方法请参考 https://scikit-learn.org/stable/datasets/sample_generators.html" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.8" } }, "nbformat": 4, "nbformat_minor": 2 }