added neural networks

This commit is contained in:
Morten Hjorth-Jensen
2021-10-08 07:33:08 +02:00
parent 62b974ad8d
commit 4c2b4a9f57
68 changed files with 1933 additions and 1742 deletions
+15
View File
@@ -1200,6 +1200,21 @@ print("Test set accuracy with Logistic Regression for AND gate: {:.2f}".format(l
Not exactly impressive, but somewhat better.
!split
===== Adding Neural Networks =====
!bc pycod
# and now neural networks with Scikit-Learn and the XOR
from sklearn.neural_network import MLPClassifier
from sklearn.datasets import make_classification
X, yXOR = make_classification(n_samples=100, random_state=1)
FFNN = MLPClassifier(random_state=1, max_iter=300).fit(X, yXOR)
FFNN.predict_proba(X)
print(f"Test set accuracy with Feed Forward Neural Network for XOR gate:{FFNN.score(X, yXOR)}")
!ec