...
Sample Python Projects
Basic Python projects
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
import mysql.connector
#connecting to a database
con = mysql.connector.connect(
host = "husseinmac",
user = "root",
password = "password",
database = "husseindb",
port = 3306
)
print("Hey, I think I'm connected")
#cursor
cur = con.cursor()
#insert a new row
for i in range(100):
cur.execute("INSERT INTO employees (ID, NAME) VALUES (%s, %s)", (i+10, f'Mark{i}' ))
#execute the query
cur.execute("SELECT ID,NAME FROM employees")
#cur.execute("SELECT ID,NAME FROM employees where NAME = %s", ("Yara",))
rows = cur.fetchall()
for r in rows:
print(f" ID = {r[0]} NAME = {r[1]}")
#commit the transaction
con.commit()
#close the cursor
cur.close()
#close the connection
con.close() |
Simplest Neural Network in Python - Perceptron
In this video I'll show you how an artificial neural network works, and how to make one yourself in Python. In the next video we'll make one that is usable, but if you want, that code can already be found on github. I recommend watching at 1.5x speed, unless you're coding along.
video
Widget Connector | ||
---|---|---|
|
video 2
Widget Connector | ||
---|---|---|
|
https://morioh.com/p/512d41219fda
Github code
https://github.com/jonasbostoen/simple-neural-network
reating a simple neural network in Python with one input layer (3 inputs) and one output neuron. A neural network with no hidden layers is called a perceptron. In the training_version.py I train the neural network in the clearest way possible, but it's not really useable. The outputs of the training can be found in outputs.txt . neural_network.py is an object and can be used by giving in different inputs.
Thanks to Milo Spencer-Harber for this: https://medium.com/technology-invention-and-more/how-to-build-a-simple-neural-network-in-9-lines-of-python-code-cc8f23647ca1
And to Andrew Trask for this: https://iamtrask.github.io/2015/07/12/basic-python-network/
What does it do?
The neural_net.py tries to predict the output given 3 binary inputs. If the first input is 1, the output should be one. Otherwise the output should be 0.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
Potential Value Opportunities
...