Skip to content

Instantly share code, notes, and snippets.

View primaryobjects's full-sized avatar

Kory Becker primaryobjects

View GitHub Profile
@primaryobjects
primaryobjects / text-analysis.R
Created October 1, 2023 01:26
Text analysis with word frequency, topic modeling using LDA, and word clouds. https://www.coursera.org/learn/applying-data-analytics-business-in-marketing/home/week/3
# Load the rvest package
library(rvest)
library(ggplot2)
library(tidytext)
library(tidyverse)
library(topicmodels)
library(tm)
library(wordcloud)
library(RColorBrewer)
@primaryobjects
primaryobjects / bogleheads-network.R
Last active September 30, 2023 21:08
Network analysis in a connected graph. Building a social network for most influential post authors based on post and replies https://www.coursera.org/learn/applying-data-analytics-business-in-marketing/lecture/7FPYu/network-analysis-with-r-part-2
# Network Analysis with R
# https://www.coursera.org/learn/applying-data-analytics-business-in-marketing/lecture/7FPYu/network-analysis-with-r-part-2
# Create a method in R to extract all posts listed on https://bogleheads.org and return their Author, Title, and Url.
#
# For example, the first result in the list might be:
# Title: Helping elderly parents with diminishing mental capacity
# Author: yakk0
# Url: https://www.bogleheads.org/forum/viewtopic.php?f=2&t=413715&newpost=7484050
@primaryobjects
primaryobjects / zombie.ipynb
Last active September 26, 2023 18:43
Quantum computing zombie simulation
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@primaryobjects
primaryobjects / 1-word-cloud-comparison.Rmd
Last active September 11, 2023 13:08
Word Cloud Comparison Review using Bogleheads.org forum post title web scraping keywords in R https://www.coursera.org/learn/intro-business-analytics
---
title: "Word Cloud Comparison"
author: "Kory Becker"
date: "2023-09-11"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
@primaryobjects
primaryobjects / creature.ipynb
Last active September 12, 2023 14:33
Quantum computing qiskit to generate a magical creature based upon a state vector. Uses DALLE to generate an image.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@primaryobjects
primaryobjects / rps.py
Last active September 8, 2023 17:52
Rock paper scissors quantum computing qiskit using 1 qubit
# Import Qiskit and numpy
from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister, execute, Aer
import numpy as np
# Define the quantum register and the classical register
qreg = QuantumRegister(1)
creg = ClassicalRegister(1)
qc = QuantumCircuit(qreg, creg)
# Define the basis states for rock, paper, and scissors
// Given an input of a dictionary of words and an input senetnce that does not contain spaces, write a method that returns the input sentence split into words.
// Input: "applesauceisfun", ["apple","applesauce","is","good"]
// Output: "applesauce is fun"
const dict = ["apple","applesauce","is","good"];
// Simple approach with indexOf (uses shorter words).
const sentenceSplit = (s, dict) => {
dict.sort((a, b) => { return b.length - a.length }).forEach(word => {
const merge = (nums1, m, nums2, n) => {
let index = m + n - 1; // Pointer to the current index being written to.
let i = m - 1; // Pointer to value to compare in nums1.
let j = n - 1; // Pointer to value to compare in nums2.
// Move from right to left, compare values i, j and write larger at index.
// If no more vaues in nums2, just choose nums1.
while (index >= 0) {
nums1[index--] = j < 0 || nums1[i] > nums2[j] ? nums1[i--] : nums2[j--];
}
@primaryobjects
primaryobjects / longestNiceSubstring.js
Created August 13, 2023 18:56
Longest Nice Substring containing uppercase and lowercase matching letters https://leetcode.com/problems/longest-nice-substring
const longestNiceSubstring = s => {
// Brute-force.
let result = '';
let max = 0;
const adder = 32; // uppercase or lowercase compliment
// Begin building the word from the left and appending 1 character at a time.
for (let i=0; i<s.length-1; i++) {
const hash = {};
let word = s[i];
@primaryobjects
primaryobjects / quiz3.txt
Last active August 4, 2023 02:09
IBM Introduction to Artificial Intelligence, Quiz 3, https://www.coursera.org/learn/introduction-to-ai
QUESTION 1/10
What is Al ethics?
1 point
I How and why an Al system arrived at a particular outcome or recommendation
An organization's act of governing Al through its corporate instructions, staff, processes, and systems
** A multidisciplinary field that investigates how to maximize Al's beneficial impacts while reducing risks and adverse impacts
How to build and use Al in ways that align with human ethics and expectations
QUESTION 2/10
In Al, what is fairness?