Posts

Teaching Computers to Play Tic Tac Toe: A Reinforcement Learning Approach

Image
Teaching Computers to Play Tic Tac Toe: A Reinforcement Learning Approach by Naomi A.  You can see the full code on GitHub: https://github.com/SQLNoggin/Smart-TicTacToe-RL_NaomiA.git This Python script implements a reinforcement learning agent to play the game of Tic Tac Toe. The agent is trained through Q-learning, a type of model-free reinforcement learning that uses a Q-table to estimate the value of taking specific actions in particular states. Let's break down the key aspects:   Overview The script uses the Tkinter library to create a graphical user interface (GUI) where the Tic Tac Toe game can be played. NumPy is used for numerical operations, and the pickle library is used to save and load the Q-table to/from a file. Constant and Hyperparameter Definitions PLAYER_X and PLAYER_O : Constants representing the two players (1 for X and -1 for O). EMPTY : Constant representing an empty cell on the Tic Tac Toe board. ALPHA : The learning rate used in the Q-learning updates. GAMMA

How to Create a Neural Network for Recognizing Hand-Drawn Shapes

Image
How to Create a Neural Network for Recognizing Hand-Drawn Shapes by Naomi A. In this guide, we will walk through the process of developing a neural network that identifies hand-drawn shapes. The tutorial is broken down into three main sections: Preprocessing the hand-drawn shapes. Training a neural network to recognize these shapes. Creating a simple user interface to predict the drawn shapes. All code is available on github under the MIT License. (LINK TO REPO)    1. MNIST Maker: Preprocessing Hand-Drawn Shapes Objective : Convert the images of hand-drawn shapes into a standardized format for machine learning. Steps: Load the images from a specified directory. Convert them to grayscale and resize them to 28x28 pixels. Normalize the pixel values. Label the images based on their filenames. Shuffle and split the data for training, validation, and testing.  SCRIPT for creating the MNIST Dataset: import cv2 import numpy as np import os import random # Path to the shapes directory base_fo

Run Queries in SQL Server Using Python!

Run Queries in SQL Server Using Python! By Naomi A. This is a fairly quick one - all of the info needed on how the script works is in the comments! The full script is ready for download on GitHub: (LINK) # Import the pyodbc module. #This module allows Python to connect to an ODBC database, like SQL Server. import pyodbc # The variables hold the server name, database name, username, and password. # This is necessary in order to connect to the SQL Server database. server = 'ServerName' database = 'DBName' username = 'user' password = 'password' # Connection string: # This is a formatted string that the ODBC driver uses to know who is connecting (username and password), # where they are connecting to (server and database), # and what driver they are using to make the connection (ODBC Driver 17 for SQL Server). connection_string = f 'DRIVER= {{ ODBC Driver 17 for SQL Server }} ;SERVER= { server } ;DATABASE= { database } ;UID= { username } ;PWD