<jupyter_start><jupyter_text>Python Useful LibrariesSimple Examples  Split datahttps://scikit-learn.org/stable/modules/generated/sklearn.model_selection.train_test_split.htmlA simple example of how you can split your data into test and training data.<jupyter_code>from sklearn.model_selection import train_test_split
import pandas as pd
#Example data
X = [[0, 0], [1, 1],[0, 1], [1, 1],[1,0]]
Y = [0, 1,0,1,1]
#splitting
X_train, X_test, y_train, y_test = train_test_split(X, Y, stratify=Y, random_state=1)<jupyter_output><empty_output><jupyter_text>MLP Classifierhttps://scikit-learn.org/stable/modules/generated/sklearn.neural_network.MLPClassifier.htmlThe MLP classifier creates a multi-layer peceptron.<jupyter_code>from sklearn.neural_network import MLPClassifier

clf = MLPClassifier()
clf.fit(X_train,y_train)                         
y_pred= clf.predict(X_test)
clf.score(X_test, y_test)
# size of synapsis weights
print([coef.shape for coef in clf.coefs_])  
# get weights
print(clf.coefs_)<jupyter_output>[(2, 100), (100, 1)]
[array([[-2.44330892e-03,  4.11415025e-01, -1.59271002e-01,
         4.39061195e-01, -1.62992369e-01, -7.45621302e-02,
        -1.51324091e-01, -1.56931617e-01, -2.89553801e-01,
         9.02975930e-02,  1.93789952e-03,  1.60449381e-02,
        -3.27340238e-01,  2.86981639e-01, -6.13761974e-07,
         5.16614126e-02, -3.67064472e-01, -3.06145552e-03,
         3.67177677e-01,  3.71057508e-01, -3.74126317e-04,
        -1.36471587e-01, -1.05588026e-05,  3.46969289e-01,
         3.66994451e-01, -3.61661294e-07,  1.74671088e-03,
        -2.16205260e-01,  1.02236443e-01,  8.43520328e-07,
        -7.57432877e-02,  3.95221133e-03,  9.68024065e-02,
        -7.57652581e-02, -1.21081200e-01, -2.17316903e-01,
        -8.84140389e-07, -1.45077499e-01, -7.94029131e-08,
         2.25382636e-01, -1.52798788e-01,  1.68808251e-01,
         1.32055340e-02,  9.18396566e-02, -2.58350452e-01,
         2.90111732e-01,  2.22916443e-01, -5.85973625e-02,
        -1.96185275e-01,  2.901711[...]<jupyter_text>Check the accuracy.<jupyter_code>import sklearn.metrics as metric
import numpy as np

accuracy=metric.accuracy_score(np.array(y_test).flatten(), np.array(y_pred).flatten(), normalize=True)
print(accuracy)<jupyter_output>1.0<jupyter_text>Data from Filehttps://pandas.pydata.org/docs/user_guide/index.htmluser-guideA short example how to get the data from a file.<jupyter_code>from sklearn.neural_network import MLPClassifier
from sklearn.model_selection import train_test_split
import pandas as pd
# import the data from the csv file
train = pd.read_csv("iris.csv")
# get the featue names expect the last one
features = train.columns[:-1]
# split the data values correspondingly 
X = train[features]
Y = train['Species']
# create training and test set
X_train, X_test, y_train, y_test = train_test_split(X,Y,test_size=0.5)
# train
nn = MLPClassifier()
a = nn.fit(X_train,y_train)
# Returns the mean accuracy on the given test data and labels. 
nn.score(X_test,y_test)<jupyter_output>C:\Users\testuser\anaconda3\envs\env-IDS2020\lib\site-packages\sklearn\neural_network\_multilayer_perceptron.py:585: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (200) reached and the optimization hasn't converged yet.
  % self.max_iter, ConvergenceWarning)
{'fraction_non_alphanumeric': 0.13104287017330496, 'fraction_numerical': 0.17816965643052599, 'mean_word_length': 4.08500772797527, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 3, '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': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '386004', 'license': 'Apache-2.0', 'n_tokens_mistral': 1669, 'n_tokens_neox': 1348, 'n_words': 237, 'path': 'IDS_2020/NeuralNetwork/NeuralNetworkIsntruction-UsefulLibraries.ipynb', 'repo_name': 'pmnatos/DataScience', 'size': '3289'}