Skip to content

Instantly share code, notes, and snippets.

python examples/model_selection/grid_search_text_feature_extraction.py 

==========================================================
Sample pipeline for text feature extraction and evaluation
==========================================================

The dataset used in this example is the 20 newsgroups dataset which will be
automatically downloaded and then cached and reused for the document
classification example.

Test script

from __future__ import division, print_function                                                 
                                                                                                
import platform                                                                                 
import sys                                                                                      
                                                                                                
from time import time                                                                           
                                                                                                
import numpy as np
from sklearn.preprocessing import QuantileTransformer
X = np.array([0] * 1 + [0.5] * 7 + [1] * 2).reshape(-1, 1)
qt = QuantileTransformer(n_quantiles=10)
qt.fit(X)
# a behaviour which is not desired, but that frankly should
"""
This is real case using the data of the Adult Census dataset available at:
https://archive.ics.uci.edu/ml/datasets/Adult
It will show that adding a smoothing noise do not has any influence on the
classification performance but allow for a better understanding when manually
checking the QuantileTransformer.
"""
import numpy as np
import pandas as pd
@glemaitre
glemaitre / sprint_tags.md
Last active June 3, 2017 11:42
Issues and PRs which need some love
from skcycling.data_management import Rider                                                                          
                                                                                                                     
filename = '../data/rider/user_5.p'                                                                                  
my_rider = Rider.load_from_pickles(filename)                                                                         
print('This rider has {} rides.'.format(len(my_rider.rides_pp_)))
def rep_boitier_inertiel(Ax, Ay, Az, q0, q1, q2, q3):
"""TODO: Docstring for rep_boitier_inertiel.
:Ax: Acc lin x
:Ay: Acc lin y
:Az: Acc lin z
:q0: quat q0
:q1: quat q1
:q2: quat q2
:q3: quat q3
:returns: array Ax, Ay, Az corrigé dans l'espace
#cython: cdivision=True
#cython: boundscheck=False
#cython: nonecheck=False
#cython: wraparound=False
from libc.stdlib cimport malloc, free, realloc
import numpy as np
from ..transform import integral_image
from abc import ABCMeta, abstractmethod
from random import randint
import six
class BaseChiffrement(six.with_metaclass(ABCMeta)):
@staticmethod
def _check_input(texte, cle):
# --- ploting the original angles ---#
fig, xxx = plt.subplots(nrows=3, ncols=2, figsize=(18, 10), sharex=True)
((ax0, ax1), (ax2, ax3), (ax4, ax5)) = xxx
ax0.plot(imu_eG[:, 0], '-', c='k', linewidth=3, label='GT', alpha=0.8)
ax0.plot(pre_angle[:, 0], ':', lw=2,
label=r'No noise$= {:1.3f} \pm {:1.3f}$'.format(0.087, 0.078))
ax0.plot(pre_angle[:, 0] + np.random.random(pre_angle[:, 0].shape) - 0.5, '-.', lw=2,
label=r'Noisy$= {:1.3f} \pm {:1.3f}$'.format(0.087, 0.078))