Skip to content
Snippets Groups Projects
Commit 1001a87d authored by s183919's avatar s183919
Browse files

Added neural network

parent c8c28e2a
No related branches found
No related tags found
No related merge requests found
# -*- coding: utf-8 -*-
"""
Created on Thu Jan 17 12:03:45 2019
@author: madsl
"""
from matplotlib import pyplot
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
x = np.array([[0.916694553016232, 0.879860173448982, 0.799823725246787], [0.251044893589751, 0.873483597741251, 0.799020036424031], [0.462848690300581, 0.570089266302553, 0.963221106731452], [0.336997448954343, 0.657334680563338, 0.0171789134476452], [0.121086166021466, 0.130820525948952, 0.277826792025607], [0.64818993287732, 0.345999487135878, 0.760489988694125], [0.327718637630705, 0.941325191867006, 0.543913596656697], [0.621508539244741, 0.267934790137423, 0.552943486206798], [0.33562988105478, 0.238357195987091, 0.92325115784734], [0.904787263273107, 0.47550237736589, 0.321083923098015], [0.887495693968907, 0.521172743131916, 0.666699111497533], [0.809760732275199, 0.939246719545988, 0.619447059854184], [0.96334309515959, 0.715781701957867, 0.7167483209566], [0.292157918101503, 0.537154690195954, 0.294120879952536], [0.243359080627646, 0.621222624133338, 0.991719830724062], [0.282109470818913, 0.798695126176517, 0.2795964231394], [0.5099087154142, 0.085685256183095, 0.0813250582634212], [0.34839099324059, 0.659008323432175, 0.717688325188482], [0.578316524545624, 0.783928232007116, 0.102188830100146], [0.901955098332335, 0.691511793902777, 0.441573684419181], [0.508575025963998, 0.0172277393866976, 0.978457495142924], [0.729439273613732, 0.763488989931359, 0.637269107209062], [0.146213011579791, 0.544061425421207, 0.64239874029629], [0.721389284270231, 0.171547132053126, 0.49790269347574], [0.603125573862254, 0.597774348854729, 0.436249236751353], [0.371914772276304, 0.58161838994962, 0.710105866266908], [0.113970116379024, 0.117607382692026, 0.330556847947531], [0.419838871597587, 0.228498726165025, 0.802551483799235], [0.875401252278416, 0.253849786187848, 0.482724764048467], [0.970374641007221, 0.628231193564876, 0.0447240727947193]])
y = np.array([0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0])
fig = pyplot.figure()
ax = Axes3D(fig)
ax.set_facecolor((1.0, 0.47, 0.42))
for n in range(len(x)):
if y[n] == 0:
ax.scatter(x[n,0], x[n,1], x[n,2], c="black")
elif y[n] == 1:
ax.scatter(x[n,0], x[n,1], x[n,2], c="white")
ax.set_xlabel('R', fontsize = 15)
ax.set_ylabel('B', fontsize = 15)
ax.set_zlabel('G', fontsize = 15)
pyplot.show()
\ No newline at end of file
import matplotlib.pyplot as plt
from sklearn.datasets import *
from sklearn.neural_network import MLPClassifier
X = [[0.729411764705882, 0.647058823529412, 0.945098039215686], [0.482352941176471, 0.443137254901961, 0.0862745098039216], [0.643137254901961, 0.525490196078431, 0.313725490196078], [0.462745098039216, 0.933333333333333, 0.501960784313725], [0.588235294117647, 0.168627450980392, 0.768627450980392], [0.854901960784314, 0.635294117647059, 0.462745098039216], [0.580392156862745, 0.588235294117647, 0.305882352941176], [0.0666666666666667, 0.717647058823529, 0.0901960784313725], [0.133333333333333, 0.627450980392157, 0.0862745098039216], [0.16078431372549, 0.415686274509804, 0.125490196078431], [0.219607843137255, 0.52156862745098, 0.431372549019608], [0.556862745098039, 0.525490196078431, 0.611764705882353], [0.227450980392157, 0.741176470588235, 0.286274509803922], [0.176470588235294, 0.376470588235294, 0.466666666666667], [0.752941176470588, 0.0705882352941176, 0.541176470588235], [0.572549019607843, 0.227450980392157, 0.588235294117647], [0.862745098039216, 0.549019607843137, 0.654901960784314], [0.945098039215686, 0.490196078431373, 0.274509803921569], [0.749019607843137, 0.556862745098039, 0.780392156862745], [0.654901960784314, 0.937254901960784, 0.796078431372549], [0.890196078431372, 0.525490196078431, 0.101960784313725], [0.768627450980392, 0.670588235294118, 0.2], [0.905882352941176, 0.443137254901961, 0.654901960784314], [0.43921568627451, 0.56078431372549, 0.0509803921568627], [0.235294117647059, 0.552941176470588, 0.717647058823529], [0.105882352941176, 0.858823529411765, 0.788235294117647], [0.341176470588235, 0.101960784313725, 0.0823529411764706], [0.780392156862745, 0.745098039215686, 0.180392156862745], [0.741176470588235, 0.392156862745098, 0.976470588235294], [0.517647058823529, 0.258823529411765, 1], [0.854901960784314, 0.580392156862745, 0.101960784313725], [0.858823529411765, 0.211764705882353, 0.737254901960784], [0.968627450980392, 0.2, 0.419607843137255], [0.698039215686274, 0.380392156862745, 0.517647058823529], [0.905882352941176, 0.0196078431372549, 0.988235294117647], [0.372549019607843, 0.419607843137255, 0.0470588235294118], [0.945098039215686, 0.635294117647059, 0.27843137254902], [0.47843137254902, 0.427450980392157, 0.729411764705882], [0.188235294117647, 0.976470588235294, 0.172549019607843], [0.309803921568627, 0.662745098039216, 0.56078431372549], [0.745098039215686, 0.0196078431372549, 0.215686274509804], [0.00784313725490196, 0.0313725490196078, 0.345098039215686], [0.341176470588235, 0.411764705882353, 0.850980392156863], [0.611764705882353, 0.254901960784314, 0.52156862745098], [0.266666666666667, 0.858823529411765, 0.925490196078431], [0.980392156862745, 0.647058823529412, 0.933333333333333], [0.447058823529412, 0.137254901960784, 0.635294117647059], [0.333333333333333, 0.603921568627451, 0.890196078431372], [0.670588235294118, 0.909803921568627, 0.462745098039216], [0.831372549019608, 0.16078431372549, 0.619607843137255], [0.192156862745098, 0.0784313725490196, 0.231372549019608], [0.713725490196078, 0.529411764705882, 0.976470588235294], [0.203921568627451, 0.749019607843137, 0.980392156862745], [0.87843137254902, 0.368627450980392, 0.356862745098039], [0.913725490196078, 0.952941176470588, 0.498039215686275], [0.0666666666666667, 0.929411764705882, 0.266666666666667], [0.784313725490196, 0.486274509803922, 0.152941176470588], [0.117647058823529, 0.741176470588235, 0.894117647058824], [0.776470588235294, 0.466666666666667, 0.533333333333333], [0.133333333333333, 0.254901960784314, 0.494117647058824], [0.635294117647059, 0.294117647058824, 0.882352941176471], [0.627450980392157, 0.470588235294118, 0.47843137254902], [0.592156862745098, 0.815686274509804, 0.145098039215686], [0.290196078431373, 0.333333333333333, 0.262745098039216], [0.0392156862745098, 0.552941176470588, 0.847058823529412], [0.725490196078431, 0.835294117647059, 0.164705882352941], [0.619607843137255, 0.882352941176471, 0.945098039215686], [0.36078431372549, 0.807843137254902, 0.0823529411764706], [0.498039215686275, 0.941176470588235, 0.509803921568627], [0.572549019607843, 0.733333333333333, 0.72156862745098], [0.0745098039215686, 0.113725490196078, 0.623529411764706], [0.533333333333333, 0.325490196078431, 0.00784313725490196], [0.752941176470588, 0.811764705882353, 0.917647058823529], [0.180392156862745, 0.2, 0.941176470588235], [0.27843137254902, 0.909803921568627, 0.156862745098039], [0.133333333333333, 0.650980392156863, 0.258823529411765], [0.250980392156863, 0.588235294117647, 0.435294117647059], [0.898039215686275, 0.729411764705882, 0.294117647058824], [0.631372549019608, 0.0392156862745098, 0.717647058823529], [0.564705882352941, 0.392156862745098, 0.541176470588235], [0.317647058823529, 0.596078431372549, 0.4], [0.133333333333333, 0.274509803921569, 0.474509803921569], [0.749019607843137, 0.164705882352941, 0.713725490196078], [0.305882352941176, 0.749019607843137, 0.533333333333333], [0.145098039215686, 0.647058823529412, 0.356862745098039], [0.925490196078431, 0.243137254901961, 0.972549019607843], [0.890196078431372, 0.286274509803922, 0.749019607843137], [0.227450980392157, 0.509803921568627, 0.929411764705882], [0.823529411764706, 0.686274509803922, 0.631372549019608], [0.0901960784313725, 0.125490196078431, 0.113725490196078], [0.423529411764706, 0.498039215686275, 0.266666666666667], [0.780392156862745, 0.682352941176471, 0.176470588235294], [0.00392156862745098, 0.682352941176471, 0.607843137254902], [0.725490196078431, 0.556862745098039, 0.215686274509804], [0.443137254901961, 0.0666666666666667, 0.823529411764706], [0.713725490196078, 0.980392156862745, 0.882352941176471], [0.988235294117647, 0.36078431372549, 0.83921568627451], [0.486274509803922, 0.792156862745098, 0.235294117647059], [0.482352941176471, 0.603921568627451, 0.447058823529412], [0.592156862745098, 0.152941176470588, 0.733333333333333]]
y = [0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1]
clf = MLPClassifier(solver='lbfgs', alpha=1e-5, hidden_layer_sizes=(5, 2), random_state=1)
clf.fit(X, y)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment