import matplotlib.pyplot as pl
%matplot inline
def learning_curves(X_train, y_train, X_test, y_test):
""" Calculates the performance of several models with varying sizes of training data.
The learning and testing error rates for each model are then plotted. """
print ("Creating learning curve graphs for max_depths of 1, 3, 6, and 10. . .")
# Create the figure window
fig = pl.figure(figsize=(10,8))
# We will vary the training set size so that we have 50 different sizes
sizes = np.rint(np.linspace(1, len(X_train), 50)).astype(int) …Run Code Online (Sandbox Code Playgroud) 我正在尝试根据不同类别的计数(数据框中的“类”列)生成堆积条形图。
我的数据也按另一个类别(“STRAT”列)分组。
我有实际的数字绘图,但我想将这些比例设为总计 100%。IE。因此,对于每个“STRAT”类别,所有条形图都是图表的全高,就像垂直饼图一样。
以下是我的尝试和结果。
样本是大型数据集的一小部分。
import pandas as pd
df_test= pd.read_excel('df.xlsx')
df_test
From To Interval (m) Class STRAT Total %S
308 309 1 PAF CBC 4.15
309 310 1 PAF CBC 3.76
320 321 1 UC CBC 0.85
330 331 1 UC CBC 0.698
342 343 1 NAF LBB 0.259
376 377 1 NAF LBB 0.395
412 413 1 UC LBB 1.19
51 52 1 PAF UBB 2.27
420 420.5 0.5 UC UAB 2.85
189 190 1 PAF …Run Code Online (Sandbox Code Playgroud)