# Path: mimicus/tools/featureedit.py
# class FeatureDescriptor(object):
#     '''
#     A class containing descriptions of PDFrate features. 
#     '''
#     
#     @staticmethod
#     def get_feature_count():
#         return 135
#     
#     @staticmethod
#     def get_feature_name(i):
#         '''
#         Returns the i-th feature name. 
#         '''
#         return copy.copy(_pdfrate_feature_names[i])
#     
#     @staticmethod
#     def get_feature_names():
#         '''
#         Returns a sorted list of feature names. 
#         '''
#         return copy.copy(_pdfrate_feature_names)
#     
#     @staticmethod
#     def get_feature_description(feat):
#         '''
#         Returns the description of the given feature as defined by the 
#         FeatureDescriptor.get_feature_descriptions() method. 
#         
#         feat - name or index of the feature
#         '''
#         feat_name = FeatureDescriptor.get_feature_names()[feat] if type(feat) == int else feat
#         return copy.copy(_pdfrate_feature_descriptions[feat_name])
#     
#     @staticmethod
#     def get_feature_descriptions():
#         '''
#         For every feature, a dictionary is returned describing that feature:
#         its type ('type'), whether it may be altered or not ('edit', with the 
#         values 'y' if altering is implemented, 'n' if it's impossible to 
#         alter and 'm' if altering is not directly implemented, but the 
#         feature value might change by modifying some other features) and 
#         the range ('range') within which it may be altered as a tuple of 
#         lower and upper bound (FileDefined means that this lower or upper 
#         bound cannot be modified further than what is currently in the file). 
#         The range represents actual minimum and maximum values seen in the 
#         Contagio dataset. 
#         '''
#         return copy.copy(_pdfrate_feature_descriptions)
# 
#     @staticmethod
#     def get_feature_mask_numpy():
#         '''
#         Returns a numpy array with 1 for every feature which is modifiable, 
#         otherwise 0. 
#         '''
#         return numpy.array([1 if _pdfrate_feature_descriptions[name]['edit'] == 'y' else 0 for name in _pdfrate_feature_names])


import csv
import numpy
from sklearn.preprocessing import StandardScaler
from mimicus.tools.featureedit import FeatureDescriptor
datasets.py

Created on Jun 4, 2013
'''




def csv2numpy(csv_in):
    '''
    Parses a CSV input file and returns a tuple (X, y) with 
    training vectors (numpy.array) and labels (numpy.array), respectfully. 
    
    csv_in - name of a CSV file with training data points; 
                the first column in the file is supposed to be named 
                'class' and should contain the class label for the data 
                points; the second column of this file will be ignored 
                (put data point ID here). 
    '''
    # Parse CSV file
    csv_rows = list(csv.reader(open(csv_in, 'rb')))
    classes = {'FALSE':0, 'TRUE':1}
    rownum = 0
    # Count exact number of data points
    TOTAL_ROWS = 0
    for row in csv_rows:
        if row[0] in classes:
            # Count line if it begins with a class label (boolean)
            TOTAL_ROWS += 1
    # X = vector of data points, y = label vector

# Path: mimicus/tools/featureedit.py
# class FeatureDescriptor(object):
#     '''
#     A class containing descriptions of PDFrate features. 
#     '''
#     
#     @staticmethod
#     def get_feature_count():
#         return 135
#     
#     @staticmethod
#     def get_feature_name(i):
#         '''
#         Returns the i-th feature name. 
#         '''
#         return copy.copy(_pdfrate_feature_names[i])
#     
#     @staticmethod
#     def get_feature_names():
#         '''
#         Returns a sorted list of feature names. 
#         '''
#         return copy.copy(_pdfrate_feature_names)
#     
#     @staticmethod
#     def get_feature_description(feat):
#         '''
#         Returns the description of the given feature as defined by the 
#         FeatureDescriptor.get_feature_descriptions() method. 
#         
#         feat - name or index of the feature
#         '''
#         feat_name = FeatureDescriptor.get_feature_names()[feat] if type(feat) == int else feat
#         return copy.copy(_pdfrate_feature_descriptions[feat_name])
#     
#     @staticmethod
#     def get_feature_descriptions():
#         '''
#         For every feature, a dictionary is returned describing that feature:
#         its type ('type'), whether it may be altered or not ('edit', with the 
#         values 'y' if altering is implemented, 'n' if it's impossible to 
#         alter and 'm' if altering is not directly implemented, but the 
#         feature value might change by modifying some other features) and 
#         the range ('range') within which it may be altered as a tuple of 
#         lower and upper bound (FileDefined means that this lower or upper 
#         bound cannot be modified further than what is currently in the file). 
#         The range represents actual minimum and maximum values seen in the 
#         Contagio dataset. 
#         '''
#         return copy.copy(_pdfrate_feature_descriptions)
# 
#     @staticmethod
#     def get_feature_mask_numpy():
#         '''
#         Returns a numpy array with 1 for every feature which is modifiable, 
#         otherwise 0. 
#         '''
#         return numpy.array([1 if _pdfrate_feature_descriptions[name]['edit'] == 'y' else 0 for name in _pdfrate_feature_names])


# Path: mimicus/tools/datasets.py
import csv
import numpy
from sklearn.preprocessing import StandardScaler
from mimicus.tools.featureedit import FeatureDescriptor

datasets.py

Created on Jun 4, 2013
'''




def csv2numpy(csv_in):
    '''
    Parses a CSV input file and returns a tuple (X, y) with 
    training vectors (numpy.array) and labels (numpy.array), respectfully. 
    
    csv_in - name of a CSV file with training data points; 
                the first column in the file is supposed to be named 
                'class' and should contain the class label for the data 
                points; the second column of this file will be ignored 
                (put data point ID here). 
    '''
    # Parse CSV file
    csv_rows = list(csv.reader(open(csv_in, 'rb')))
    classes = {'FALSE':0, 'TRUE':1}
    rownum = 0
    # Count exact number of data points
    TOTAL_ROWS = 0
    for row in csv_rows:
        if row[0] in classes:
            # Count line if it begins with a class label (boolean)
            TOTAL_ROWS += 1
    # X = vector of data points, y = label vector

    X = numpy.array(numpy.zeros((TOTAL_ROWS, FeatureDescriptor.get_feature_count())), dtype=numpy.float64, order='C')