コード例 #1
0
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)
コード例 #2
0
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)
コード例 #3
0
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)
コード例 #4
0
 def __init__(self, file_path):
     self.file_path = file_path
     self.obj = getData(self.file_path)
コード例 #5
0
#!/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)
コード例 #6
0
ファイル: plots.py プロジェクト: sehgalayush1/movie_revenue
#!/usr/bin/env python

from normalize import getData

training_file = 'data/main_data.csv'

obj = getData(training_file)
obj.plot_graphs()