Simple-Dataframe-For-Statsmodel
from __future__ import print_function
import statsmodels.api as sm
import pandas as pd
from patsy import dmatrices
df = sm.datasets.get_rdataset("Guerry", "HistData").data
|
dept |
Region |
Department |
Crime_pers |
Crime_prop |
Literacy … |
Read More
Simple-Dataframe-From-Statsmodels
title: "Simple DataFrame From StatsModels"
author: "Raja CSP Raman"
date: 2019-04-22
description: "-"
type: technical_note
draft: false
from __future__ import print_function
import statsmodels.api as sm
import pandas as pd
from patsy import dmatrices
df = sm.datasets.get_rdataset("Guerry", "HistData").data
Read More
Simple-Entropy
title: "Simple Entropy"
author: "Rj"
date: 2019-04-20
description: "-"
type: technical_note
draft: false
import math
from collections import Counter
import timeit
import numpy as np
def eta(data, unit='natural'):
base = {
'shannon' : 2.,
'natural' : math.exp(1),
'hartley' : 10.
}
if len(data) <= 1:
return 0
counts = Counter()
for d in data …
Read More
Simple-Match
title: "Simple Match"
author: "Raja CSP Raman"
date: 2019-04-20
description: "-"
type: technical_note
draft: false
content = "Eminem means positive"
a = re.search('^Em.*ve$', content)
if(a):
print('matched')
else:
print('not matched')
More situations
- Match Canadian postal code
- Phone number
- Start with /home
- Contains /User/raja
Score …
Read More
Simple-Multiplication
title: "Simple Multiplication"
author: "Raja CSP Raman"
date: 2019-05-09
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.random_normal([2, 2])
b = tf.random_normal([2, 2])
<tf.Tensor 'random_normal_3:0' shape=(2 …
Read More
Simple-Numba
title: "Numba Simple"
author: "Raja CSP Raman"
date: 2019-05-07
description: "-"
type: technical_note
draft: false
from numba import njit, prange
import numpy as np
@njit(parallel=True)
def add(A):
s = 0
# Without "parallel=True" in the jit-decorator
# the prange statement is equivalent to range
for i in prange(A.shape …
Read More
Simple-Plot
title: "Simple Plot"
author: "Rj"
date: 2019-04-20
description: "List Test"
type: technical_note
draft: false
import matplotlib.pyplot as plt
import numpy as np
N = 128
x = np.linspace(-5, 5, N)
y = np.exp(-x**2)
y_fft = np.fft.fftshift(np.fft.fft(y).real)
plt.plot(x, y_fft)
plt …
Read More
Simple-Plot-20241203
!pip show matplotlib | grep "Version:"
# !pip install matplotlib
import matplotlib.pyplot as plt
([1, 2, 3, 4], [50, 40, 80, 40])
plt.plot(x, y, 'ro')
plt.axis([0, 10, 20, 100])
Read More
Simple-Plot-7808
title: "Simple Plot"
author: "Rj"
date: 2020-20-29
description: "Simple Plot on Plotly"
type: technical_note
draft: false
import plotly.graph_objects as go
fig = go.Figure(data=go.Bar(y=[2, 3, 1]))
fig.show()
<script type="text/javascript">
window.PlotlyConfig = {MathJaxConfig: 'local'};
if (window.MathJax) {MathJax.Hub.Config({SVG: {font: "STIX-Web …
Read More
Simple Query
title: "Simple Query"
author: "Rj"
date: 2019-04-20
description: "List Test"
type: technical_note
draft: false
import os
import sys
from sqlalchemy import Column, ForeignKey, Integer, String
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
Base = declarative_base()
Read More