Skip to content

Instantly share code, notes, and snippets.

View mohdabdin's full-sized avatar

Mohammad Abdin mohdabdin

View GitHub Profile
"""
This script is used to automate the process of sending LinkedIn connection requests and messages to a list of people.
It uses Selenium to automate the process of logging in and sending connection requests and messages.
Author: Mohammad Abdin (https://www.linkedin.com/in/mohammad-abdin-779260147/)
Keep in mind this can break if LinkedIn changes their HTML structure.
"""
import pandas as pd
import yahoo_fin.stock_info as si
df = pd.read_csv('stocks.csv')
final_dic = {}
temp = si.get_quote_table('aapl')
for key in temp:
final_dic.update({key:[]})
for idx, row in df.iterrows():
while True:
try:
# Get Stock Card
card = driver.find_element_by_xpath('/html/body/section/div/div/div[2]/div['+str(count)+']')
# Extract Title
stock_string = card.find_element_by_xpath(".//h6/div/span[2]/strong")
driver.execute_script("return arguments[0].scrollIntoView();", stock_string)
stock = stock_string.get_attribute('innerHTML')
stock_symbol = stock.split()[-1][1:-1]
import pandas as pd
import time
from selenium import webdriver
import selenium.webdriver.common.keys as kl
from selenium.webdriver.common.action_chains import ActionChains
driver = webdriver.Chrome("C:/chromedriver.exe")
driver.set_window_size(1280, 1080)
actions = ActionChains(driver)
import gym
import time
from stable_baselines3 import A2C
def train(env):
env = gym.make('CartPole-v0')
model = A2C('MlpPolicy', env, verbose=1)
model.learn(total_timesteps=20000)
return model
from policy_network import Policy
agent = Policy(obs_dim=4, act_dim=2)
for param in agent.parameters():
print(param.data.shape)
for epoch in range(EPOCHS):
evolved_agents = [] #new population of agents to be populated
# Perform Elitism
for i in range(int(POP_SIZE*ELITISM_RATE)):
evolved_agents.append(population.iloc[i]['agents'])
while len(evolved_agents)<POP_SIZE:
# Perform Selection
parent_a, parent_b = selection(population)
if __name__=='__main__':
#initialize population
agents = []
for _ in range(POP_SIZE):
agent = Policy(obs_dim=NUM_STATES, act_dim=NUM_ACTIONS)
agents.append(agent)
fitness_list = evaluate_agents(env, agents)
population = pd.DataFrame({'agents': agents,
import numpy as np
import pandas as pd
import gym
from evolution_functions import evaluate_agents, crossover, mutate, selection
import torch.nn as nn
import torch as T
from policy_network import Policy
EPOCHS = 100
# Select two parents from population based on fitness
def selection(population):
# Define a probability distribution proportional to each agent's fitness/reward score
fit_sum = sum(population['fitness'])
prob_dist = population['fitness']/fit_sum
# Choose random indices from distribution making sure they're not equal
par_a_idx = 0
par_b_idx = 0
while par_a_idx==par_b_idx: