Beispiel #1
0
from sklearn.neural_network import MLPClassifier
from utils import split_feats_targs, capture_features, capture_targets, export_results

(train_features, train_targets) = split_feats_targs(
    'train_1.csv')  # pass training set with targets
test_features = capture_features('test_no_label_1.csv',
                                 False)  # pass test set without targets
actual_targets = capture_targets(
    'test_with_label_1.csv')  # pass test set with targets

fitted_mlp = MLPClassifier(activation='logistic', solver='sgd').fit(
    train_features, train_targets)  # fits model with training set values
predicted_targets = list(fitted_mlp.predict(
    test_features))  # gets predictions from model and record them
export_results(actual_targets, predicted_targets, 'Base-MLP-DS1.csv')
Beispiel #2
0
"""
from utils import split_feats_targs, capture_features, capture_targets, export_results
from sklearn.naive_bayes import GaussianNB
from sklearn.linear_model import Perceptron
from sklearn.tree import DecisionTreeClassifier
from sklearn.neural_network import MLPClassifier
from sklearn.model_selection import GridSearchCV
"""
Store the necessary training/test set values into variables
"""
(train_features,
 train_targets) = split_feats_targs('<demo_training_set_file_name>')
test_features = capture_features(
    '<demo_test_set_file_name>',
    False)  # pass False if test set has no targets, otherwise pass True
actual_targets = capture_targets('<demo_test_set_w_targets_file_name>')
"""
Run GNB model
"""
fitted_gnb = GaussianNB().fit(
    train_features, train_targets)  # fit model with training set values
predicted_targets = list(fitted_gnb.predict(
    test_features))  # get predictions from model and record them
export_results(actual_targets, predicted_targets, '<demo_output_file_name>')
"""
Run PER model
"""
fitted_per = Perceptron().fit(
    train_features, train_targets)  # fit model with training set values
predicted_targets = list(fitted_per.predict(
    test_features))  # get predictions from model and record them