Skip to content

Instantly share code, notes, and snippets.

@KhanradCoder
KhanradCoder / symbolic_regression.py
Created September 12, 2023 01:20
rederive newton's law of universal gravitation with pysr
import numpy as np
num_samples=1000
noise = np.random.normal(1,
0.01, #0.001
size=num_samples)
input_vars = np.random.randn(num_samples, 3)
F = noise*(input_vars[:,0]*input_vars[:,1])/(input_vars[:,2]**2)
from pysr import PySRRegressor
<!DOCTYPE html>
<html>
<body>
<h3>x ≡ <input type="number" id="a1"> mod <input type="number" id="m1"></h3>
<br>
<h3>x ≡ <input type="number" id="a2"> mod <input type="number" id="m2"></h3>
<br>
<h3>x ≡ <input type="number" id="a3"> mod <input type="number" id="m3"></h3>
We can make this file beautiful and searchable if this error is corrected: It looks like row 4 should actually have 31 columns, instead of 20. in line 3.
"diagnosis(1=m, 0=b)",radius_mean,texture_mean,perimeter_mean,area_mean,smoothness_mean,compactness_mean,concavity_mean,concave points_mean,symmetry_mean,fractal_dimension_mean,radius_se,texture_se,perimeter_se,area_se,smoothness_se,compactness_se,concavity_se,concave points_se,symmetry_se,fractal_dimension_se,radius_worst,texture_worst,perimeter_worst,area_worst,smoothness_worst,compactness_worst,concavity_worst,concave points_worst,symmetry_worst,fractal_dimension_worst
1,17.99,10.38,122.8,1001,0.1184,0.2776,0.3001,0.1471,0.2419,0.07871,1.095,0.9053,8.589,153.4,0.006399,0.04904,0.05373,0.01587,0.03003,0.006193,25.38,17.33,184.6,2019,0.1622,0.6656,0.7119,0.2654,0.4601,0.1189
1,20.57,17.77,132.9,1326,0.08474,0.07864,0.0869,0.07017,0.1812,0.05667,0.5435,0.7339,3.398,74.08,0.005225,0.01308,0.0186,0.0134,0.01389,0.003532,24.99,23.41,158.8,1956,0.1238,0.1866,0.2416,0.186,0.275,0.08902
1,19.69,21.25,130,1203,0.1096,0.1599,0.1974,0.1279,0.2069,0.05999,0.7456,0.7869,4.585,94.03,0.00615,0.04006,0.03832,0.02058,0.0225
@KhanradCoder
KhanradCoder / user_tweet_downloader.py
Created September 13, 2020 00:48
Download all of a user's tweets
import tweepy
import csv
import time
#Twitter API credentials
consumer_key =
consumer_secret =
access_key =
access_secret =
@KhanradCoder
KhanradCoder / speech_recognition_example.py
Last active March 1, 2024 15:30
Simple implementation of speech recognition in python
# Install speech_recognition with pip install speech_recognition
# Install pyaudio with pip install pyaudio
# Make sure you look up full instructions for installing pyaudio
import speech_recognition as sr
recognizer = sr.Recognizer()
mic = sr.Microphone()
with mic as source:
@KhanradCoder
KhanradCoder / euler-s-method.ipynb
Created April 17, 2020 19:43
Euler's Method.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@KhanradCoder
KhanradCoder / PyDa.py
Created April 11, 2020 01:21
Code for the video where we build a Jarvis like virtual assistant in python 3
import wolframalpha
client = wolframalpha.Client("lilpumpsaysnopeeking")
import wikipedia
import PySimpleGUI as sg
sg.theme('DarkPurple')
layout =[[sg.Text('Enter a command'), sg.InputText()],[sg.Button('Ok'), sg.Button('Cancel')]]
window = sg.Window('PyDa', layout)
@KhanradCoder
KhanradCoder / next_president.tr
Last active September 17, 2020 07:27
TrumpScript poem on who will be the next POTUS
say "roses are red"
say "violets are blue"
make president ""
if , "Trump" is president ? ;
say "Trump is in charge, what will we do?" !
else :
say "If Clinton is in charge, wall street is too" !
@KhanradCoder
KhanradCoder / TinyScreen_KhanWatchOS.ino
Created December 19, 2015 14:55
My edit of a SmartWatch for the TinyScreen with reminders and flappy bird.
// KhanWatchOs 1.0
// KhanWatchOs is a combination and improvement of several arduino programs for
// the TinyDuino TinyScreen
// Main code developed by TinyScreen
// https://codebender.cc/sketch:115936#TinyScreen_SmartWatch_iOS.ino
// Flappy Bird design developed by TinyScreen
// https://codebender.cc/sketch:77043#TinyScreen_FlappyBirds.ino
// Thanks to all for the code, I hope you like my improvements and new features
#define menu_debug_print true