Skip to content

Instantly share code, notes, and snippets.

Avatar

Viktor Pekar vpekar

  • Birmingham, UK
View GitHub Profile
@vpekar
vpekar / document_classification_20newsgroups.py
Last active Mar 13, 2017
Document classification with feature selection using information gain
View document_classification_20newsgroups.py
"""
======================================================
Classification of text documents using sparse features
======================================================
This is an example showing how scikit-learn can be used to classify documents
by topics using a bag-of-words approach. This example uses a scipy.sparse
matrix to store the features and demonstrates various classifiers that can
efficiently handle sparse matrices.
@vpekar
vpekar / plot_compare_reduction.py
Created Nov 3, 2016
Comparing feature selection methods including information gain and information gain ratio
View plot_compare_reduction.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
=================================================================
Selecting dimensionality reduction with Pipeline and GridSearchCV
=================================================================
This example constructs a pipeline that does dimensionality
reduction followed by prediction with a support vector
classifier. It demonstrates the use of GridSearchCV and
@vpekar
vpekar / pttest.py
Last active Sep 1, 2020
A Python implementation of the Directional Accuracy Score and Pesaran-Timmermann statistic.
View pttest.py
import numpy as np
import scipy.stats as stats
def pttest(y, yhat):
"""Given NumPy arrays with predictions and with true values,
return Directional Accuracy Score, Pesaran-Timmermann statistic and its p-value
"""
size = y.shape[0]
pyz = np.sum(np.sign(y) == np.sign(yhat))/size
You can’t perform that action at this time.