<commit_before>from tcga_encoder.utils.helpers import *
from scipy import special
#import numpy as np
import pdb
from sklearn.neighbors import KernelDensity
from sklearn import linear_model

def logistic_sigmoid( activations ):
  return 1.0 / (1.0 + np.exp(-activations) )
  
class NaiveBayesClassifier(object):
  def fit( self, X, y ):
    raise NotImplementedError
  def predict( self, X ):
    raise NotImplementedError

class LogisticRegressionModel( object ):
    
  def get_weights(self):
    return self.w
    
  def fit( self, X, y, one_hot_groups = None ):
    if one_hot_groups is None:
      return self.fit_normal( X, y )
    else:
      return self.fit_grouped( X, y, one_hot_groups )
  
  def fit_normal( self, X, y ):
    self.class_1 = pp.find( y==1 )
    self.class_0 = pp.find( y==0 )
    
    self.model = linear_model.LogisticRegression( penalty='l1', C=1.0 )
    self.model.fit( X, y )
    
    self.pi_1 = len( self.class_1 ) / float(len(y))
    self.pi_0 = 1.0 - self.pi_1<commit_msg>C=100<commit_after>from tcga_encoder.utils.helpers import *
from scipy import special
#import numpy as np
import pdb
from sklearn.neighbors import KernelDensity
from sklearn import linear_model

def logistic_sigmoid( activations ):
  return 1.0 / (1.0 + np.exp(-activations) )
  
class NaiveBayesClassifier(object):
  def fit( self, X, y ):
    raise NotImplementedError
  def predict( self, X ):
    raise NotImplementedError

class LogisticRegressionModel( object ):
    
  def get_weights(self):
    return self.w
    
  def fit( self, X, y, one_hot_groups = None ):
    if one_hot_groups is None:
      return self.fit_normal( X, y )
    else:
      return self.fit_grouped( X, y, one_hot_groups )
  
  def fit_normal( self, X, y ):
    self.class_1 = pp.find( y==1 )
    self.class_0 = pp.find( y==0 )
    
    self.model = linear_model.LogisticRegression( penalty='l1', C=100.0 )
    self.model.fit( X, y )
    
    self.pi_1 = len( self.class_1 ) / float(len(y))
    self.pi_0 = 1.0 - self.pi_1
{'fraction_non_alphanumeric': 0.10806772908366534, 'fraction_numerical': 0.01942231075697211, 'mean_word_length': 3.1252566735112937, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6592921', 'n_tokens_mistral': 739, 'n_tokens_neox': 730, 'n_words': 191}