Changeset ad8742 in git
- Timestamp:
- Sep 2, 2019, 5:41:55 PM (5 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- 44ebb1208e9d72e44ac4a62daa6d1d118c4acebb
- Parents:
- bfaec2aa93e88c6781454a61ac4ffa74b64eb0dd
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/iparith.cc
rbfaec2 rad8742 80 80 81 81 #include <ctype.h> 82 83 #include <readline/history.h> 82 84 83 85 // defaults for all commands: NO_NC | NO_RING | ALLOW_ZERODIVISOR … … 7798 7800 7799 7801 7800 //HERE7801 7802 static BOOLEAN jjPREDHELP0(leftv res, leftv) 7802 7803 { 7804 char buffer[30]; 7805 char filename[15] = "~/.history"; 7806 int i; 7803 7807 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 7804 7816 if (!ml_initialise()) { 7805 7817 Print("Initialise of ml failed."); … … 7809 7821 } 7810 7822 7823 ml_make_prediction(filename, 30, buffer, &i); 7824 printf("prediciton %s\n", buffer); 7825 7811 7826 L->Init(1); 7812 7827 … … 7820 7835 return FALSE; 7821 7836 } 7837 7822 7838 7823 7839 -
machine_learning/Makefile.am
rbfaec2 rad8742 1 1 ACLOCAL_AMFLAGS = -I ../m4 2 2 3 AM_CPPFLAGS = -I/usr/include/python2.7 -DDATA_PATH=\"$(datadir)\" 3 #AM_CPPFLAGS = -I/usr/include/python3.6 -DDATA_PATH=\"$(datadir)\" 4 AM_CPPFLAGS = -I/usr/include/python2.7 -DDATA_PATH=\"$(datadir)\" 4 5 5 libmlearn_LTLIBRARIES = libmlearn.la6 libmlearn_LTLIBRARIES = libmlearn.la 6 7 libmlearndir = $(libdir) 7 8 … … 10 11 11 12 libmlearn_la_SOURCES = $(SOURCES) 13 #libmlearn_la_LDFLAGS = $(SINGULAR_LDFLAGS) -lpython3.6m 12 14 libmlearn_la_LDFLAGS = $(SINGULAR_LDFLAGS) -lpython2.7 13 15 14 libmlearn_includedir =${includedir}/singular/machine_learning15 nobase_libmlearn_include_HEADERS = $(LIBMLEARNHEADERS)16 libmlearn_includedir = ${includedir}/singular/machine_learning 17 nobase_libmlearn_include_HEADERS = $(LIBMLEARNHEADERS) 16 18 17 19 18 20 ########################################################################### 19 21 20 TESTS = test_bufsize test_init_ml 22 TESTS = test_bufsize test_init_ml 23 check_PROGRAMS = test_bufsize test_init_ml 21 24 22 check_PROGRAMS = test_bufsize test_init_ml 25 test_bufsize_LDADD = libmlearn.la 26 #test_bufsize_LDFLAGS = -lpython3.6m 27 test_bufsize_LDFLAGS = -lpython2.7 23 28 24 test_bufsize_ LDADD=libmlearn.la25 test_bufsize_ LDFLAGS= -lpython2.729 test_bufsize_SOURCES = tests/test_bufsize.c 30 test_bufsize_CFLAGS = -Wall -Wextra 26 31 27 test_bufsize_SOURCES=tests/test_bufsize.c 28 test_bufsize_CFLAGS= -Wall -Wextra 32 test_init_ml_LDADD = libmlearn.la 33 #test_init_ml_LDFLAGS = -lpython3.6m 34 test_init_ml_LDFLAGS = -lpython2.7 29 35 30 test_init_ml_ LDADD=libmlearn.la31 test_init_ml_ LDFLAGS= -lpython2.736 test_init_ml_SOURCES = tests/test_init_ml.c 37 test_init_ml_CFLAGS = -Wall -Wextra 32 38 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 = \ 39 nobase_dist_data_DATA = \ 38 40 ml_python/__init__.py \ 39 41 ml_python/predictor_runner.py \ -
machine_learning/ml_python/common/keyword_vector.py
rbfaec2 rad8742 71 71 vectors = vectors.toarray() 72 72 if normalise: 73 #print(sys.version) 73 74 vectors = vectors / np.sqrt((vectors ** 2).sum(-1))[..., np.newaxis] 74 75 return vectors -
machine_learning/ml_python/common/lookuptable.py
rbfaec2 rad8742 55 55 56 56 # extract keywords using the singular script 57 os.system(SINGULAR_BIN + " -q " + EXTRACT_SCRIPT + 57 os.system(SINGULAR_BIN + " -q " + EXTRACT_SCRIPT + 58 58 " | sort | uniq > " + KEYWORDS_FILE) 59 59 -
machine_learning/ml_python/predictor_runner.py
rbfaec2 rad8742 37 37 predictor.fit(vectors, file_list) 38 38 39 filename = os.path.expanduser(filename) 39 40 test_vec = count_occurances(filename, dictionary) 40 41 prediction = predictor.predict(np.array([test_vec])) -
machine_learning/mlpredict.c
rbfaec2 rad8742 101 101 PyObject *pName = NULL; 102 102 PyObject *pModule = NULL; 103 PyObject *pTemp = NULL; 103 104 104 105 if (!Py_IsInitialized()) { … … 107 108 108 109 pName = PyString_FromString("sys"); 110 //pName = PyUnicode_FromString("sys"); 109 111 pModule = PyImport_Import(pName); 110 112 Py_DECREF(pName); … … 128 130 pString = PyObject_Str(pPath); 129 131 spath = PyString_AsString(pString); 132 //pTemp = PyUnicode_AsASCIIString(pString); 133 //spath = PyBytes_AsString(pTemp); 130 134 /* get the path to be set */ 131 135 PYTPATH(buffer); 132 136 if (!strstr(spath, buffer)) { 133 137 pMyPath = PyString_FromString(buffer); 138 //pMyPath = PyUnicode_FromString(buffer); 134 139 /* pPath set to tuple, so no decref needed later */ 135 140 PyList_Append(pPath, pMyPath); … … 137 142 } 138 143 Py_DECREF(pString); 144 //Py_XDECREF(pTemp); 139 145 Py_DECREF(pPath); 140 146 … … 194 200 PyObject *pFName = NULL, *pArgs = NULL; 195 201 PyObject *pValue = NULL; PyObject *pString = NULL; 202 PyObject *pTemp = NULL; 196 203 int ret_string_len = 0; 197 204 198 205 pFName = PyString_FromString(filename); 206 //pFName = PyUnicode_FromString(filename); 199 207 if (!pFName) { 200 208 fprintf(stderr, "This is weird\n"); … … 231 239 pString = PyObject_Str(pValue); 232 240 strncpy(prediction_buffer, PyString_AsString(pString), buffer_size - 1); 241 //pTemp = PyUnicode_AsASCIIString(pString); 242 //strncpy(prediction_buffer, PyBytes_AsString(pTemp), buffer_size - 1); 233 243 ret_string_len = strlen(PyString_AsString(pString)); 244 //ret_string_len = strlen(PyBytes_AsString(pTemp)); 234 245 if (ret_string_len >= buffer_size - 1) { 235 246 prediction_buffer[buffer_size - 1] = '\0'; … … 240 251 241 252 Py_DECREF(pString); 253 //Py_XDECREF(pTemp); 242 254 Py_DECREF(pValue); 243 255 … … 286 298 /* import the module */ 287 299 pName = PyString_FromString(module); 300 //pName = PyUnicode_FromString(module); 288 301 pModule = PyImport_Import(pName); 289 302 Py_DECREF(pName); -
machine_learning/tests/test_bufsize.c
rbfaec2 rad8742 12 12 char buffer12[12]; 13 13 char buffer20[20]; 14 double time_taken;15 14 if (argc != 1) { 16 15 printf("Usage: %s\n", argv[0]);
Note: See TracChangeset
for help on using the changeset viewer.