Skip to content

Instantly share code, notes, and snippets.

View MechCoder's full-sized avatar
💭
away

manoj kumar MechCoder

💭
away
View GitHub Profile
+ set -e
+++ dirname ./cpp/thirdparty/build_thirdparty.sh
++ cd ./cpp/thirdparty
++ pwd
+ TP_DIR=/home/manoj/arrow/cpp/thirdparty
+ source /home/manoj/arrow/cpp/thirdparty/versions.sh
++ GTEST_VERSION=1.7.0
++ GTEST_URL=https://github.com/google/googletest/archive/release-1.7.0.tar.gz
++ GTEST_BASEDIR=googletest-release-1.7.0
++ GBENCHMARK_VERSION=1.0.0
# coding: utf-8
# Predicting the Behavior of the Supreme Court of the United States: A General Approach
# ==================
# * __Title__: Predicting the Behavior of the Supreme Court of the United States: A General Approach
# * __Authors__: [Daniel Martin Katz](http://www.law.msu.edu/faculty_staff/profile.php?prof=780), [Michael J Bommarito II](http://bommaritollc.com/), [Josh Blackman](http://joshblackman.com)
# * __Paper URL__: [http://papers.ssrn.com/sol3/papers.cfm?abstract_id=2463244](http://papers.ssrn.com/sol3/papers.cfm?abstract_id=2463244)
# * __Blog URL__: [http://lexpredict.com/portfolio/predicting-the-supreme-court/](http://lexpredict.com/portfolio/predicting-the-supreme-court/)
#
# ## Paper Abstract
from math import exp
import numpy as np
from scipy.stats import beta
from sklearn.gaussian_process import GaussianProcessRegressor
from sklearn.gaussian_process.kernels import Matern
from sklearn.utils import safe_mask
from scipy import stats
from sklearn.datasets import make_classification, load_iris, load_digits
from scipy.stats import uniform, rv_continuous
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import RandomizedSearchCV, GridSearchCV, SequentialSearchCV
import numpy as np
import matplotlib.pyplot as plt
# iris = load_iris()
# digits = load_digits()
# X, y = iris.data, iris.target
import csv
import urllib
import pickle
from urllib.error import HTTPError
from bs4 import BeautifulSoup
# The logic here is messy but it seems to work.
# The idea is to pass the html read from urllib to BeautifulSoup
# which will return a soup object.
import numpy as np
import matplotlib.pyplot as plt
from sklearn.datasets import make_regression
from sklearn.linear_model import HuberRegressor, Ridge
from sklearn.metrics import mean_squared_error
from sklearn.preprocessing import StandardScaler
rng = np.random.RandomState(0)
noise = rng.randn(100).reshape(-1, 1)
@MechCoder
MechCoder / huber.py
Last active September 25, 2015 20:51
Example code for the HuberEstimator
import numpy as np
from sklearn.datasets import make_regression, load_boston
from sklearn.linear_model import HuberRegressor
from sklearn.metrics import mean_squared_error
from sklearn.preprocessing import StandardScaler
from sklearn.grid_search import GridSearchCV
from sklearn.utils.estimator_checks import NotAnArray, _boston_subset
boston = load_boston()
@MechCoder
MechCoder / since.sh
Created August 21, 2015 08:15
Replace since by Since
echo "Enter file name"
read file_name
output=$(grep -n 'since' $file_name)
echo "$output" > tmp.txt
while read name
do
IFS=': ' read -ra line_and_since <<< "$name"
line_no="${line_and_since[0]}"
version_no="${line_and_since[-1]}"
@MechCoder
MechCoder / df.scala
Last active August 29, 2015 14:24
SparkSQL stuff
import org.apache.spark.SparkContext
import org.apache.spark.sql.SQLContext
val a = Array(1, 2, 3, 4)
val b = Array("one", "two", "three", "four")
val sc = SparkContext.getOrCreate()
val sql = SQLContext.getOrCreate(sc)
val df = sc.parallelize(a.zip(b)).toDF("number", "word")
# Collects the dataframe
************* Module pyspark
W: 48, 0: Wildcard import pyspark.status (wildcard-import)
************* Module pyspark.broadcast
W: 27, 4: Redefining built-in 'unicode' (redefined-builtin)
W: 37, 4: Redefining name '_broadcastRegistry' from outer scope (line 33) (redefined-outer-name)
W: 37, 4: Module import itself (import-self)
R: 77, 4: Method could be a function (no-self-use)
R: 82, 4: Method could be a function (no-self-use)
W: 97,12: Attribute '_value' defined outside __init__ (attribute-defined-outside-init)
************* Module pyspark.heapq3