BigdataAIML-Important Data Features preprocessing points非常重要的数据维度预处理方面
https://developer.ibm.com/tutorials/awb-k-means-clustering-in-python/
PCA: 对2D数据非常好理解,但是对tensor(3D以上维度),假设维度为N,
可以理解为 求一个 方阵, 每一条N维列向量的数据乘以这个方阵(即进行多维坐标轴旋转),
得到的是降维变换(小于等于N维空间的)后的向量;
算法会有一些前提条件与假设,而通过数据预处理,
不仅可以保障与满足这些,同时能提高模型的有效计算速度。
“不空”、“不漏”、“不乱”、“不限”、“不差”、“不异”:
- Dedkind Split
- 不限、不差、不异
例如:- 大多数算法假设数据是完整而有效的。
- Naive-Bayes算法假设数据维度之间的correlationship是非常小的。
- K-Means算法要估计最佳的Number of Cluster簇数。
Preprocessing
Ensure that the columns were imported with the correct data types.
$ print(df.dtypes)
distance_center float64
num_rooms float64
property_size float64
age float64
utility_cost float64
label int64
dtype: objectCheck for missing values.
Consider imputation or removing missing values if there are many.
$ df.isnull().sum()
distance_center 0
num_rooms 0
property_size 0
age 0
utility_cost 0
label 0
dtype: int64Check for outliers.
Consider removing outliers If appropriate, so that the final cluster shapes are not skewed.Standardize scales first using scikit-learn;
Identify correlated features using mathematics(Measure of correlationship);
Consider using a pairwise plot to identify strong correlations and remove features that are highly correlated.
EDA(Exploratory Data Analysis)
These are the steps you will follow:
- Create a AI project and open a Jupyter Notebook.
- Generate a data set and do preprocess.
- Perform EDA (exploratory data analysis).
- Choose K clusters using WCSS.
- Interpret K-means clustering.
Example: Choose best K for K-Means model
When EDA is complete, you must choose how many clusters to separate your data into.
- set K manually in scikit-learn If you already know how many groups you want to make.
- use the elbow method to test different K values, If you are not sure how many groups are appropriate,
- The elbow method works by computing the Within Cluster Sum of Squares (WCSS), quantifies the variance (or spread) of data within a cluster.
- If WCSS decreases, the data within the clusters are more similar.
- As K increases, there should be a natural decrease in WCSS because the distance between the data in its cluster to its center will be smaller.
- The ideal K is the "elbow" point of the graph, where WCSS stops decreasing or starts to marginally decrease as K increases.
- The elbow method is particularly useful for big data sets that have lots of potential clusters because there is a trade-off between computational power required to run the algorithm and the number of clusters generated.
Use the following steps to implement the elbow method.
- Create an empty list to hold WCSS values at different K values.
- Fit the clusters with different K values.
- At each K value, append the WCSS value to the list.
- Graph the WCSS values versus the number of clusters.
Use the elbow method to find a good number of clusters using WCSS (within-cluster sums of squares)
wcss = []
Let's check for up to 10 clusters
for i in range(1, 11):
kmeans = KMeans(n_clusters=i, init='k-means++', max_iter=300, n_init=10, random_state=42)
kmeans.fit(df)
wcss.append(kmeans.inertia_)
plt.plot(range(1, 11), wcss)
plt.title('Elbow Method')
plt.xlabel('Number of clusters')
plt.ylabel('WCSS')
plt.show()
Select the "elbow point" of the graph as your K value.
Elbow method graph
Rerun K-means with your chosen K value. Use the n_clusters parameter to set the K value.
Be sure to set the random_state parameter for reproducibility.
The graph indicates that 5 is the ideal number of clusters, which makes sense because we set the make-blobs number of centers parameter equal to 5.
Ideal number of clusters
Step 5. Interpret K-means clustering
**Using PCA(Principal Component Analysis) and similar dimensionality reduction technique
so you can graph your clusters in a two-dimensional space and visualize the groupings.
This tutorial does not cover the exact details of PCA,
but our data has five dimensions, and thus dimensionality reduction is needed to visualize clusters of data with more than two dimensions in a 2-D space.
It's likely that most data sets that you encounter when performing K-means clustering have data with more than two dimensions.
The following steps are the high-level steps to interpret K-means clustering.
BigdataAIML-Important Data Features preprocessing points非常重要的数据维度预处理方面的更多相关文章
- Spring Data:企业级Java的现代数据访问技术(影印版)
<Spring Data:企业级Java的现代数据访问技术(影印版)>基本信息原书名:Spring Data:Modern Data Access for Enterprise Java作 ...
- 17.1.1.8?Setting Up Replication with Existing Data设置复制使用存在的数据
17.1.1.8?Setting Up Replication with Existing Data设置复制使用存在的数据 当设置复制使用存在的数据,你需要确定如何最好的从master 得到数据到sl ...
- 【转】Jmeter中使用CSV Data Set Config参数化不重复数据执行N遍
Jmeter中使用CSV Data Set Config参数化不重复数据执行N遍 要求: 今天要测试上千条数据,且每条数据要求执行多次,(模拟多用户多次抽奖) 1.用户id有175个,且没有任何排序规 ...
- Jmeter===Jmeter中使用CSV Data Set Config参数化不重复数据执行N遍(转)
Jmeter中使用CSV Data Set Config参数化不重复数据执行N遍 要求: 今天要测试上千条数据,且每条数据要求执行多次,(模拟多用户多次抽奖) 1.用户id有175个,且没有任何排序规 ...
- Azure Data Factory(二)复制数据
一,引言 上一篇主要只讲了Azure Data Factory的一些主要概念,今天开始新的内容,我们开始通过Azure DevOps 或者 git 管理 Azure Data Factory 中的源代 ...
- 使用Spring Data ElasticSearch+Jsoup操作集群数据存储
使用Spring Data ElasticSearch+Jsoup操作集群数据存储 1.使用Jsoup爬取京东商城的商品数据 1)获取商品名称.价格以及商品地址,并封装为一个Product对象,代码截 ...
- Define the Data Model and Set the Initial Data 定义数据模型并设置初始数据
This topic describes how to define the business model and the business logic for WinForms and ASP.NE ...
- Jmeter—6 CSV Data Set Config 通过文件导入数据
线程组循环次数大于1的时候,请求里每次提交的数据都相同.有的系统限制了不能提交相同数据,我们通过 CSV Data Set Config 加载csv文件数据. 1 创建一个文本文件,输入参数值保存为. ...
- 转:代码的坏味道之二十 :Data Class(纯稚的数据类)或POJO
所谓Data Class是指:它们拥有一些值域(fields),以及用于访问(读写]这些值域的函数,除此之外一无长物.这样的classes只是一种「不会说话的数据容器」,它们几乎一定被其他classe ...
- [译] 使用Using Data Quality Services (DQS) 清理用户数据
SQL Server 2012 Data Quality Services (DQS) 允许你使用自己的知识库来清洗数据. 在本文中我会展示一个简单示例. 使用DQS清理步骤如下: A. 建立DQS ...
随机推荐
- SQL 强化练习 (八)
继续练习写sql, 不能停下来. 今天还额外对 Excel 拼接 sql 语句做了一个代码实现, 逻辑是蛮简单的, 发现其实很多东西都是蛮简单的, 只要一点点去做, 明白逻辑过后, 慢慢去调试, 都是 ...
- C#之MethodImpl(MethodImplOptions.Synchronized)
[MethodImpl(MethodImplOptions.Synchronized)] 是 C# 中用于指定方法同步的一个特性,它控制方法的执行方式,确保在多线程环境下某个方法的执行是线程安全的.它 ...
- 第2讲、从启动到表单加载:Odoo 18 的完整执行流程详解
了解 Odoo 在从启动到用户打开一个模型表单视图时,内部到底发生了什么,是模块开发.性能调优和故障排查的关键.本文将为你系统梳理 Odoo 18 的执行流程与关键方法调用链,适用于开发者与技术架构师 ...
- 乌班图源码编译安装nginx
第一步:下载 wget http://nginx.org/download/nginx-1.16.0.tar.gz 第二步:解压 tar -xzf Nginx-1.16.0.tar.gz 第三步:编译 ...
- 如何在 .NET 中构建一个好用的动态查询生成器
前言 自从.NET Framework 3.5提供了LINQ之后,集合数据查询基本被LINQ统一了.这大幅提高了编写数据查询代码的效率和质量,但是在需要编写动态查询的时候反而很困难,特别是最常用的wh ...
- 在Ubuntu上使用Let's Encrypt配置Nginx SSL证书并自动更新
在Ubuntu上使用Let's Encrypt配置Nginx SSL证书并自动更新 绪言 这篇文章其实内容不多,难度不大,只是自己记录一下. Arisu拷打了我几次我在阿里云上花钱购买SSL证书一事. ...
- 【2020.11.24提高组模拟】变换 (transform) 题解
[2020.11.24提高组模拟]变换 (transform) 题解 题意描述 给一个大小为\(n\)的\(01\)环\(A\),点编号为\(0,1,\dots,n-1\).每一个点\(i\)都与\( ...
- Linux c 运行时获取动态库所在路径
记录一下如何在Linux环境下运行时获取动态库路径. 只讨论Linux amd64和arm64环境,因为使用的办法都是平台相关的不具备可移植性. 准备 一般来说动态库并不需要关心自己所在的文件系统上的 ...
- crictl基础操作
# 1. 查看机器上的镜像列表 crictl images ls # 2.删除机器上没用使用的镜像 crictl rmi --prune
- python之PypI打包whl文件
一.简单介绍 python中我们经常会用到第三方的包作为工具,比如爬虫解析工具,网络请求工具等.之所以要把它封装成包,意识为了技术与业务分离,二是为了能多 项目多平台共用.python里面用到的第三方 ...