#我们用一个等臂天平来称物体的质量,如果我们要称的物体质量范围在1到40克(整数),请问我们最少需要几块砝码可以完成这项物体质量的称量?
- 3
- 4
- 5
- 6
- 7
##answer: 答案是四个。
#!/usr/bin/env python | |
# encoding: utf-8 | |
__author__ = 'dm' | |
punct = set(u''':!),.:;?]}¢'"、。〉》」』】〕〗〞︰︱︳﹐、﹒ | |
﹔﹕﹖﹗﹚﹜﹞!),.:;?|}︴︶︸︺︼︾﹀﹂﹄﹏、~¢ | |
々‖•·ˇˉ―--′’”([{£¥'"‵〈《「『【〔〖([{£¥〝︵︷︹︻ | |
︽︿﹁﹃﹙﹛﹝({“‘-—_…''') | |
# 对str/unicode | |
filterpunt = lambda s : ''.join(filter(lambda x : x not in punct , s)) |
IPYTHON=ipython IPYTHON_OPTS=qtconsole ./bin/pyspark |
#我们用一个等臂天平来称物体的质量,如果我们要称的物体质量范围在1到40克(整数),请问我们最少需要几块砝码可以完成这项物体质量的称量?
##answer: 答案是四个。
/** | |
* Created by cmy on 12/14/15. | |
*/ | |
import org.apache.spark.util.StatCounter | |
class NAStatCounter extends Serializable{ | |
val stats: StatCounter = new StatCounter() | |
var missing: Long = 0 | |
def add(x: Double): NAStatCounter = { |
/** | |
* bisecting <master> <input> <nNodes> <subIterations> | |
* | |
* divisive hierarchical clustering using bisecting k-means | |
* assumes input is a text file, each row is a data point | |
* given as numbers separated by spaces | |
* | |
*/ | |
import org.apache.spark.SparkContext |
import pandas as pd | |
import numpy as np | |
%matplotlib inline | |
fig, ax = plt.subplots() | |
df = pd.read_csv("author_coauthor_number.csv") | |
df.boxplot(ax=ax) | |
plt.savefig("coauthor.png", dpi=400) |
Movies Recommendation:
Music Recommendation:
#!/usr/bin/env python | |
# encoding: utf-8 | |
from numpy import * | |
import matplotlib.pyplot as plt | |
def logistic(wTx): | |
return 1.0/(1.0 + exp(-wTx)) | |
def file2matrix(filename,delimiter): |
-0.017612 -14.053064 0.0 | |
-1.395634 -4.662541 1.0 | |
-0.752157 -6.53862 0.0 | |
-1.322371 -7.152853 0.0 | |
0.423363 -11.054677 0.0 | |
0.406704 -7.067335 1.0 | |
0.667394 -12.741452 0.0 | |
-2.46015 -6.866805 1.0 | |
0.569411 -9.548755 0.0 | |
-0.026632 -10.427743 0.0 |