<commit_before>//
//  SwiftSimpleNeuralNetworkTests.swift
//  SwiftSimpleNeuralNetworkTests
//
//  Copyright 2016 <NAME>
//
//  Licensed under the Apache License, Version 2.0 (the "License");
//  you may not use this file except in compliance with the License.
//  You may obtain a copy of the License at
//
//  http://www.apache.org/licenses/LICENSE-2.0
//
//  Unless required by applicable law or agreed to in writing, software
//  distributed under the License is distributed on an "AS IS" BASIS,
//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//  See the License for the specific language governing permissions and
//  limitations under the License.


import XCTest

class SwiftSimpleNeuralNetworkTests: XCTestCase {
    
    var network: Network = Network(layerStructure: [1,8,1], learningRate: 8.0)
    
    override func setUp() {
        super.setUp()
        // Put setup code here. This method is called before the invocation of each test method in the class.
        let xos = randomNums(number: 10000, limit: 500)
        let ys = xos.map{[(0.5 * sin(10 * ($0 / 1000)) + 0.5)]}
        let xs = xos.map{[$0 / 1000]}
        network.train(inputs: xs, expecteds: ys, printError: true)
    }
    
    override func tearDown() {
        // Put teardown code here. This method is called after the invocation of each test method in the class.
        super.tearDown()
    }
    
    func testSin() {
        // This is an example of a functional test case.
        // Use XCTAssert and related functions to verify your tests produce the correct results.
        let xos = randomNums(number: 1000, limit: 300)
        let ys = xos.map{ (0.5 * sin(10 * ($0 / 600)) + 0.5) }
        let xs = xos.map{[$0 / 600]}
        let results = network.validate(inputs: xs, expecteds: ys, accuracy: 0.05)
        print("\(results.correct) correct of \(results.total) = \(results.percentage * 100)%")<commit_msg>Cleaned up sin test a little bit.<commit_after>//
//  SwiftSimpleNeuralNetworkTests.swift
//  SwiftSimpleNeuralNetworkTests
//
//  Copyright 2016 <NAME>
//
//  Licensed under the Apache License, Version 2.0 (the "License");
//  you may not use this file except in compliance with the License.
//  You may obtain a copy of the License at
//
//  http://www.apache.org/licenses/LICENSE-2.0
//
//  Unless required by applicable law or agreed to in writing, software
//  distributed under the License is distributed on an "AS IS" BASIS,
//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//  See the License for the specific language governing permissions and
//  limitations under the License.


import XCTest

class SwiftSimpleNeuralNetworkTests: XCTestCase {
    
    var network: Network = Network(layerStructure: [1,6,1], learningRate: 8.0)
    
    override func setUp() {
        super.setUp()
        // Put setup code here. This method is called before the invocation of each test method in the class.
        let xos = randomNums(number: 10000, limit: 500)
        let ys = xos.map{[(0.5 * sin(10 * ($0 / 1000)) + 0.5)]}
        let xs = xos.map{[$0 / 1000]}
        network.train(inputs: xs, expecteds: ys, printError: true)
    }
    
    override func tearDown() {
        // Put teardown code here. This method is called after the invocation of each test method in the class.
        super.tearDown()
    }
    
    func testSin() {
        // This is an example of a functional test case.
        // Use XCTAssert and related functions to verify your tests produce the correct results.
        let xos = randomNums(number: 1000, limit: 500)
        let ys = xos.map{ (0.5 * sin(10 * ($0 / 1000)) + 0.5) }
        let xs = xos.map{[$0 / 1000]}
        let results = network.validate(inputs: xs, expecteds: ys, accuracy: 0.05)
        print("\(results.correct) correct of \(results.total) = \(results.percentage * 100)%")
{'fraction_non_alphanumeric': 0.10828189300411523, 'fraction_numerical': 0.03343621399176955, 'mean_word_length': 2.648217636022514, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4321793', 'n_tokens_mistral': 1238, 'n_tokens_neox': 1129, 'n_words': 443}