Skip to content

Instantly share code, notes, and snippets.

@puraminy
puraminy / pca_compress.py
Created January 15, 2020 06:26
PCA image Compress
from sklearn.decomposition import PCA
import scipy.io as sio
import matplotlib.image as image
import matplotlib.image as mpimg
import pandas as pd
import matplotlib.pyplot as plt
import cv2
import numpy as np
import math
import operator
@puraminy
puraminy / face_recog.py
Created January 2, 2020 17:24
Image compression using PCA
from sklearn.decomposition import PCA
import scipy.io as sio
import matplotlib.image as image
import matplotlib.image as mpimg
import pandas as pd
import matplotlib.pyplot as plt
import cv2
import numpy as np
import math
import operator
@puraminy
puraminy / whitenning.py
Last active December 30, 2019 12:38
Eigen vector Whitening
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from numpy import array
from numpy import mean
from numpy import cov
from numpy.linalg import eig, svd
@puraminy
puraminy / tf_idf.py
Created December 25, 2019 17:00
Calculate TF-IDF
import nltk, re, pprint
from nltk import word_tokenize
import numpy as np
import pandas as pd
import heapq
import string
from sklearn.naive_bayes import GaussianNB
from sklearn.linear_model import LogisticRegression
@puraminy
puraminy / lda.py
Last active December 24, 2019 20:27
LDA (Linear Discrimination Analysis)
import numpy as np
import pandas as pd
from sklearn.metrics import confusion_matrix
from sklearn.metrics import accuracy_score
from sklearn import preprocessing
from sklearn.neighbors import KNeighborsClassifier
from sklearn.neighbors import RadiusNeighborsClassifier
from sklearn.naive_bayes import GaussianNB
import matplotlib.pyplot as plt
@puraminy
puraminy / pca_feature_selection.py
Last active December 24, 2019 18:28
PCA for feature selection
import numpy as np
import pandas as pd
from sklearn.metrics import confusion_matrix
from sklearn.metrics import accuracy_score
from sklearn import preprocessing
from sklearn.neighbors import KNeighborsClassifier
from sklearn.neighbors import RadiusNeighborsClassifier
from sklearn.naive_bayes import GaussianNB
import matplotlib.pyplot as plt
@puraminy
puraminy / forward_feature_selection.py
Last active December 23, 2019 07:04
Forward Feature Selection in Machine Learning
import numpy as np
import pandas as pd
from sklearn.metrics import confusion_matrix
from sklearn.metrics import accuracy_score
from sklearn import preprocessing
from sklearn.neighbors import KNeighborsClassifier
from sklearn.neighbors import RadiusNeighborsClassifier
from sklearn.naive_bayes import GaussianNB
import matplotlib.pyplot as plt
@puraminy
puraminy / classifier.py
Last active December 22, 2019 21:00
classifiers (KNN, Bayes, Parzen)
import numpy as np
from sklearn import preprocessing
from sklearn.metrics import accuracy_score
from sklearn.metrics import confusion_matrix
import matplotlib.pyplot as plt
import itertools
import seaborn as sn
from sklearn.metrics import confusion_matrix, classification_report, accuracy_score, f1_score
import matplotlib.pyplot as plt
@puraminy
puraminy / bayes-classifier-gaussian.py
Last active December 19, 2019 21:08
Bayes Classifier Gaussian
import numpy as np
from scipy.stats import multivariate_normal
from sklearn.feature_selection import VarianceThreshold
from sklearn.metrics import accuracy_score
import seaborn as sn
from sklearn.metrics import confusion_matrix, classification_report, accuracy_score, f1_score
import matplotlib.pyplot as plt
from sklearn import preprocessing
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import networkx as nx
df = pd.DataFrame(np.zeros((5,14)), columns = ['علی','مدرسه', 'را', 'دوست','دار',
'برای','او','زندان', 'است', 'کمی','در','درس','خوان', 'بازیگوش'])
s1 = 'علی مدرسه را دوست دار'