append.pl

#!/usr/bin/perl

#su xinmin 2013/1/17

$NUM_ARGV  =  @ARGV  ;

if ( $NUM_ARGV  ==  2 )
{
         $input   =  $ARGV  [ 0 ];
         $cl   =  $ARGV  [ 1 ];
}
else
{
         return  1  ;
}

open  (inf, $input  ) ||  die  " $input "  ;
@alllines  =  <inf>  ;
close  (inf);
$str = ""  ;
foreach  ( @alllines  )
{
         $str .= $_  ;
}

$str  =~ s/#  [0-9]+ / \@  $cl /sg ;                                #将#3  数字 改成  @cl号

open  F  , "> $input  "  or  die  " $input "  ;
print  F  $str ;
close  F  ;
import numpy as np import pylab as pl import pandas as pd from sklearn.linear_model import Ridge from sklearn.metrics import mean_squared_error from sklearn.model_selection import train_test_split X2=[] X3=[] X4=[] X5=[] X6=[] X7=[] X1=[i for i in range(1,24) for j in range(128)] df=pd.read_excel('C:/Users/86147/OneDrive/文档/777.xlsx',header=0,usecols=(3,)) X2=df.values.tolist() x2=[] x21=[] for i in X2: if X2.index(i)<=2927: #两个单元楼的分隔数 x2.append(i) else: x21.append(i) df=pd.read_excel('C:/Users/86147/OneDrive/文档/777.xlsx',header=0,usecols=(4,)) X3=df.values.tolist() x3=[] x31=[] for i in X3: if X3.index(i)<=2927: x3.append(i) else: x31.append(i) df=pd.read_excel('C:/Users/86147/OneDrive/文档/777.xlsx',header=0,usecols=(5,)) X4=df.values.tolist() x4=[] x41=[] for i in X4: if X4.index(i)<=2927: x4.append(i) else: x41.append(i) df=pd.read_excel('C:/Users/86147/OneDrive/文档/777.xlsx',header=0,usecols=(6,)) X5=df.values.tolist() x5=[] x51=[] for i in X5: if X5.index(i)<=2927: x5.append(i) else: x51.append(i) df=pd.read_excel('C:/Users/86147/OneDrive/文档/777.xlsx',header=0,usecols=(7,)) X6=df.values.tolist() x6=[] x61=[] for i in X6: if X6.index(i)<=2927: x6.append(i) else: x61.append(i) df=pd.read_excel('C:/Users/86147/OneDrive/文档/777.xlsx',header=0,usecols=(8,)) X7=df.values.tolist() x7=[] x71=[] for i in X7: if X7.index(i)<=2927: x7.append(i) else: x71.append(i) np.random.seed(42) q=np.array(X1[:2922]) w=np.array(x21[:2922]) e=np.array(x31[:2922]) r=np.array(x41[:2922]) t=np.array(x51[:2922]) p=np.array(x61[:2922]) u=np.array(x71[:2922]) eps=np.random.normal(0,0.05,152) X=np.c_[q,w,e,r,t,p,u] beta=[0.1,0.15,0.2,0.5,0.33,0.45,0.6] y=np.dot(X,beta)X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42) alpha = 0.1 # 设置岭回归的惩罚参数 ridge = Ridge(alpha=alpha) ridge.fit(X_train, y_train) y_pred = ridge.predict(X_test) mse = mean_squared_error(y_test, y_pred) print('MSE:', mse) coef = ridge.coef_ # 计算岭回归的系数 intercept = ridge.intercept_ # 计算岭回归的截距 print('Coefficients:', coef) print('Intercept:', intercept)
06-02
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值