image_output_1.png
import matplotlib.pyplot as plt

import numpy as np # linear algebra

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

data_train_db = pd.read_csv('/kaggle/input/data-train-db/data_train_db.csv')
data_test_db = pd.read_csv('/kaggle/input/data-test-db/data_test_db.csv')

from scipy import stats
stdev_max = 6
pd.set_option('display.max_rows', data_train_db.shape[0] + 1)

data_train = data_train_db.values

labels = 'Runs', 'Does not run'
sizes = [np.sum(data_train[:,0]), np.sum(1-data_train[:,0])]

fig1, ax1 = plt.subplots()
ax1.pie(sizes, labels=labels, autopct='%1.1f%%',
        shadow=True, startangle=90)
ax1.axis('equal')  # Equal aspect ratio ensures that pie is drawn as a circle.

plt.show()

def myclassifier(data):
    if data[1] == 0:
        return 0
    if data[2] > 1.5 and (data[65] + data[66] < 5 or data[3] + data[4] + data[5] < 4.5 or data[80] + data[81] + data[82] < 4.5) or (data[2] < 1.5 and (data[99] > 3.5 or data[62] + data[63] + data[64] < 5 or data[77] + data[78] + data[79] < 4.5)):
        return 0
    return 1
err1 = 0
for t in range(data_train.shape[0]):
    err1 = err1 + (myclassifier1(data_train[t, :]) != data_train[t, 0])
err2 = 0
for t in range(data_train.shape[0]):
    err2 = err2 + (myclassifier(data_train[t, :]) != data_train[t, 0])
print('Train accuracy 1:' + str(1 - err1 / data_train.shape[0]))
print('Train accuracy 2:' + str(1 - err2 / data_train.shape[0]))
print('difference: ' + str(1 - err1 / data_train.shape[0] - 1 + err2 / data_train.shape[0]))