Skip to content

Instantly share code, notes, and snippets.

View faisalnawazmir's full-sized avatar

Faisal Nawaz faisalnawazmir

View GitHub Profile
  • repo -> repository
  • clone -> bring a repo down from the internet (remote repository like Github) to your local machine
  • add -> track your files and changes with Git
  • commit -> save your changes into Git
  • push -> push your changes to your remote repo on Github (or another website)
  • pull -> pull changes down from the remote repo to your local machine
@faisalnawazmir
faisalnawazmir / 2.py
Created July 30, 2021 06:56 — forked from fnneves/2.py
markowitz
plt.figure(figsize=(12,8))
plt.scatter(vol_arr, ret_arr, c=sharpe_arr, cmap='viridis')
plt.colorbar(label='Sharpe Ratio')
plt.xlabel('Volatility')
plt.ylabel('Return')
plt.scatter(max_sr_vol, max_sr_ret,c='red', s=50) # red dot
plt.show()
@faisalnawazmir
faisalnawazmir / 1.py
Created July 30, 2021 06:54 — forked from fnneves/1.py
medium
np.random.seed(42)
num_ports = 6000
all_weights = np.zeros((num_ports, len(stocks.columns)))
ret_arr = np.zeros(num_ports)
vol_arr = np.zeros(num_ports)
sharpe_arr = np.zeros(num_ports)
for x in range(num_ports):
# Weights
weights = np.array(np.random.random(4))
# coding=UTF-8
import nltk
from nltk.corpus import brown
# This is a fast and simple noun phrase extractor (based on NLTK)
# Feel free to use it, just keep a link back to this post
# http://thetokenizer.com/2013/05/09/efficient-way-to-extract-the-main-topics-of-a-sentence/
# Create by Shlomi Babluki
# May, 2013
# Evaluating 4 Indian English NewsPapers for 10th May 2020 for their
## Vocabulary or No of Unique words per Paragraphs
## Factual Presentation
## Sentimental Analysis
## Graphic content/ images : Needs preprocessing
## Visualising
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
@faisalnawazmir
faisalnawazmir / how-to-install-vscode-on-mxlinux-19.5.md
Created October 7, 2020 14:11 — forked from stardigits/how-to-install-vscode-on-mxlinux-19.5.md
How to Install Visual Studio Code on MX Linux 19.5 (Debian 10)
@faisalnawazmir
faisalnawazmir / An Introduction to Statistical Learning.md
Created September 7, 2020 06:45 — forked from goerz/An Introduction to Statistical Learning.md
PDF bookmarks for "James, Witten, Hastie, Tibshirani - An Introduction to Statistical Learning" (LaTeX)

This gist contains out.tex, a tex file that adds a PDF outline ("bookmarks") to the freely available pdf file of the book

An Introduction to Statistical Learning with Applications in R, by Gareth James, Daniela Witten, Trevor Hastie and Robert Tibshirani

http://www-bcf.usc.edu/~gareth/ISL/index.html

The bookmarks allow to navigate the contents of the book while reading it on a screen.

@faisalnawazmir
faisalnawazmir / knn_impute.py
Created July 31, 2020 15:08 — forked from YohanObadia/knn_impute.py
Imputation of missing values with knn.
import numpy as np
import pandas as pd
from collections import defaultdict
from scipy.stats import hmean
from scipy.spatial.distance import cdist
from scipy import stats
import numbers
def weighted_hamming(data):
#cleaned up original code to work with python 3.6
#results match the output from the python 2.7 version
#filter and map functions have been changed between 3.6 and 2.7
import numpy as np
import pandas as pd
import os
import re
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.metrics.pairwise import euclidean_distances
from sklearn.metrics.pairwise import cosine_similarity