Beispiel #1
0
from sklearn.model_selection import GridSearchCV
from math import log
from sklearn.model_selection import train_test_split


def svc_param_selection(X, y, nfolds=None):
    Cs = [0.001, 0.01, 0.1, 1, 10, 100, 1000]
    gammas = [0.001, 0.01, 0.1, 1, 10, 100, 1000]
    param_grid = {'C': Cs, 'gamma': gammas}
    grid_search = GridSearchCV(svm.SVC(kernel='rbf'), param_grid, cv=3)
    grid_search.fit(X, y)
    print(grid_search.best_params_)


support = svm.SVC(kernel='rbf', C=100, gamma=10)
a = Parser('new_data.csv')
a.open()
dots = a.get_data()

X = []
y = []

TEST = []
a = 1.8
b = 1510000000
for dot in dots:
    if dot.label == '-':
        continue
    if dot.label == '?':
        TEST.append((dot.log, dot.lat, log(dot.trans_ts - b,
                                           a), log(dot.request_ts - b, a)))
Beispiel #2
0
from sklearn.linear_model import LogisticRegression
from csv_parser import Parser
from math import log
from sklearn.model_selection import train_test_split
from sklearn.feature_selection import RFE

decision = LogisticRegression(C=1.5, max_iter=2000, solver="saga")
rfe = RFE(decision, 2)
a = Parser('transport_data.csv')
a.open()
dots = a.get_data()

X = []
y = []

TEST = []
a = 10
b = 1510000000
for dot in dots:
    if dot.label == '-':
        continue
    if dot.label == '?':
        TEST.append((dot.log, dot.lat, log(dot.trans_ts - b,
                                           a), log(dot.request_ts - b, a)))
        continue
    X.append((dot.log, dot.lat, log(dot.trans_ts - b,
                                    a), log(dot.request_ts - b, a)))
    y.append(dot.label)

X_train, X_test, y_train, y_test = train_test_split(X,
                                                    y,
Beispiel #3
0
import os

from csv_parser import Parser

CSV_FILE_DIR = os.path.join(os.path.dirname(__file__), 'csv_parser', 'data')

print('----------------------------------------------------')
print('Results of parsing 1.csv:')
with open(os.path.join(CSV_FILE_DIR, '1.csv')) as csv_file:
    print(Parser(csv_file).parse())

print('----------------------------------------------------')
print('Results of parsing 2.csv:')
with open(os.path.join(CSV_FILE_DIR, '2.csv')) as csv_file:
    print(Parser(csv_file).parse())

print('----------------------------------------------------')
print('Results of parsing 3.csv:')
with open(os.path.join(CSV_FILE_DIR, '3.csv')) as csv_file:
    print(Parser(csv_file).parse())
print('----------------------------------------------------')