- Slides
- Video
Stuart McMurray:
import os | |
import numpy as np | |
from sklearn.metrics import log_loss | |
""" | |
- HARDCODED FORMULAE | |
- In this gist, we shall almost always use probabilities and not unscaled logits | |
""" | |
## BINARY CLASS CROSS ENTROPY | |
y_true = [0,0,0,1] # 4 observations |
Stuart McMurray:
import itertools | |
class Board(object): | |
def __init__(self): | |
self.rows = [[' ', ' ', ' '], [' ', ' ', ' '], [' ', ' ', ' ']] | |
@property | |
def diagonals(self): |
#Implementation of Two Player Tic-Tac-Toe game in Python. | |
''' We will make the board using dictionary | |
in which keys will be the location(i.e : top-left,mid-right,etc.) | |
and initialliy it's values will be empty space and then after every move | |
we will change the value according to player's choice of move. ''' | |
theBoard = {'7': ' ' , '8': ' ' , '9': ' ' , | |
'4': ' ' , '5': ' ' , '6': ' ' , | |
'1': ' ' , '2': ' ' , '3': ' ' } |
def display_board(board): | |
for i in range(3): | |
print " ", | |
for j in range(3): | |
if board[i*3+j] == 1: | |
print 'X', | |
elif board[i*3+j] == 0: |
#!/usr/bin/python3 | |
# Simple TicTacToe game in Python - EAO | |
import random | |
import sys | |
board=[i for i in range(0,9)] | |
player, computer = '','' | |
# Corners, Center and Others, respectively | |
moves=((1,7,3,9),(5,),(2,4,6,8)) |
# simpleLP1.py | |
# Python 2.7.6 | |
""" | |
Python script to solve Linear Programming problems | |
Uses Pulp library | |
Problem statement: (src - http://fisher.osu.edu/~croxton.4/tutorial/) | |
1) Objective Function - |
import random | |
def rps(n,x,y): | |
print('-----------------------') | |
print('Rock, Paper, Scissors!!') | |
mode = int(input('(1) Vs. Computer (2) Multiplayer')) | |
if mode == 1: | |
print('Wins: ' + str(n)) | |
user = str(input('Rock (R/r), Paper (P/p) or Scissors (S/s)?')).lower() |
import random | |
score = 0 | |
choice = ["rock","scissors","paper"] | |
x = random.choice(choice) | |
def rockpaperscissors(): | |
print(score) | |
user1 = input("Choose rock, scissors or paper") | |
if (x == "rock" and user1 == "rock") or (x == "paper" and user1 == "paper") or (x == "scissors" and user1 == "scissors"): | |
print ("tie") |
# This program is a simulation of the spread of Covid-19 in a country. | |
print("This Program is dedicated to a project i did back in 2020 for a Challenge called the 300 Innovation Challenge") | |
# Asking the user to input the number of people who have Covid in their country. | |
cases=int(input("How many people have Covid in your country")) | |
# Creating a list of the number of cases for each day. | |
future=[cases] | |
# This code is taking the number of cases on a given day and multiplying it by a factor of 2.5. | |
if cases<30000: | |
for x in range(0,50): | |
print("day",x,"cases",future[x]) |