<commit_before>var nodejs = (typeof window === 'undefined');
if (nodejs) {
	var TestMain = require('../main');
	var AgentSmith = require('../../agent_smith/src/agent_smith');
	require('../../agent_smith/src/agent_smith_cl');
	var AgentSmithML = require('../../src/agent_smith_ml');
	require('../../src/linear_model/linear_model');
	requre('../../src/linear_model/base.js');
	require('../../src/linear_model/logistic');
}

TestMain.Tester.addTest('LogisticTest', [
									   {
										   name : 'Logistic',
											   test : function(callback) {
											   var $M = AgentSmith.Matrix;
											   var logistic = new AgentSmithML.LinearModel.Logistic();

											   var X = $M.fromArray( [[0, 4, 3],
																	  [1, 5, 1],
																	  [2, 8, 2],
																	  [3, 5, 6]] );
											   var y = $M.fromArray( [[1],
																	  [-1],
																	  [1],
																	  [-1]] );
											   var sample = $M.fromArray( [[3, 3, 6],
																	  [2, 8, 2],
																	  [-2, 6, -3]] );

											   logistic.fit(X,y);
											   var pred = logistic.predict(sample);
											   console.log('weight');
											   logistic.weight.print();
											   pred.print();
											   if (pred.nearlyEquals($M.fromArray( [[-2.29, 2.60],
																					[1.23, -0.64],
																					[3.72, 0.82]] ))) {
												   return true;
											   }
											   return false;

										   }
									   },

												 ]);<commit_msg>logreg<commit_after>var nodejs = (typeof window === 'undefined');
if (nodejs) {
	var TestMain = require('../main');
	var AgentSmith = require('../../agent_smith/src/agent_smith');
	require('../../agent_smith/src/agent_smith_cl');
	var AgentSmithML = require('../../src/agent_smith_ml');
	require('../../src/linear_model/linear_model');
	requre('../../src/linear_model/base.js');
	require('../../src/linear_model/logistic');
}

TestMain.Tester.addTest('LogisticTest', [
									   {
										   name : 'Logistic',
											   test : function(callback) {
											   var $M = AgentSmith.Matrix;
											   var logistic = new AgentSmithML.LinearModel.Logistic({eta:0.01, maxIter:1000});

											   var X = $M.fromArray( [[0, 4, 3],
																	  [1, 5, 1],
																	  [2, 8, 2],
																	  [3, 5, 6]] );
											   var y = $M.fromArray( [[1,0],
																	  [0,1],
																	  [1,0],
																	  [0,1]] );
											   var sample = $M.fromArray( [[3, 3, 6],
																	  [2, 8, 2],
																	  [-2, 6, -3]] );

											   logistic.fit(X,y);
											   var pred = logistic.predict(sample);
											   console.log('weight');
											   logistic.weight.print();
											   pred.print();
											   if (pred.nearlyEquals($M.fromArray( [[0.06, 0.94],
																					[0.64, 0.36],
																					[0.99, 0.01]] ))) {
												   return true;
											   }
											   return false;

										   }
									   },

												 ]);
{'fraction_non_alphanumeric': 0.1785831960461285, 'fraction_numerical': 0.031960461285008235, 'mean_word_length': 1.2673637042569081, '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': '4608335', 'n_tokens_mistral': 1656, 'n_tokens_neox': 960, 'n_words': 171}