杩欐槸鐢ㄤ簬鎷夐綈鍘熷垱銆佹椿璺冦佷骇鑳界殑python鍖咃紝閫氳繃杈撳叆涓や釜缇や綋鐨勫師鍒涚巼銆佹椿璺冨害銆佸彂鏂囬噺锛岄氳繃PSM鐨勬柟寮忓緱鍒板彲鍖归厤鐨勪袱缇や綋鏍锋湰锛屽苟杩涜杩斿洖銆 涓嬮潰鏄绋嬪簭鍖呯殑浣跨敤浠嬬粛锛 #鏁版嵁澶勭悊 data = pd.read_csv('D:\椤圭洰\X椤圭洰\鎷夐綈鍘熷垱銆佹椿璺冦佷骇鑳絓\X_鍒涗綔鍙锋媺榻愬琛.csv', encoding='utf-8')
data.set_index('cpid', drop=1, inplace=True)
data = data[['cp_type','active_index','pubnum','rate_org']].sample(20000)
data['treatment'] = data['cp_type'].map({'X': 1, 'creator': 0}) #瀹炰緥鍖 mt = PsmData(data,treatment='treatment',exclude_vars=['cp_type']) #鑾峰彇璇勫垎 print(mt.propensity_score(method=LogisticRegression())) #寰楀埌鍖归厤鐨刬ndex print(mt.matching(left_match=1, right_match=0, k=1, caliper=None, replace=True).head()) #寰楀埌鍖归厤鍚庣殑涓ょ兢浣撴牱鏈 print(mt.full_matched_data(left_match=1, right_match=0, k=1, caliper=None, replace=True).head()) #缁樺埗鍒嗗竷鍥 matchdata = mt.full_matched_data() mt.plot_distribution_list(matchdata) plt.show()
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file matchgroup-0.0.1.tar.gz.
File metadata
- Download URL: matchgroup-0.0.1.tar.gz
- Upload date:
- Size: 6.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/4.0.1 CPython/3.8.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d05126d2879234bdf7c196fc46c2e4c1eb24e267d8d0189387283fd8f9eb104
|
|
| MD5 |
1912a978d577998a363910b68dc60521
|
|
| BLAKE2b-256 |
0654f95bfd5eb77d782e3f8aa83615efeb6063401104777ebaa7b9cfcd75a009
|