# 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
            continue
        # Read class label from first row
        y[rownum] = classes[row[0]]
        featnum = 0
        file_names.append(row[1])
        for featval in row[2:]:
            if featval in classes:
                # Convert booleans to integers
                featval = classes[featval]
            X[rownum, featnum] = float(featval)
            featnum += 1
        rownum += 1
    return X, y, file_names

def numpy2csv(csv_out, X, y, file_names=None):
    '''
    Creates a CSV file from the given data points (X, scipy matrix) and labels 
    (y, numpy.array). The CSV file has a header. The first column is named 
    'class' and the others after PDFrate features. All features are written 
    in their respective type format (e.g., True/False for booleans). 
    
    If 'csv_out' is an open Python file, it will not be reopened. If 
    it is a string, a file will be created with that name. 
    '''
    we_opened_csvfile = type(csv_out) == str
    csvfile = open(csv_out, 'wb+') if we_opened_csvfile else csv_out
    # Write header
    csvfile.write('class')
    if file_names:
        csvfile.write(',filename')

# 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

            continue
        # Read class label from first row
        y[rownum] = classes[row[0]]
        featnum = 0
        file_names.append(row[1])
        for featval in row[2:]:
            if featval in classes:
                # Convert booleans to integers
                featval = classes[featval]
            X[rownum, featnum] = float(featval)
            featnum += 1
        rownum += 1
    return X, y, file_names

def numpy2csv(csv_out, X, y, file_names=None):
    '''
    Creates a CSV file from the given data points (X, scipy matrix) and labels 
    (y, numpy.array). The CSV file has a header. The first column is named 
    'class' and the others after PDFrate features. All features are written 
    in their respective type format (e.g., True/False for booleans). 
    
    If 'csv_out' is an open Python file, it will not be reopened. If 
    it is a string, a file will be created with that name. 
    '''
    we_opened_csvfile = type(csv_out) == str
    csvfile = open(csv_out, 'wb+') if we_opened_csvfile else csv_out
    # Write header
    csvfile.write('class')
    if file_names:
        csvfile.write(',filename')

    names = FeatureDescriptor.get_feature_names()