Skip to content

Instantly share code, notes, and snippets.

View Habush's full-sized avatar

Abdulrahman S. Omar Habush

  • Addis Ababa, Ethiopia
View GitHub Profile
@Habush
Habush / plot_emb_pca_projection.py
Last active April 9, 2021 17:57
Plot the embedding of SVD components and their projections in the same subpsace. Inspired by https://europepmc.org/article/pmc/pmc5054124
def plot_emb_projection(X, y=None, ker=tanimoto_v2, alpha=0.5, params=None, annotate=False):
"""
Plot the row vectors of X and features of X in the same embedded space spanned by PCA Components
:param X: the data matrix or dataframe
:param y: the target variable (for labelling)
:param ker: the kernel function to use
:param alpha: the exponent to use for matrix factorization
:return: The pca projects of the row vectors and the columns
"""
@Habush
Habush / fibers_demo.scm
Created April 24, 2020 12:00
A simple demonstration of using fibers for annotation scheme
(define (atomese->graph in out)
(define (expr->graph thing)
(match (cog-type thing)
;; nodes
((or 'PredicateNode
'GeneNode
'MoleculeNode 'ConceptNode) (format #f "~s~%" (cog-name thing)))
;; links
@Habush
Habush / generate-id.scm
Created September 8, 2019 14:44
A simple scheme function to generate unique string ids
(use-modules (rnrs bytevectors))
(import (uuid))
(import (industria base64))
(define generate-id (lambda ()
(let* (
[vecs (bytevector->u8-list (random-uuid))]
[ls (let loop (
(i 0)
(ls '())
@Habush
Habush / parents-func.scm
Last active May 7, 2019 18:28
Finding the parents of a gene recursively
(use-modules (srfi srfi-1))
;;Returns a namespace EvaluationLink of namespaces
(define namespace-eval (lambda (nsp)
(map (lambda (n)
(EvaluationLink
(PredicateNode "GO_namespace")
(ListLink
(VariableNode "$a")
(ConceptNode n)
@Habush
Habush / parent_child_proc.py
Created April 26, 2019 12:35
A simple python script for demonstrating calling the atomspace from different processes
__author__ = 'Abdulrahman Semrie<[email protected]>'
import os
from opencog.scheme_wrapper import scheme_eval, scheme_eval_h
from opencog.atomspace import AtomSpace
from multiprocessing import Pool
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
OPENCOG_DEPS_PATH = os.path.join(PROJECT_ROOT, "opencog_deps")
@Habush
Habush / introrx.md
Created March 6, 2019 17:50 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@Habush
Habush / Program.cs
Created December 22, 2018 14:14
The maximum possible reward is 14.2593 BTC
class Program
{
/// <summary>
/// This problem is an optimization problem specifically 0-1 Knapsack problem which can be solved using dynamic programming approach
/// </summary>
/// <param name="args"></param>
static void Main(string[] args)
{
IList<Tuple<int, int, double>> transactions = new List<Tuple<int, int, double>>();