This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Com.Example.Controllers | |
{ | |
[Authorize] | |
public class HomeController : Controller | |
{ | |
public HomeController() | |
{ | |
} | |
//Use Refresh Token to generate new Access Token |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
'use strict'; | |
angular.module('token.service') | |
.factory('AuthorizationTokenService', AuthorizationTokenService); | |
AuthorizationTokenService.$inject = ['$q', '$injector']; | |
function AuthorizationTokenService($q, $injector) { | |
//Local storage for token | |
var tokenVM = { | |
accessToken: null, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
'use strict'; | |
var core = angular.module('config'); | |
core.config(configure); | |
configure.$inject = ['$httpProvider']; | |
/* @ngInject */ | |
function configure($httpProvider) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
allwords = ""; | |
% - Load and concatenate all the emails in one string | |
Files=dir('data/*/*.txt'); | |
for k=1:length(Files) | |
FileNames = Files(k).name; | |
dr = Files(k).folder; | |
file = fileread(strcat(dr, '\', FileNames)); | |
file = regexprep(file, '\<\w{1,2}\>', ""); | |
allwords = strcat(allwords, ' ', file); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dictionaryList = get_dictionary_list(); | |
#Train Features | |
#Train Labels | |
docId = 1; | |
featureTrain = zeros(1,3); | |
labelTrain = zeros(1,1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
numTrainDocs = 100; | |
numTokens = 2500; | |
% - Load train emails features | |
M = dlmread('train-features.txt', ' '); | |
spmatrix = sparse(M(:, 1), M(:, 2), M(:, 3), numTrainDocs, numTokens); | |
train_matrix = full(spmatrix); | |
% - Load train emails labels | |
train_labels = dlmread('train-labels.txt', ' '); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
N = dlmread('test-features.txt', ' '); | |
test_matrix = sparse(N(:, 1), N(:, 2), N(:, 3)); | |
numTestDocs = size(test_matrix, 1); | |
numTestTokens = size(test_matrix, 2); | |
output = zeros(numTestDocs, 1); | |
% - Probability that one email is spam, number of spam emails divided by number of all emails | |
% - Because the ration of spam - nonspam emails in the training set is 50:50 this probability will be 0.5 (50%) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function data_reshape = getCsvData(filename) | |
%GETCSVDATA load the csv data into cell array | |
fileID = fopen(filename,'r'); | |
% Start row is 1 since the first line is the heading (name of the columns) | |
startRow = 1; | |
data = textscan(fileID, '%d %d\n', 'Delimiter', ';',... | |
'HeaderLines', startRow,'ReturnOnError', false); | |
fclose(fileID); |
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Year;Population | |
2007;9182927 | |
2008;9256347 | |
2009;9340682 | |
2010;9415570 | |
2011;9482855 | |
2012;9555893 | |
2013;9644864 | |
2014;9747355 | |
2015;9851017 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Load Population Data | |
statistics_data = getCsvData('swe_pop_2007_2017.csv'); | |
% Convert cell to matrix | |
X = cell2mat(statistics_data(:,1)); | |
y = cell2mat(statistics_data(:,2)); | |
% Convert matrix values to double | |
X = double(X); | |
y = double(y); |
OlderNewer