# coding: utf-8

# In[1]:

import pandas as pd
import numpy as np
from sklearn import tree
from sklearn.svm import SVC
from sklearn.grid_search import GridSearchCV
from sklearn.model_selection import train_test_split
from sklearn.metrics import classification_report, confusion_matrix
from sklearn.preprocessing import binarize
from sklearn.preprocessing import LabelEncoder
from sklearn.preprocessing import OneHotEncoder
from sklearn.preprocessing import Normalizer
from sklearn.metrics import f1_score
from sklearn.metrics import accuracy_score,recall_score,average_precision_score,auc

# In[2]:

data = pd.read_csv("D:/Users/SGG91044/Desktop/MEP_no_defect_data_pivot_test.csv")

# In[3]:

data.head()

# In[4]:

data.drop(columns=["lotid","waferid","defect_count","eqpid","Chamber","Step","Recipie_Name"],inplace=True)
data

# In[5]:

data.iloc[:,0:17] = data.iloc[:,0:17].apply(pd.to_numeric,errors='coerce')

# In[6]:

for i in range(0,17):
med = np.median(data.iloc[:,i][data.iloc[:,i].isna() == False])
data.iloc[:,i] = data.iloc[:,i].fillna(med)

# In[10]:

nz = Normalizer()
X=data.iloc[:,0:19]=pd.DataFrame(nz.fit_transform(data.iloc[:,0:17]),columns=data.iloc[:,0:17].columns)

# In[11]:

X

# In[12]:

X_train, X_test = train_test_split(
X, test_size=0.3, random_state=8)

# In[30]:

# fit the model
clf = IsolationForest( max_samples=10000,random_state=10 )
clf.fit(X_train)
y_pred_train = clf.predict(X_train)
y_pred_test = clf.predict(X_test)

# In[35]:

scores_pred = clf.decision_function(X_train.values)
scores_pred

# In[36]:

clf.decision_function(X_test)

我的代码-unsupervised learning的更多相关文章

  1. Machine Learning Algorithms Study Notes(4)—无监督学习(unsupervised learning)

    1    Unsupervised Learning 1.1    k-means clustering algorithm 1.1.1    算法思想 1.1.2    k-means的不足之处 1 ...

  2. Unsupervised Learning: Use Cases

    Unsupervised Learning: Use Cases Contents Visualization K-Means Clustering Transfer Learning K-Neare ...

  3. Unsupervised Learning and Text Mining of Emotion Terms Using R

    Unsupervised learning refers to data science approaches that involve learning without a prior knowle ...

  4. Supervised Learning and Unsupervised Learning

    Supervised Learning In supervised learning, we are given a data set and already know what our correc ...

  5. Unsupervised learning无监督学习

    Unsupervised learning allows us to approach problems with little or no idea what our results should ...

  6. PredNet --- Deep Predictive coding networks for video prediction and unsupervised learning --- 论文笔记

    PredNet --- Deep Predictive coding networks for video prediction and unsupervised learning   ICLR 20 ...

  7. 131.005 Unsupervised Learning - Cluster | 非监督学习 - 聚类

    @(131 - Machine Learning | 机器学习) 零. Goal How Unsupervised Learning fills in that model gap from the ...

  8. Unsupervised learning, attention, and other mysteries

    Unsupervised learning, attention, and other mysteries Get notified when our free report “Future of M ...

  9. Coursera 机器学习 第8章(上) Unsupervised Learning 学习笔记

    8 Unsupervised Learning8.1 Clustering8.1.1 Unsupervised Learning: Introduction集群(聚类)的概念.什么是无监督学习:对于无 ...

随机推荐

  1. java根据#号截取字符串,使用Pattern的方法

    public class Regex1 { public static void main(String[] args) { String s = "神秘的海洋出现了一只#话题#海怪阿拉斯加 ...

  2. Oracle查询语句导致CPU使用率过高问题处理

    解决此问题的关键在于如何找到造成CPU使用率过高的SQL语句.步骤如下: 1.使用Process Explorer工具查看到Oracle进程,双击Oracle进程,在弹出的属性窗口的Threads选项 ...

  3. go-ethereum源码分析 PartII 共识算法

    首先从共识引擎-Engine开始记录 Engine是一个独立于具体算法的共识引擎接口 Author(header) (common.Address, error) 返回打包header对应的区块的矿工 ...

  4. 常见IO模型

    在socket的通信中,recv,accept,recvfrom(UDP协议接收信息)这些阶段由于需要收到信息,才能继续下面的代码,所以这些阶段叫做阻塞,类似于我们python变成中的input函数, ...

  5. vs code编写的时候自动回车的原因

    今天在书写一个空白的scss文件的时候,刚打2个字就自动回车换行了: 测试了几次,发现了规律就是输入停下来0.5秒左右就会自动换行,比如,打了2个中文,再连续打一个句子,键盘虽然在动,但是vs cod ...

  6. linux下jdk8安装

    --- 解压命令不管用 添加插件 yum install tar --- 上传命令不管用 添加插件 wget http://www.ohse.de/uwe/releases/lrzsz-0.12.20 ...

  7. 关于C#mvc用iis发布,虚拟目录的问题。

    mvc关于iis发布虚拟目录的问题,解决方法是修改代码中路径的方式,例如ajax中常用的为url:“/Home/Index”,可修改为 url: '@Url.Action("Index&qu ...

  8. Django框架教程之正则表达式URL误区详解

    问题:我学习的视频大概是2015年录的,里面用的Django版本比较老关于正则表达式URL这一块都是用的url(“url(r'^admin/', admin.site.urls),”)方法.而我自己练 ...

  9. PYTHON实现算术表达式构造二叉树

    LEETCOCE 224. Basic Calculator Implement a basic calculator to evaluate a simple expression string. ...

  10. 查询数据库游标使用情况以及sql

    ----查询游标使用情况以及游标最大数---- SELECT MAX(A.VALUE) AS HIGHEST_OPEN_CUR, P.VALUE AS MAX_OPEN_CUR FROM V$SESS ...