<jupyter_start><jupyter_text>Increasing accuracy for LL fault detection<jupyter_code>from jupyterthemes import get_themes
import jupyterthemes as jt
from jupyterthemes.stylefx import set_nb_theme

set_nb_theme('chesterish')
import pandas as pd
data_10=pd.read_csv(r'D:\Acads\BTP\Lightly Loaded\Train10hz2.csv')
data_20=pd.read_csv(r'D:\Acads\BTP\Lightly Loaded\Train20hz2.csv')
data_30=pd.read_csv(r'D:\Acads\BTP\Lightly Loaded\Train30Hz2.csv')
data_15=pd.read_csv(r'D:\Acads\BTP\Lightly Loaded\Train15hz2.csv')
data_25=pd.read_csv(r'D:\Acads\BTP\Lightly Loaded\Train25hz2.csv')
data_10=data_10.head(99990)
data_15=data_15.head(99990)
data_20=data_20.head(99990)
data_25=data_25.head(99990)
data_30=data_30.head(99990)
data_25.head<jupyter_output><empty_output><jupyter_text>Shuffling<jupyter_code>data_20=data_20.sample(frac=1)
data_30=data_30.sample(frac=1)
data_10=data_10.sample(frac=1)
data_15=data_15.sample(frac=1)
data_25=data_25.sample(frac=1)
import sklearn as sk<jupyter_output><empty_output><jupyter_text>Assiging X and y for training<jupyter_code>dataset_10=data_10.values
X_10= dataset_10[:,0:9]
print(X_10)
y_10=dataset_10[:,9]
print(y_10)
dataset_15=data_15.values
X_15= dataset_15[:,0:9]
print(X_15)
y_15=dataset_15[:,9]
print(y_15)
dataset_20=data_20.values
X_20= dataset_20[:,0:9]
print(X_20)
y_20=dataset_20[:,9]
print(y_20)
dataset_25=data_25.values
X_25= dataset_25[:,0:9]
print(X_25)
y_25=dataset_25[:,9]
print(y_25)
dataset_30=data_30.values
X_30= dataset_30[:,0:9]
print(X_30)
y_30=dataset_30[:,9]
print(y_30)<jupyter_output>[[ 2.4935450e+01 -4.9922530e+00  7.8726500e+00 ... -1.6664800e-01
  -3.8500000e-04  3.9411700e-01]
 [ 2.5294050e+01 -1.3088218e+01 -2.2882611e+01 ... -1.5150200e-01
  -2.4600000e-04  1.3029700e-01]
 [ 1.1126500e+00 -5.6964500e-01 -8.9743100e-01 ...  2.0879300e-01
  -1.1400000e-03  2.2298900e-01]
 ...
 [ 1.1696500e+00 -3.6290960e+00  2.3131530e+00 ...  6.8067000e-02
  -1.4530000e-03 -9.1156000e-02]
 [ 1.2179000e+00  1.0015628e+01  1.1586879e+01 ... -1.2445800e-01
  -3.2700000e-04  2.3937200e-01]
 [ 2.5326550e+01 -2.4578310e+00 -1.1466750e+00 ... -1.2771600e-01
  -3.5900000e-04  8.6916000e-02]]
[4. 1. 3. ... 3. 1. 2.]<jupyter_text>Training RF Classifier<jupyter_code>from sklearn.ensemble import RandomForestClassifier
rf_10 = RandomForestClassifier(n_estimators = 1000, random_state = 42)
rf_10.fit(X_10, y_10);
from sklearn.ensemble import RandomForestClassifier
rf_15 = RandomForestClassifier(n_estimators = 5000, random_state = 42)
rf_15.fit(X_15, y_15);
from sklearn.ensemble import RandomForestClassifier
rf_20 = RandomForestClassifier(n_estimators = 5000, random_state = 42)
rf_20.fit(X_20, y_20);
from sklearn.ensemble import RandomForestClassifier
rf_25 = RandomForestClassifier(n_estimators = 5000, random_state = 42)
rf_25.fit(X_25, y_25);
from sklearn.ensemble import RandomForestClassifier
rf_30 = RandomForestClassifier(n_estimators = 5000, random_state = 42)
rf_30.fit(X_30, y_30);<jupyter_output><empty_output><jupyter_text>Importing Testing Data<jupyter_code>test_10=pd.read_csv(r'D:\Acads\BTP\Lightly Loaded\Test10hz.csv')
test_20=pd.read_csv(r'D:\Acads\BTP\Lightly Loaded\Test20hz.csv')
test_30=pd.read_csv(r'D:\Acads\BTP\Lightly Loaded\Test30Hz.csv')
test_15=pd.read_csv(r'D:\Acads\BTP\Lightly Loaded\Test15hz.csv')
test_25=pd.read_csv(r'D:\Acads\BTP\Lightly Loaded\Test25hz.csv')
test_35=pd.read_csv(r'D:\Acads\BTP\Lightly Loaded\Test35Hz.csv')
test_40=pd.read_csv(r'D:\Acads\BTP\Lightly Loaded\Test40Hz.csv')
test_10=test_10.head(99990)
test_15=test_15.head(99990)
test_20=test_20.head(99990)
test_25=test_25.head(99990)
test_30=test_30.head(99990)
test_35=test_35.head(99990)
test_40=test_40.head(99990)
test_20=test_20.sample(frac=1)
test_30=test_30.sample(frac=1)
test_40=test_40.sample(frac=1)
test_10=test_10.sample(frac=1)
test_15=test_15.sample(frac=1)
test_25=test_25.sample(frac=1)
test_35=test_35.sample(frac=1)<jupyter_output><empty_output><jupyter_text>Assigning X and y for testing<jupyter_code>dataset_test_10 = test_10.values
X_test_10 = dataset_test_10[:,0:9]
print(X_test_10)

y_test_10= dataset_test_10[:,9]
print(y_test_10)
dataset_test_15 = test_15.values
X_test_15 = dataset_test_15[:,0:9]
print(X_test_15)

y_test_15= dataset_test_15[:,9]
print(y_test_15)
dataset_test_20 = test_20.values
X_test_20 = dataset_test_20[:,0:9]
print(X_test_20)

y_test_20= dataset_test_20[:,9]
print(y_test_20)
dataset_test_25 = test_25.values
X_test_25 = dataset_test_25[:,0:9]
print(X_test_25)

y_test_25= dataset_test_25[:,9]
print(y_test_25)
dataset_test_30 = test_30.values
X_test_30 = dataset_test_30[:,0:9]
print(X_test_30)

y_test_30= dataset_test_30[:,9]
print(y_test_30)
dataset_test_35 = test_35.values
X_test_35 = dataset_test_35[:,0:9]
print(X_test_35)

y_test_35= dataset_test_35[:,9]
print(y_test_35)
dataset_test_40 = test_40.values
X_test_40 = dataset_test_40[:,0:9]
print(X_test_40)

y_test_40= dataset_test_40[:,9]
print(y_test_40)<jupyter_output>[[ 2.350000e-03 -6.048020e-01 -5.286216e+00 ... -5.563400e-02
  -5.360000e-04  1.524800e-01]
 [ 9.066500e-01  7.590920e-01  7.678400e-01 ...  1.846030e-01
  -5.390000e-04 -1.383960e-01]
 [ 6.659500e-01  2.462024e+00  4.102064e+00 ...  2.115860e-01
  -1.050000e-03 -2.585200e-02]
 ...
 [ 1.302000e-01  1.896860e-01 -1.041943e+00 ... -2.340610e-01
   8.900000e-04 -4.387370e-01]
 [ 1.816000e-01  3.382514e+00 -7.351136e+00 ...  2.053020e-01
  -5.810000e-04 -2.639510e-01]
 [ 4.139000e-01 -1.319388e+00  7.335840e-01 ... -3.393800e-02
  -4.200000e-04 -1.841800e-02]]
[4. 4. 3. ... 1. 4. 2.]<jupyter_text>Predictions with 10Hz model<jupyter_code>import numpy as np
predictions_10 = rf_10.predict(X_test_10)
errors_10 = abs(predictions_10 - y_test_10)
print('Mean Absolute Error 10Hz with 10Hz:', round(np.mean(errors_10), 3), 'degrees.')

accuracy = 100 - np.mean(errors_10)
print('Accuracy:', round(accuracy, 3), '%.')
predictions_15 = rf_10.predict(X_test_15)
errors_15 = abs(predictions_15 - y_test_15)
print('Mean Absolute Error 15Hz with 10Hz:', round(np.mean(errors_15), 3), 'degrees.')

accuracy = 100 - np.mean(errors_15)
print('Accuracy:', round(accuracy, 3), '%.')
predictions_20 = rf_10.predict(X_test_20)
errors_20 = abs(predictions_20 - y_test_20)
print('Mean Absolute Error 20Hz with 10Hz:', round(np.mean(errors_20), 3), 'degrees.')

accuracy = 100 - np.mean(errors_20)
print('Accuracy:', round(accuracy, 3), '%.')
predictions_25 = rf_10.predict(X_test_25)
errors_25 = abs(predictions_25 - y_test_25)
print('Mean Absolute Error 25Hz with 10Hz:', round(np.mean(errors_25), 3), 'degrees.')

accuracy = 100 - np.mean(errors_25)
print('Accuracy:', round(accuracy, 3), '%.')
predictions_30 = rf_10.predict(X_test_30)
errors_30 = abs(predictions_30 - y_test_30)
print('Mean Absolute Error 30Hz with 10Hz:', round(np.mean(errors_30), 3), 'degrees.')

accuracy = 100 - np.mean(errors_30)
print('Accuracy:', round(accuracy, 3), '%.')
predictions_35 = rf_10.predict(X_test_35)
errors_35 = abs(predictions_35 - y_test_35)
print('Mean Absolute Error 35Hz with 10Hz:', round(np.mean(errors_35), 3), 'degrees.')

accuracy = 100 - np.mean(errors_35)
print('Accuracy:', round(accuracy, 3), '%.')
predictions_40 = rf_10.predict(X_test_40)
errors_40 = abs(predictions_40 - y_test_40)
print('Mean Absolute Error 40Hz with 10Hz:', round(np.mean(errors_40), 3), 'degrees.')

accuracy = 100 - np.mean(errors_40)
print('Accuracy:', round(accuracy, 3), '%.')<jupyter_output>Mean Absolute Error 40Hz with 10Hz: 1.536 degrees.
Accuracy: 98.464 %.
{'fraction_non_alphanumeric': 0.15447371940617896, 'fraction_numerical': 0.1881770763675271, 'mean_word_length': 6.281402142161636, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '62564', 'license': 'MIT', 'n_tokens_mistral': 4210, 'n_tokens_neox': 3435, 'n_words': 465, 'path': '.ipynb_checkpoints/LL_Phase_2-checkpoint.ipynb', 'repo_name': 'Aficionado45/IM-Fault-Detection', 'size': '7477'}