Changeset ad8742 in git


Ignore:
Timestamp:
Sep 2, 2019, 5:41:55 PM (5 years ago)
Author:
Murray Heymann <heymann.murray@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
44ebb1208e9d72e44ac4a62daa6d1d118c4acebb
Parents:
bfaec2aa93e88c6781454a61ac4ffa74b64eb0dd
Message:
Make actual prediction
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • Singular/iparith.cc

    rbfaec2 rad8742  
    8080
    8181#include <ctype.h>
     82
     83#include <readline/history.h>
    8284
    8385// defaults for all commands: NO_NC | NO_RING | ALLOW_ZERODIVISOR
     
    77987800
    77997801
    7800 //HERE
    78017802static BOOLEAN jjPREDHELP0(leftv res, leftv)
    78027803{
     7804        char buffer[30];
     7805        char filename[15] = "~/.history";
     7806        int i;
    78037807        lists L = (lists)omAllocBin(slists_bin);
     7808
     7809        buffer[0] = '\0';
     7810
     7811        if(write_history(NULL)) {
     7812                printf("Failed to write history\n");
     7813                return TRUE;
     7814        }
     7815
    78047816        if (!ml_initialise()) {
    78057817                Print("Initialise of ml failed.");
     
    78097821        }
    78107822
     7823        ml_make_prediction(filename, 30, buffer, &i);
     7824        printf("prediciton %s\n", buffer);
     7825
    78117826        L->Init(1);
    78127827
     
    78207835        return FALSE;
    78217836}
     7837
    78227838
    78237839
  • machine_learning/Makefile.am

    rbfaec2 rad8742  
    11ACLOCAL_AMFLAGS = -I ../m4
    22
    3 AM_CPPFLAGS = -I/usr/include/python2.7 -DDATA_PATH=\"$(datadir)\"
     3#AM_CPPFLAGS            = -I/usr/include/python3.6 -DDATA_PATH=\"$(datadir)\"
     4AM_CPPFLAGS             = -I/usr/include/python2.7 -DDATA_PATH=\"$(datadir)\"
    45
    5 libmlearn_LTLIBRARIES = libmlearn.la
     6libmlearn_LTLIBRARIES   = libmlearn.la
    67libmlearndir = $(libdir)
    78
     
    1011
    1112libmlearn_la_SOURCES    = $(SOURCES)
     13#libmlearn_la_LDFLAGS   = $(SINGULAR_LDFLAGS) -lpython3.6m
    1214libmlearn_la_LDFLAGS    = $(SINGULAR_LDFLAGS) -lpython2.7
    1315
    14 libmlearn_includedir=${includedir}/singular/machine_learning
    15 nobase_libmlearn_include_HEADERS= $(LIBMLEARNHEADERS)
     16libmlearn_includedir    = ${includedir}/singular/machine_learning
     17nobase_libmlearn_include_HEADERS = $(LIBMLEARNHEADERS)
    1618
    1719
    1820###########################################################################
    1921
    20 TESTS = test_bufsize test_init_ml
     22TESTS                   = test_bufsize test_init_ml
     23check_PROGRAMS          = test_bufsize test_init_ml
    2124
    22 check_PROGRAMS = test_bufsize test_init_ml
     25test_bufsize_LDADD      = libmlearn.la
     26#test_bufsize_LDFLAGS   = -lpython3.6m
     27test_bufsize_LDFLAGS    = -lpython2.7
    2328
    24 test_bufsize_LDADD=libmlearn.la
    25 test_bufsize_LDFLAGS= -lpython2.7
     29test_bufsize_SOURCES    = tests/test_bufsize.c
     30test_bufsize_CFLAGS     = -Wall -Wextra
    2631
    27 test_bufsize_SOURCES=tests/test_bufsize.c
    28 test_bufsize_CFLAGS= -Wall -Wextra
     32test_init_ml_LDADD      = libmlearn.la
     33#test_init_ml_LDFLAGS   = -lpython3.6m
     34test_init_ml_LDFLAGS    = -lpython2.7
    2935
    30 test_init_ml_LDADD=libmlearn.la
    31 test_init_ml_LDFLAGS= -lpython2.7
     36test_init_ml_SOURCES    = tests/test_init_ml.c
     37test_init_ml_CFLAGS     = -Wall -Wextra
    3238
    33 test_init_ml_SOURCES=tests/test_init_ml.c
    34 test_init_ml_CFLAGS= -Wall -Wextra
    35 
    36 #mlmoduledir = ${datadir}/singular/mlearn
    37 nobase_dist_data_DATA = \
     39nobase_dist_data_DATA   = \
    3840        ml_python/__init__.py \
    3941        ml_python/predictor_runner.py \
  • machine_learning/ml_python/common/keyword_vector.py

    rbfaec2 rad8742  
    7171    vectors = vectors.toarray()
    7272    if normalise:
     73        #print(sys.version)
    7374        vectors = vectors / np.sqrt((vectors ** 2).sum(-1))[..., np.newaxis]
    7475    return vectors
  • machine_learning/ml_python/common/lookuptable.py

    rbfaec2 rad8742  
    5555
    5656    # extract keywords using the singular script
    57     os.system(SINGULAR_BIN + " -q " + EXTRACT_SCRIPT + 
     57    os.system(SINGULAR_BIN + " -q " + EXTRACT_SCRIPT +
    5858            " | sort | uniq > " + KEYWORDS_FILE)
    5959
  • machine_learning/ml_python/predictor_runner.py

    rbfaec2 rad8742  
    3737    predictor.fit(vectors, file_list)
    3838
     39    filename = os.path.expanduser(filename)
    3940    test_vec = count_occurances(filename, dictionary)
    4041    prediction = predictor.predict(np.array([test_vec]))
  • machine_learning/mlpredict.c

    rbfaec2 rad8742  
    101101        PyObject *pName = NULL;
    102102        PyObject *pModule = NULL;
     103        PyObject *pTemp = NULL;
    103104
    104105        if (!Py_IsInitialized()) {
     
    107108
    108109        pName = PyString_FromString("sys");
     110        //pName = PyUnicode_FromString("sys");
    109111        pModule = PyImport_Import(pName);
    110112        Py_DECREF(pName);
     
    128130        pString = PyObject_Str(pPath);
    129131        spath = PyString_AsString(pString);
     132        //pTemp = PyUnicode_AsASCIIString(pString);
     133        //spath = PyBytes_AsString(pTemp);
    130134        /* get the path to be set */
    131135        PYTPATH(buffer);
    132136        if (!strstr(spath, buffer)) {
    133137                pMyPath = PyString_FromString(buffer);
     138                //pMyPath = PyUnicode_FromString(buffer);
    134139                /* pPath set to tuple, so no decref needed later */
    135140                PyList_Append(pPath, pMyPath);
     
    137142        }
    138143        Py_DECREF(pString);
     144        //Py_XDECREF(pTemp);
    139145        Py_DECREF(pPath);
    140146
     
    194200        PyObject *pFName = NULL, *pArgs = NULL;
    195201        PyObject *pValue = NULL; PyObject *pString = NULL;
     202        PyObject *pTemp = NULL;
    196203        int ret_string_len = 0;
    197204
    198205        pFName = PyString_FromString(filename);
     206        //pFName = PyUnicode_FromString(filename);
    199207        if (!pFName) {
    200208                fprintf(stderr, "This is weird\n");
     
    231239        pString = PyObject_Str(pValue);
    232240        strncpy(prediction_buffer, PyString_AsString(pString), buffer_size - 1);
     241        //pTemp = PyUnicode_AsASCIIString(pString);
     242        //strncpy(prediction_buffer, PyBytes_AsString(pTemp), buffer_size - 1);
    233243        ret_string_len = strlen(PyString_AsString(pString));
     244        //ret_string_len = strlen(PyBytes_AsString(pTemp));
    234245        if (ret_string_len >= buffer_size - 1) {
    235246                prediction_buffer[buffer_size - 1] = '\0';
     
    240251
    241252        Py_DECREF(pString);
     253        //Py_XDECREF(pTemp);
    242254        Py_DECREF(pValue);
    243255
     
    286298        /* import the module */
    287299        pName = PyString_FromString(module);
     300        //pName = PyUnicode_FromString(module);
    288301        pModule = PyImport_Import(pName);
    289302        Py_DECREF(pName);
  • machine_learning/tests/test_bufsize.c

    rbfaec2 rad8742  
    1212        char buffer12[12];
    1313        char buffer20[20];
    14         double time_taken;
    1514        if (argc != 1) {
    1615                printf("Usage: %s\n", argv[0]);
Note: See TracChangeset for help on using the changeset viewer.