程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

python_ data_ analysis_ and_ mining_ action-master-9

編輯:Python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Nov 3 13:10:35 2017
@author: lu
"""
import pickle
from numpy.random import shuffle
import pandas as pd
from sklearn import metrics, svm
"""
programmer_1-->svm Support vector machine
"""
def programmer_1():
inputfile = "data/moment.csv"
outputfile1 = "tmp/cm_train.xls"
outputfile2 = "tmp/cm_test.xls"
data = pd.read_csv(inputfile, encoding="gbk")
data = data.as_matrix()
# Then extract training set and verification set --8:2
shuffle(data)
data_train = data[:int(0.8 * len(data)), :]
data_test = data[int(0.8 * len(data)):, :]
# Training set / Extraction of training data and result data of verification set
x_train = data_train[:, 2:] * 30
y_train = data_train[:, 0].astype(int)
x_test = data_test[:, 2:] * 30
y_test = data_test[:, 0].astype(int)
# Training support vector machine SVC
model = svm.SVC()
model.fit(x_tra

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved