Prettify-Error

Fri 14 November 2025

error_string = """
{
    "error": {
        "error_code": 1002,
        "error_message": "Unspecified Error",
        "details": "Unexpected error: ['Traceback (most recent call last):', '  File \"/home/rajaraman/rprojects/ml-api-work/ml-api-raja/services/mlapi/app/main.py\", line 228, in post_predict_classic_joblib_api', '    result_obj = await label_generator.match_with_multi(', '                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^', '  File \"/home/rajaraman/rprojects/ml-api-work/ml-api-raja/services/mlapi/app/label_generator.py\", line 770, in match_with_multi', '    feature_scores …

Category: error-analyzer

Read More

Prettify-Xml

Fri 14 November 2025

title: "Prettify XML" author: "Rj" date: 2019-04-20 description: "List Test" type: technical_note draft: false


import xmltodict
import pprint
import json

import xml.dom.minidom
dom = xml.dom.minidom.parse('sample.xml') # or xml.dom.minidom.parseString(xml_string)
pretty_xml_as_string = dom.toprettyxml()
pretty_xml_as_string
'<?xml version="1.0" ?>\n<note>\n\t\n …

Category: basics

Read More

Pretty Print Json

Fri 14 November 2025

title: "Pretty Print Json" author: "Rj" date: 2019-04-20 description: "List Test" type: technical_note draft: false


import json
import pprint
content = """{"system": {"commit": None, "python": "3.6.8.final.0", "python-bits": 64, "OS": "Darwin", "OS-release": "18.5.0", "machine": "x86_64", "processor": "i386", "byteorder": "little", "LC_ALL": "None", "LANG": "en_CA.UTF-8", "LOCALE": "en_CA …

Category: basics

Read More

Pretty Print Online Json

Fri 14 November 2025

title: "Pretty Print Online JSON" author: "Rj" date: 2019-04-20 description: "List Test" type: technical_note draft: false


import pprint
import json 
from urllib.request import urlopen
r = urlopen("https://mdn.github.io/fetch-examples/fetch-json/products.json")
text = r.read() 
pprint.pprint(json.loads(text))
{'products': [{'Location': 'Refrigerated foods',
               'Name': 'Cheese',
               'Price …

Category: basics

Read More

Print-Filenames

Fri 14 November 2025

title: "Print Filenames" author: "Rj" date: 2019-04-21 description: "-" type: technical_note draft: false


from os import walk
from os import listdir
from os.path import isfile, join
path = '/tmp'
onlyfiles = [f for f in listdir(path) if isfile(join(path, f))]
onlyfiles
['.BBE72B41371180178E084EEAF106AED4F350939DB95D3516864A1CC62E7AE82F']
for fle in onlyfiles:
    print(fle)
.BBE72B41371180178E084EEAF106AED4F350939DB95D3516864A1CC62E7AE82F



Score …

Category: textprocessing

Read More

Print In Tensorflow

Fri 14 November 2025

title: "Print in Tensorflow" author: "Raja CSP Raman" date: 2019-05-07 description: "-" type: technical_note draft: false


import tensorflow as tf

import os

# Just disables the warning, doesn't enable AVX/FMA
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
a = tf.Variable([[1, 2, 3]])
init = (tf.global_variables_initializer(), tf.local_variables_initializer())
sess = tf.Session()
sess.run …

Category: tensorflow-work

Read More

Print Tensorflow

Fri 14 November 2025

title: "Print in Tensorflow" author: "Raja CSP Raman" date: 2019-05-07 description: "-" type: technical_note draft: false


import tensorflow as tf

import os

# Just disables the warning, doesn't enable AVX/FMA
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
sess = tf.InteractiveSession()
sess
<tensorflow.python.client.session.InteractiveSession at 0x12b796668>
a = tf.constant([12.0 …

Category: tensorflow-work

Read More

Print Values

Fri 14 November 2025

title: "Print Values" author: "Raja CSP Raman" date: 2019-05-07 description: "-" type: technical_note draft: false


import tensorflow as tf

import os

# Just disables the warning, doesn't enable AVX/FMA
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
normal_rv = tf.Variable(tf.truncated_normal([2, 3], stddev=0.1))
# Initialize the variables
init_op = tf.initialize_all_variables()
with …

Category: tensorflow-work

Read More

Product-Summary-Classification-Nb

Fri 14 November 2025

title: "Text Classification - Naive Bayes - Product Summary" author: "Rj" date: 2019-04-21 description: "-" type: technical_note draft: false


# Disclaimer: some code copied form this https://towardsdatascience.com/multi-class-text-classification-model-comparison-and-selection-5eb066197568
import logging
import pandas as pd
import numpy as np
from numpy import random
import gensim
import nltk
from sklearn.model_selection import train_test_split
from …

Category: textprocessing

Read More

Py-Ml-Tips-Rules

Fri 14 November 2025

title: "Py ML Tips and Rules" author: "Rj" date: 2019-04-21 description: "-" type: technical_note draft: false


Numpy Indexing

Numpy indexing for one-dimensional arrays works similarly to Python lists using the square-bracket notation. For two-dimensional arrays, the first index refers to the row number, and the indexer to the column number.



Score …

Category: basics

Read More
Page 121 of 146

« Prev Next »