boyuancong 2017-11-04 12:26 采纳率: 0%
浏览 13148

NameError: name 'clf' is not defined”

import sys,random,os,pickle

from multiprocessing import Pool

from sklearn.svm import SVC

from sklearn import metrics
from sklearn import cross_validation

from sklearn.cross_validation import train_test_split

from sklearn.externals import joblib

import pandas as pd

train = pd.read_csv("E:/training38085.csv")
test = pd.read_csv("E:/test38085.csv")
test_x = test.drop("bad_good",axis=1)

#生成validation set

val = pd.read_csv('E:/validation20000_950.csv')

train_y = train.bad_good

train_x = train.drop(['bad_good'],axis=1)

val_y = val.bad_good

val_x = val.drop(['bad_good'],axis=1)

print(test_x.shape)

print(train_x.shape)

print(val_x.shape)

def pipeline(iteration,C,gamma,random_seed):

x_train, _x , y_train, _y = train_test_split(train_x,train_y,test_size=0.4,random_state=random_seed)

print(x_train.shape)

clf = SVC(C=C,kernel='rbf',gamma=gamma,probability=True,cache_size=7000,class_weight='balanced',verbose=True,random_state=random_seed)

clf.fit(x_train,y_train)

#predict test set

pred = clf.predict_proba(test_x)
    Traceback (most recent call last):

File "", line 1, in
报错: “pred = clf.predict_proba(test_x)
NameError: name 'clf' is not defined”
上面def pipline 有clf ,为啥还会报错呢。前面的代码没有报错

  • 写回答

1条回答 默认 最新

  • devmiao 2017-11-04 13:22
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥30 python代码,帮调试,帮帮忙吧