Created
March 19, 2020 05:25
-
-
Save mirsahib/54ae6cc5f0b0911309eab6cc936f6c23 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
Created on Thu Mar 19 10:55:10 2020 | |
@author: Mir Sahib | |
""" | |
import pandas as pd | |
import numpy as np | |
import matplotlib.pyplot as plt | |
from sklearn.model_selection import train_test_split | |
from sklearn.svm import SVC | |
from sklearn.metrics import accuracy_score,roc_auc_score | |
from itertools import combinations | |
import glob | |
import concurrent.futures | |
import sys | |
fileName = glob.glob(r'C:\Users\Mir Sahib\Desktop\Jupyter_WS\pair_set\*.csv') | |
def run_svm(fileName): | |
data = pd.read_csv(fileName) | |
X = data.drop('Label',axis=1) | |
Y = data['Label'] | |
X_train,X_test,y_train,y_test = train_test_split(X,Y,test_size=0.2,random_state=0,stratify=Y) | |
clf = SVC(kernel = 'linear') | |
clf.fit(X_train, y_train) | |
y_pred = clf.predict(X_test) | |
return clf.coef_ | |
if __name__ == '__main__': | |
try: | |
with concurrent.futures.ProcessPoolExecutor() as executor: | |
for result in zip(fileName,executor.map(run_svm, fileName)): | |
print(result) | |
except Exception as e: | |
#print(sys.exc_info()[0]) | |
print(e) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment