Skip to content

Instantly share code, notes, and snippets.

View MarkDana's full-sized avatar
🎛️
jam

Haoyue Dai MarkDana

🎛️
jam
View GitHub Profile

1. Didn't consider uncentered data.

import causallearn_5a3219e as causallearn
# causallearn before Jun 16, 2022, where local_score_BIC is calculated using inner product
# download at https://github.com/py-why/causal-learn/tree/5a3219efa60f6d60387363358f6a97401d7546ce

from causallearn.utils.GraphUtils import GraphUtils
from causallearn.search.ScoreBased.GES import ges
import matplotlib.image as mpimg
@MarkDana
MarkDana / mbti-16personalities.py
Created November 3, 2022 03:53
Get the result of MBTI personalities from questionnaire answers (by web scrapping or fitted linear sum)
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import json, random, requests, math
from bs4 import BeautifulSoup
import numpy as np
header={
'User-Agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36',
"Content-Type": "application/json; charset=utf-8",
}
@MarkDana
MarkDana / count-unique-in-array-performance.md
Last active June 22, 2022 14:04
count-unique-in-array-performance

Given a non-negative integers array a with different len(a) (scale) and different max(a) (amplitude), what is the most efficient way in Python to count the unique elements in a?

In this experiment, we fix the scale len(a) to be 20000, and focus specifically on the amplitude max(a) of the array.

Here is the code:

def get_runtime_stat(AMPLITUDE:int):
    def _test1():
        counts = np.zeros((AMPLITUDE + 1, ), dtype=np.int32)
@MarkDana
MarkDana / m1-max-numpy-setup.md
Last active October 28, 2023 11:42
Install NumPy on M1 Max

How to install numpy on M1 Max, with the most accelerated performance (Apple's vecLib)? Here's the answer as of Dec 6 2021.


Steps

I. Install miniforge

So that your Python is run natively on arm64, not translated via Rosseta.

  1. Download Miniforge3-MacOSX-arm64.sh, then
  2. Run the script, then open another shell
$ bash Miniforge3-MacOSX-arm64.sh