<commit_before>{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "import correlation_matrix as co\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[ 0.33  0.46 -0.41  0.55 -0.03  0.61  0.47  0.06]\n"
     ]
    }
   ],
   "source": [
    "data_file = open('historical_factors.csv', 'r')\n",
    "matrix = np.loadtxt(data_file, skiprows=1,usecols=(2,3,4,5,6,7,8,9,10))\n",
    "cor = co.Cor_matrix(matrix)\n",
    "factor = np.array(cor[0,1:])[0]\n",
    "print(factor)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {
    "collapsed": false,
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Country \t Cal \t Bib \t Dif\n",
      "Algeria_1983 \t 3.0 \t 1.0 \t 2.0\n",
      "Argent_1978 \t 2.0 \t 2.0 \t 0.0\n",
      "Austral_1961 \t 2.0 \t 2.0 \t 0.0\n",
      "Brazil_1978 \t 2.0 \t 2.0 \t 0.0\n",
      "China_1955 \t 2.0 \t 2.0 \t 0.0\n",
      "Egypt_1965 \t 2.0 \t 2.0 \t 0.0\n",
      "France_1954 \t 2.0 \t 2.0 \t 0.0\n",
      "India_1964 \t 3.0 \t 2.0 \t 1.0\n",
      "Indones_1965 \t 1.0 \t 1.0 \t 0.0\n",
      "Iran_1985 \t 3.0 \t 2.0 \t 1.0\n",
      "Iraq_1983 \t 2.0 \t 2.0 \t 0.0\n",
      "Israel_1960 \t 2.0 \t 2.0 \t 0.0\n",
      "Libya_1970 \t 2.0 \t 2.0 \t 0.0\n",
      "N-Korea_1980 \t 3.0 \t 2.0 \t 1.0\n",
      "S-Korea_1970 \t 1.0 \t 2.0 \t -1.0\n",
      "Pakist_1972 \t 2.0 \t 2.0 \t 0.0\n",
      "Romania_1985 \t 2.0 \t 1.0 \t 1.0\n",
      "S-Afric_1974 \t 2.0 \t 2.0 \t 0.0\n",
      "Sweden_1946 \t 1.0 \t 1.0 \t 0.0\n",
      "Switz_1946 \t 1.0 \t 1.0 \t 0.0\n",
      "Syria_2000 \t 2.0 \t 2.0 \t 0.0\n",
      "UK_1947 \t 1.0 \t 2.0 \t -1.0\n",
      "USSR_1945 \t 3.0 \t 2.0 \t 1.0\n",
      "China_1964 \t 2.0 \t 3.0 \t -1.0\n",
      "France_1960 \t 2.0 \t 3.0 \t -1.0\n",
      "India_1988 \t 2.0 \t 3.0 \t -1.0\n",
      "Israel_1969 \t 3.0 \t 3.0 \t 0.0\n",
      "N-Korea_2006 \t 3.0 \t 3.0 \t 0.0\n",
      "Pakist_1987 \t 3.0 \t 3.0 \t 0.0\n",
      "S-Afric_1979 \t 3.0 \t 3.0 \t 0.0\n",
      "UK_1952 \t 2.0 \t 3.0 \t -1.0\n",
      "US_1945 \t 2.0 \t 3.0 \t -1.0\n",
      "USSR_1949 \t 3.0 \t 3.0 \t 0.0\n",
      "Belarus_2015 \t 1.0 \t 0.0 \t 1.0\n",
      "Germany_2015 \t 1.0 \t 0.0 \t 1.0\n",
      "Japan_2015 \t 1.0 \t 0.0 \t 1.0\n",
      "Armenia_2015 \t 1.0 \t 0.0 \t 1.0\n",
      "Belgium_2015 \t -0.0 \t 0.0 \t -0.0\n",
      "Bulgar_2015 \t 0.0 \t 0.0 \t 0.0\n",
      "Canada_2015 \t 0.0 \t 0.0 \t 0.0\n",
      "Czech-R_2015 \t 0.0 \t 0.0 \t 0.0\n",
      "Finland_2015 \t 1.0 \t 0.0 \t 1.0\n",
      "Hungary_2015 \t 0.0 \t 0.0 \t 0.0\n",
      "Kazak_2015 \t 1.0 \t 0.0 \t 1.0\n",
      "Lithua_2015 \t 1.0 \t 0.0 \t 1.0\n",
      "Mexico_2015 \t 1.0 \t 0.0 \t 1.0\n",
      "Nether_2015 \t 1.0 \t 0.0 \t 1.0\n",
      "Saudi-A_2015 \t 2.0 \t 0.0 \t 2.0\n",
      "Slovak_2015 \t 0.0 \t 0.0 \t 0.0\n",
      "Spain_2015 \t 0.0 \t 0.0 \t 0.0\n",
      "Ukraine_2015 \t 1.0 \t 0.0 \t 1.0\n",
      "UAE_2015 \t 2.0 \t 0.0 \t 2.0\n"
     ]
    }
   ],
   "source": [
    "data_file = open('historical_factors.csv', 'r')\n",
    "lines = data_file.readlines()\n",
    "print( 'Country \\t Cal \\t Bib \\t Dif')\n",
    "for line in lines[1:]:\n",
    "    words = line.split('\\t');\n",
    "    name = words[0] + '_' + words[1]\n",
    "    weight = words[3:]\n",
    "    weight = [float(i) for i in weight]\n",
    "    score = co.Compute_Score(weight,factor)\n",
    "    cal_sc = round((score+1.88974910524)/(20.0370815652+1.88974910524)*3)\n",
    "    print( name, '\\t', cal_sc, '\\t', words[2],'\\t', cal_sc-float(words[2])  )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}<commit_msg>push notebook<commit_after>{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "import correlation_matrix as co\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[  3.73e-01   2.33e-01  -5.47e-01   3.17e-01  -3.61e-16   6.54e-01   6.12e-02  -4.43e-02]\n"
     ]
    }
   ],
   "source": [
    "data_file = open('historical_factors.csv', 'r')\n",
    "matrix = np.loadtxt(data_file, skiprows=1,usecols=(2,3,4,5,6,7,8,9,10))\n",
    "cor = co.Cor_matrix(matrix)\n",
    "factor = np.array(cor[0,1:])[0]\n",
    "print(factor)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {
    "collapsed": false,
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Country \t Cal \t Bib \t Dif\n",
      "Belarus_2015 \t 13.0 \t 0.0 \t 13.0\n",
      "Germany_2015 \t 5.0 \t 0.0 \t 5.0\n",
      "Japan_2015 \t 7.0 \t 0.0 \t 7.0\n",
      "Armenia_2015 \t 15.0 \t 0.0 \t 15.0\n",
      "Belgium_2015 \t 0.0 \t 0.0 \t 0.0\n",
      "Bulgar_2015 \t 6.0 \t 0.0 \t 6.0\n",
      "Canada_2015 \t 0.0 \t 0.0 \t 0.0\n",
      "Czech-R_2015 \t 0.0 \t 0.0 \t 0.0\n",
      "Finland_2015 \t 6.0 \t 0.0 \t 6.0\n",
      "Hungary_2015 \t 2.0 \t 0.0 \t 2.0\n",
      "Kazak_2015 \t 9.0 \t 0.0 \t 9.0\n",
      "Lithua_2015 \t 9.0 \t 0.0 \t 9.0\n",
      "Mexico_2015 \t 5.0 \t 0.0 \t 5.0\n",
      "Nether_2015 \t 9.0 \t 0.0 \t 9.0\n",
      "Saudi-A_2015 \t 25.0 \t 0.0 \t 25.0\n",
      "Slovak_2015 \t 3.0 \t 0.0 \t 3.0\n",
      "Spain_2015 \t 3.0 \t 0.0 \t 3.0\n",
      "Ukraine_2015 \t 9.0 \t 0.0 \t 9.0\n",
      "UAE_2015 \t 24.0 \t 0.0 \t 24.0\n",
      "Sweden_2015 \t 4.0 \t 0.0 \t 4.0\n",
      "Switz_2015 \t 3.0 \t 0.0 \t 3.0\n",
      "Indones_2015 \t 8.0 \t 0.0 \t 8.0\n",
      "Algeria_2015 \t 17.0 \t 0.0 \t 17.0\n",
      "Romania_2015 \t 3.0 \t 0.0 \t 3.0\n",
      "Sweden_1946 \t 18.0 \t 1.0 \t 17.0\n",
      "Switz_1946 \t 15.0 \t 1.0 \t 14.0\n",
      "Indones_1965 \t 14.0 \t 1.0 \t 13.0\n",
      "Algeria_1983 \t 22.0 \t 1.0 \t 21.0\n",
      "Romania_1985 \t 13.0 \t 1.0 \t 12.0\n",
      "Austral_1961 \t 9.0 \t 2.0 \t 7.0\n",
      "Egypt_1965 \t 22.0 \t 2.0 \t 20.0\n",
      "Libya_1970 \t 25.0 \t 2.0 \t 23.0\n",
      "S-Korea_1970 \t 13.0 \t 2.0 \t 11.0\n",
      "Argent_1978 \t 18.0 \t 2.0 \t 16.0\n",
      "Brazil_1978 \t 12.0 \t 2.0 \t 10.0\n",
      "Iraq_1983 \t 28.0 \t 2.0 \t 26.0\n",
      "Iran_1985 \t 26.0 \t 2.0 \t 24.0\n",
      "Syria_2000 \t 22.0 \t 2.0 \t 20.0\n",
      "US_1942 \t 20.0 \t 2.0 \t 18.0\n",
      "USSR_1945 \t 30.0 \t 2.0 \t 28.0\n",
      "UK_1947 \t 19.0 \t 2.0 \t 17.0\n",
      "France_1954 \t 22.0 \t 2.0 \t 20.0\n",
      "China_1955 \t 20.0 \t 2.0 \t 18.0\n",
      "Israel_1960 \t 18.0 \t 2.0 \t 16.0\n",
      "India_1964 \t 19.0 \t 2.0 \t 17.0\n",
      "Pakist_1972 \t 16.0 \t 2.0 \t 14.0\n",
      "S-Afric_1974 \t 19.0 \t 2.0 \t 17.0\n",
      "N-Korea_1980 \t 25.0 \t 2.0 \t 23.0\n"
     ]
    }
   ],
   "source": [
    "data_file = open('historical_factors.csv', 'r')\n",
    "lines = data_file.readlines()\n",
    "print( 'Country \\t Cal \\t Bib \\t Dif')\n",
    "for line in lines[1:]:\n",
    "    words = line.split('\\t');\n",
    "    name = words[0] + '_' + words[1]\n",
    "    weight = words[3:]\n",
    "    weight = [float(i) for i in weight]\n",
    "    score = co.Compute_Score(weight,factor)\n",
    "    cal_sc = round((score+4.32698482534)/(14.6802594247+4.32698482534)*30)\n",
    "    print( name, '\\t', cal_sc, '\\t', words[2],'\\t', cal_sc-float(words[2])  )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
{'fraction_non_alphanumeric': 0.2305579036348267, 'fraction_numerical': 0.13366441251056635, 'mean_word_length': 1.7268798617113224, 'pattern_counts': {'":': 122, '<': 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': '7214012', 'n_tokens_mistral': 5400, 'n_tokens_neox': 4565, 'n_words': 1049}