def run(file_path): obj = getData(file_path) features, labels = obj.normalize_data() features = features.as_matrix() labels = labels.as_matrix() features_train, features_test, labels_train, labels_test = train_test_split(features, labels) clf = linear_model.LogisticRegression() clf.fit(features_train, labels_train) predection = clf.predict(features_test) accuracy = accuracy_score(labels_test, predection) print(accuracy)
def run(file_path): obj = getData(file_path) features, labels = obj.normalize_data() features = features.as_matrix() labels = labels.as_matrix() features_train, features_test, labels_train, labels_test = train_test_split( features, labels) clf = tree.DecisionTreeClassifier(class_weight='balanced') clf.fit(features_train, labels_train) predection = clf.predict(features_test) accuracy = accuracy_score(labels_test, predection) print(accuracy)
def run(file_path): obj = getData(file_path) features, labels = obj.normalize_data() # Convert DataFrames or Series into Numpy arrays features = features.as_matrix() labels = labels.as_matrix() # Seperate train and test sets features_train, features_test, labels_train, labels_test = train_test_split(features, labels) # Train and predict # clf = svm.SVC() clf = GaussianNB() clf.fit(features_train, labels_train) prediction = clf.predict(features_test) accuracy = accuracy_score(labels_test, prediction) print(accuracy)
def __init__(self, file_path): self.file_path = file_path self.obj = getData(self.file_path)
#!/usr/bin/env python import numpy as np import pandas as pd from sklearn import linear_model from sklearn.model_selection import train_test_split from sklearn.metrics import accuracy_score from normalize import getData file_path = 'data/final_data.csv' obj = getData(file_path) features, labels = obj.normalize_data() # Convert DataFrames or Series into Numpy arrays features = features.as_matrix() labels = labels.as_matrix() # Seperate train and test sets features_train, features_test, labels_train, labels_test = train_test_split( features, labels) # Train and predict # clf = svm.SVC() clf = linear_model.LinearRegression() clf.fit(features_train, labels_train) prediction = clf.predict(features_test) accuracy = accuracy_score(labels_test, prediction)
#!/usr/bin/env python from normalize import getData training_file = 'data/main_data.csv' obj = getData(training_file) obj.plot_graphs()