示例#1
0
def runAll(path, predictMethodList, predictMethod):
    users = orig.loadAndUpdateFeatures(path)
    featureList = orig.featureList()
    featureList.addByRegex(["action_", "num_of_devices", "total_time"], users)
    category = 'country_destination'
    X_byteDF, y = orig.getXbyte(users, featureList.get(), category)
    return runClf2net(predictMethodList, predictMethod, X_byteDF, y)
示例#2
0
 def __init__(self, args, genes=None, mutationFactor=0.01):
     self.args = args
     featureListClass = orig.featureList()        
     featureListClass.addByRegex(['action_','num_of_devices'],self.args['users'])
     self.featureList = featureListClass.get()
     self.category = 'country_destination'
     self.mutationFactor = mutationFactor
     self.fitScoreNorm = 0
     self.fitScore = 0
     self.fit = 0
     if genes is None :
         self.genes = []
         for i in range(len(self.featureList)):
             if getRandTrueFalse():
                 self.genes.append(self.featureList[i])
     else :
         self.genes = genes
     # self.predictMethod = LogisticRegression()
     self.predictMethod = tree.DecisionTreeClassifier()
 def __init__(self, args, genes=None, mutationFactor=0.01):
     self.args = args
     featureListClass = orig.featureList(
         usersCol=self.args['users'].columns)
     self.featureList = featureListClass.get()
     self.category = 'country_destination'
     self.mutationFactor = mutationFactor
     self.fitScoreNorm = 0
     self.fitScore = 0
     self.fit = 0
     if genes is None:
         self.genes = []
         for i in range(len(self.featureList)):
             if getRandTrueFalse():
                 self.genes.append(self.featureList[i])
     else:
         self.genes = genes
     # self.predictMethod = LogisticRegression()
     self.predictMethod = self.args['predictMethod']
示例#4
0
 def __init__(self, args, genes=None, mutationFactor=0.01):
     self.args = args
     featureListClass = orig.featureList(
         usersCol=self.args['users'].columns)
     self.featureList = featureListClass.get()
     self.category = 'country_destination'
     self.mutationFactor = mutationFactor
     self.fitScoreNorm = 0
     self.fitScore = 0
     self.fit = 0
     self.maxNumOfNurons = 100
     self.minAlpaP2 = -6
     self.maxAlpaP2 = 4
     if genes is None:
         self.genes = self.getRandomGenes()
     else:
         self.genes = genes
     self.predictMethod = MLPClassifier(solver='lbfgs',
                                        alpha=self.genes[0],
                                        hidden_layer_sizes=tuple(
                                            self.genes[1:]))
示例#5
0
# -*- coding: utf-8 -*-
"""
Created on Tue Mar  7 17:37:46 2017

@author: Alon
"""

import basicLib.loadAndTest as orig
from sklearn.neural_network import MLPClassifier
import clfNdfOtherAll as clfAll
from sklearn import tree

users = orig.loadAndUpdateFeatures(
    '../input/users_2014_actions_combined_device.csv')
featureListClass = orig.featureList()
featureListClass.addByRegex(['action_', 'num_of_devices'], users)
featureList = featureListClass.get()
category = 'country_destination'

predictMethod1 = MLPClassifier(solver='lbfgs', alpha=1e-5)
predictMethod2 = MLPClassifier(solver='lbfgs', alpha=1e-5)
predictMethod3 = tree.DecisionTreeClassifier()
clfNdfOtherAllClass = clfAll.clfNdfOtherAll(predictMethod1, predictMethod3)

prediction, fit, y_test = orig.fitPredictAndTest(users,
                                                 featureList,
                                                 category,
                                                 clfNdfOtherAllClass,
                                                 random_state=1)
print(fit)
print(clfNdfOtherAllClass.accuracy_score(y_test))
示例#6
0
# -*- coding: utf-8 -*-
"""
Created on Thu Mar  9 11:33:24 2017

@author: Alon
"""
import featureRapperClf as frc
import basicLib.loadAndTest as orig
from sklearn import tree
import time

predictMethod = tree.DecisionTreeClassifier()
users = orig.loadAndUpdateFeatures('../input/users_2014_sessions_norm.csv')

featureListClass = orig.featureList(usersCol=users.columns)
featureListAll = featureListClass.get()

category = 'country_destination'
featureList = [
    'action_set_password_##_submit_##_set_password',
    'action_authenticate_##_submit_##_login'
]

featureRapper = frc.featureRapperClf(predictMethod, featureList)

startRun = time.clock()
prediction, fit = orig.fitPredictAndTest(users,
                                         featureListAll,
                                         category,
                                         featureRapper,
                                         random_state=1)