たれみみマンデー

機械学習に備えてPython固めの巻

どうもたれみみです。

去年の暮れから機械学習系の本を読みあさっていたのですが(何度も挫折)

最近改めて勉強しようと思い立ちググっていると、なんとスタンフォードの授業が無料で受けられると。始めました。

www.coursera.org

 

しかーし、実はPythonは基礎本2,3冊を読んでいただけで抜け漏れが半端ないことにここで気づいた(おそい)

 

そんなとき、ふとおもいだした。

言語処理、機械学習系界隈のみなさんがオススメしていた東北大乾研究室の『言語処理100本ノック』http://www.cl.ecei.tohoku.ac.jp/nlp100/

 

いままでRubyでは同じようなことをしてきたんですが、Pythonでやると、な。しかもめっちゃ研究っぽい!実用的ぽい! ワクワクしてきました。ちょっくら腕みがいてきませふ。

 

それでは。

Railsでカスタムフォントの使い方

1. どこかからフォントファイルをダウンロード

 

2. app/assets/fontsフォルダを作り、その中にさっきのファイルを放り込む

 

3. scss (css)をいじる

@font-face {

   font-family: ********;

   src: font-url('/assets/******.TTF');

}

 

で、使いたいタイミングで

font-family: *******,fantasy,sans-serif;

 

とすれば動きます。

ご参考に。

Railsでjsonファイルの配置と読み込み

読み込ませたいファイルをapp/assets/javascript/ の中に放り込んで

viewなりcontrollerの中で

 

"<%= asset_path('*******.json') %>"

 

って書けば動きます

 

だれかの役に立てば幸いです。

Railsにおけるカラムでの禁止ワード(予約語)

 

!
!=
!~
<=>
==
===
=~
[]
[]=
__id__
__send__
_attr_readonly
_commit_callbacks
_commit_callbacks=
_commit_callbacks?
_create_callbacks
_create_callbacks=
_create_callbacks?
_destroy
_destroy_callbacks
_destroy_callbacks=
_destroy_callbacks?
_find_callbacks
_find_callbacks=
_find_callbacks?
_initialize_callbacks
_initialize_callbacks=
_initialize_callbacks?
_rollback_callbacks
_rollback_callbacks=
_rollback_callbacks?
_save_callbacks
_save_callbacks=
_save_callbacks?
_touch_callbacks
_touch_callbacks=
_touch_callbacks?
_update_callbacks
_update_callbacks=
_update_callbacks?
_validate_callbacks
_validate_callbacks=
_validate_callbacks?
_validation_callbacks
_validation_callbacks=
_validation_callbacks?
_validators
_validators=
_validators?
`
acts_like?
add_to_transaction
arel_attributes_with_values_for_create
arel_attributes_with_values_for_update
as_json
assign_attributes
association
association_cache
attribute_aliases
attribute_aliases?
attribute_for_inspect
attribute_method?
attribute_method_matchers
attribute_method_matchers?
attribute_missing
attribute_names
attribute_present?
attribute_types_cached_by_default
attribute_types_cached_by_default?
attributes
attributes=
attributes_before_type_cast
becomes
becomes!
blank?
breakpoint
cache_key
cache_timestamp_format
cache_timestamp_format?
capture
changed
changed?
changed_attributes
changed_for_autosave?
changes
class
class_eval
clear_aggregation_cache
clear_association_cache
clear_transaction_record_state
clone
clone_attribute_value
clone_attributes
column_for_attribute
committed!
configurations
connection
connection_handler
connection_handler?
debugger
decrement
decrement!
deep_dup
default_scopes
default_scopes?
default_timezone
define_singleton_method
delete
destroy
destroy!
destroyed?
display
dup
duplicable?
enable_warnings
encode_with
enum_for
eql?
equal?
errors
extend
freeze
from_json
from_xml
frozen?
gem
has_attribute?
has_transactional_callbacks?
hash
html_safe?
id
id=
id?
id_before_type_cast
in?
include_root_in_json
include_root_in_json=
include_root_in_json?
increment
increment!
init_with
inspect
instance_eval
instance_exec
instance_of?
instance_values
instance_variable_defined?
instance_variable_get
instance_variable_names
instance_variable_set
instance_variables
invalid?
is_a?
kind_of?
load
load_dependency
lock!
lock_optimistically
lock_optimistically?
locking_enabled?
logger
mark_for_destruction
marked_for_destruction?
method
method_missing
methods
nested_attributes_options
nested_attributes_options?
new_record?
nil?
object_id
partial_writes
partial_writes?
perform_validations
persisted?
pluralize_table_names
pluralize_table_names?
populate_with_current_scope_attributes
presence
present?
pretty_inspect
pretty_print
pretty_print_cycle
pretty_print_inspect
pretty_print_instance_variables
previous_changes
primary_key_prefix_type
private_methods
protected_methods
psych_to_yaml
public_method
public_methods
public_send
query_attribute
quietly
quoted_id
raw_write_attribute
read_attribute
read_attribute_before_type_cast
read_attribute_for_serialization
read_attribute_for_validation
read_store_attribute
readonly!
readonly?
record_timestamps
record_timestamps=
record_timestamps?
reflections
reflections=
reflections?
reload
remember_transaction_record_state
remove_instance_variable
require
require_dependency
require_or_load
respond_to?
respond_to_without_attributes?
restore_transaction_record_state
rollback_active_record_state!
rolledback!
run_callbacks
run_validations!
sanitize_for_mass_assignment
save
save!
schema_format
send
serializable_hash
serialized_attributes
set_transaction_state
silence
silence_stderr
silence_stream
silence_warnings
singleton_class
singleton_methods
skip_time_zone_conversion_for_attributes
skip_time_zone_conversion_for_attributes?
slice
store_full_sti_class
store_full_sti_class?
suppress
suppress_warnings
table_name_prefix
table_name_prefix?
table_name_suffix
table_name_suffix?
taint
tainted?
tap
time_zone_aware_attributes
timestamped_migrations
to_enum
to_json
to_key
to_model
to_param
to_partial_path
to_query
to_s
to_xml
to_yaml
to_yaml_properties
toggle
toggle!
touch
transaction
transaction_include_any_action?
transaction_record_state
trust
try
try!
unloadable
untaint
untrust
untrusted?
update
update!
update_attribute
update_attributes
update_attributes!
update_column
update_columns
valid?
validates_absence_of
validates_acceptance_of
validates_confirmation_of
validates_exclusion_of
validates_format_of
validates_inclusion_of
validates_length_of
validates_numericality_of
validates_presence_of
validates_size_of
validates_with
validation_context
validation_context=
with_lock
with_options
with_transaction_returning_status
with_warnings
write_store_attribute

参考

http://qiita.com/fukayatsu/items/b7aa643b3a0ca6a41c5e

TwitterAPI。配列に入った複数の要素をOR検索

query = ["キーワード","キーワード","キーワード"]

if query.present?                                                                            

      new_q = query.to_s.gsub!(/,/,"+OR+").gsub!(/\s|"|\[|\]/,"")

       results = @client.search(new_q, count: 16, result_type: "recent",  exclude: "retweets", filter: "images")

       results.take(16).each do |tw|

         @client.favorite(tw.id)

         puts "#{tw.text}をファボしました"

       end

     end