sklearn之svm-葡萄酒質量預測(7)
阿新 • • 發佈:2018-12-14
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Fri Aug 10 16:13:29 2018
svm-葡萄酒質量預測
@author: [email protected]
@blog:https://blog.csdn.net/myhaspl
"""
import pandas as pd
import numpy as np
from sklearn import svm
testDf=pd.read_csv("winequality-white-test.csv",sep=";")
testData=testDf.values
wineDf= pd.read_csv("winequality-white.csv",sep=";")
wineData=wineDf.values
dataColName=df.columns
ftColName=dataColName[-1]
rsColName=list(dataColName[:len(dataColName)-1])
testFeature=testDf[ftColName].values
testResult=testDf[rsColName].values
wineFeature=wineDf[ftColName].values
wineResult=wineDf[rsColName] .values
clf = svm.SVC(gamma='scale')
clf.fit(wineFeature,wineResult)
y_pred=clf.predict(testFeature)
print y_pred
print testResult