失效链接处理 |
Python数据分析和特征提取 PDF 下载
本站整理下载:
相关截图:
主要内容:
孵化器是支持创业公司的创建及其最初活动的公司. 它们之所以重要,是因为它们可以帮助企业家
解决与经营企业通常相关的一些问题,例如工作空间,培训和种子资金.
我们的伟大工程也需要一个起点. 在本节中,我们将通过导入一些库和常规函数来开始我们的工作.
例如pandas, sklearn, matplotlib等等.
导入# 导入 warnings 过滤器 from warnings import simplefilter # 忽略future warnings, sklearn的future warning非常烦人 simplefilter(action='ignore', category=FutureWarning) # 导入相关库 import pandas as pd import numpy as np import seaborn as sns import matplotlib.pyplot as plt %matplotlib inline # 导入 from sklearn.model_selection import train_test_split from sklearn.model_selection import learning_curve from sklearn.model_selection import validation_curve from sklearn.model_selection import cross_val_score from sklearn.linear_model import LogisticRegression 函数# 创建数据表, 分析数据缺失 def draw_missing_data_table(df): total = df.isnull().sum().sort_values(ascending=False) percent = (df.isnull().sum()/df.isnull().count()).sort_values(ascending=False) missing_data = pd.concat([total, percent], axis=1, keys=['Total', 'Percent']) return missing_data # 绘制学习曲线 def plot_learning_curve(estimator, title, X, y, ylim=None, cv=None,
首发于
从点滴开始做更好的自己
2020/9/27 Python数据分析和特征提取 - 知乎
https://zhuanlan.zhihu.com/p/133507236 4/42
n_jobs=1, train_sizes=np.linspace(.1, 1.0, 5)): plt.figure() plt.title(title) if ylim is not None: plt.ylim(*ylim) plt.xlabel("Training examples") plt.ylabel("Score") train_sizes, train_scores, test_scores = learning_curve( estimator, X, y, cv=cv, n_jobs=n_jobs, train_sizes=train_sizes) train_scores_mean = np.mean(train_scores, axis=1) train_scores_std = np.std(train_scores, axis=1) test_scores_mean = np.mean(test_scores, axis=1) test_scores_std = np.std(test_scores, axis=1) plt.grid() plt.fill_between(train_sizes, train_scores_mean - train_scores_std, train_scores_mean + train_scores_std, alpha=0.1, color="r") plt.fill_between(train_sizes, test_scores_mean - test_scores_std, test_scores_mean + test_scores_std, alpha=0.1, color="g") plt.plot(train_sizes, train_scores_mean, 'o-', color="r", label="Training score") plt.plot(train_sizes, test_scores_mean, 'o-', color="g", label="Validation score") plt.legend(loc="best") return plt # 绘制验证曲线 def plot_validation_curve(estimator, title, X, y, param_name, param_range, ylim=None, n_jobs=1, train_sizes=np.linspace(.1, 1.0, 5)): train_scores, test_scores = validation_curve(estimator, X, y, param_name, param_ra train_mean = np.mean(train_scores, axis=1) train_std = np.std(train_scores, axis=1) test_mean = np.mean(test_scores, axis=1) test_std = np.std(test_scores, axis=1) plt.plot(param_range, train_mean, color='r', marker='o', markersize=5, label='Trai plt.fill_between(param_range, train_mean + train_std, train_mean - train_std, alph plt.plot(param_range, test_mean, color='g', linestyle='--', marker='s', markersize plt.fill_between(param_range, test_mean + test_std, test_mean - test_std, alpha=0. plt.grid() plt.xscale('log') plt.legend(loc='best') plt.xlabel('Parameter') plt.ylabel('Score') plt.ylim(ylim)
|