warning

R: warning: ‘newdata’ had … rows but variables found have … rows. & for loop


I know this question has been asked so many times, but I still can’t seem to fix my code in R. I always get the warning that ‘newdata’ had 13 rows but variables found have 37 rows when trying to predict.

Here’s my code:

set.seed(123)
n=50
p=25
#building a matrix 
corr=(matrix(0,p,p))
for(i in seq(p)){for(j in seq(p)){corr[i,j]=0.5^abs(i-j)}}
X<-mvrnorm(n,mu=rep(0,p),Sigma=corr)
#error term
eps<-matrix(rnorm(n,mean=0,sd=1), nrow=n)
#beta 
s1=3
b1<-(c(rep(1,s1),rep(0,p-s1)))

#model
y1<-X%*%b1+eps
X1<-data.frame(y1=y1,X)

#split X1 in training/testing set
samplesize = floor(0.75 * nrow(X))
index<-sample(seq_len(nrow(X)),size=samplesize)

#training set
X.train<-X1[index,]
#testing set
X.test<-X1[-index,]

xtrain1<-model.matrix(y1~.-1,data=X.train)
ytrain1<-X.train$y1
xtest1=model.matrix(y1~.-1,data=X.test)
ytest1=X.test$y1

now I’m trying to do a simple linear regression with a prediction and it won’t seem to work

ols.model<-lm(ytrain1~xtrain1)
ols.predict<-predict(ols.model,newdata=data.frame(xtest1))
ols.predict

after that I want to do a for-loop to repeat the linear regression but I want to store the ouput in a matrix

R=10
ols.pred<-matrix(NA,p,R)
for(i in 1:R){
ols<-lm(ytrain1~xtrain1)
ols.pred[[i]]=predict(ols,data=data.frame(xtest1[,i]))
} 
ols.pred

but that just also won’t work like I want it to.

I’m pretty new to this R-business, so it be great if someone could help!



لینک منبع

The Electronic Frontier Foundation issues a warning to companies banning hate groups


The Electronic Frontier Foundation has a message for the tech companies that have been banning hate groups — be very careful.

The EFF, a nonprofit that focuses on “defending civil liberties in the digital world,” published a post on Thursday night that warned against the precedents set by the ongoing crackdown by major tech companies on websites like The Daily Stormer, a message board popular among the far right, including white supremacists and neo-Nazis.

“All fair-minded people must stand against the hateful violence and aggression that seems to be growing across our country. But we must also recognize that on the Internet, any tactic used now to silence neo-Nazis will soon be used against others, including people whose opinions we agree with,” wrote EFF staffers Jeremy Malcolm, Cindy Cohn, and Danny O’Brien.

Major tech companies have been cracking down on hate groups like never before in the wake of violence during protests in Charlottesville, Virginia. One woman died after a man with ties to far-right organizations allegedly drove his car into a group of counter-protestors.

Since then, Google, Facebook, Spotify, Squarespace, and other companies have taken action, garnering a mostly positive public response. 

The EFF’s post doesn’t come as a surprise; the organization is known to advocate against censorship on the internet.

The EFF noted that companies can choose what kind of speech to allow, but warned that companies are entering dangerous territory because of how much power they wield.

“We strongly believe that what GoDaddy, Google, and Cloudflare did here was dangerous. That’s because, even when the facts are the most vile, we must remain vigilant when platforms exercise these rights. Because Internet intermediaries, especially those with few competitors, control so much online speech, the consequences of their decisions have far-reaching impacts on speech around the world,” the post stated.

The EFF also warned that such action could be taken against anyone. 

“We would be making a mistake if we assumed that these sorts of censorship decisions would never turn against causes we love,” the post stated.

The EFF post had some supporters, most notably Cloudflare CEO Matthew Prince. Cloudflare ceased doing business with The Daily Stormer and characterized the move as his unilateral decision. The company has traditionally maintained a hardline against censoring anything on the internet. While holding to the decision, Prince noted that the EFF post was “exactly on point.”

Others also applauded the EFF’s stance.

Others weren’t as convinced, arguing that the EFF downplayed just how toxic these groups have become.

Https%3a%2f%2fblueprint api production.s3.amazonaws.com%2fuploads%2fvideo uploaders%2fdistribution thumb%2fimage%2f81242%2fb6d3a512 c741 4ae5 9f87 ef4bc2b1cff0



لینک منبع

php – TCPDF openssl error creating PKCS7 structure warning


Ive been trying to generate a signed PDF using the TCPDF Library

My code is as follows:

App::import('Vendor','mtcpdf');

$pdf = new MTCPDF('L');

$pdf->SetProtection(array('copy'), '', null, 0, null);

$pdf->SetMargins(0, 0, 0, true);
$pdf->SetHeaderMargin(0);
$pdf->SetFooterMargin(0);
$pdf->SetAutoPageBreak(false, 0);

$pdf->AddPage('L');
$pdf->Image($imagen, -7, 1, 310, 210, '', '', '', false, 300, '', false, false, 0);

if(!empty($imagentrasera)){
    $pdf->AddPage('L');
    $pdf->Image($imagentrasera, -7, 1, 310, 210, '', '', '', false, 300, '', false, false, 0);
}



if(!empty($certificado_digital)){

    $info = array(
    'Name' => __('Certificado PDF',true),
    'Location' => '',
    'Reason' => '',
    'ContactInfo' => '',
    );

    $certificado_crt = 'file://'.$_SERVER['DOCUMENT_ROOT'].Configure::read('directorioinstalacion').'app/webroot/Documentos/certificados/certificado.cer';
    $certificado_key = 'file://'.$_SERVER['DOCUMENT_ROOT'].Configure::read('directorioinstalacion').'app/webroot/Documentos/certificados/key.key';
    $pdf->setSignature($certificado_crt,$certificado_key, '', '', 1, $info);
}


echo $pdf->Output(__('Certificado',true).'.pdf', 'D');

My “certificado.cer” file was generated using the OpenSSL library. I used the following command:

openssl pkcs12 -in certificate.p12 -out certificado.cer -nodes

And my “key.key” file was generated opening the original .p12 certificate and cutting the Key zone and saving it as the key.key file.

Then the code fais here:

openssl_pkcs7_sign($tempdoc, $tempsign, $this->signature_data['signcert'], array($this->signature_data['privkey'], $this->signature_data['password']), array(), PKCS7_BINARY | PKCS7_DETACHED);

It displays this:

Warning (2): openssl_pkcs7_sign() [function.openssl-pkcs7-sign]: error creating PKCS7 structure! [COREvendorstcpdftcpdf.php, line 7594]

Im using 5.6.25 php version, WAMP local server, and I just cant understand how to solve this, I’ve been searching on google for a while and found nothing about this.

Any help would be much appreciated!!



لینک منبع

reactjs – reactstrap is causing a Critical dependency warning about tether.js


I am using reactstrap in my React app which was originally created by the Facebook create-react-app.

The problem I’m having is with reactstrap, I’m getting the following console warnings:

./~/reactstrap-tether/dist/js/tether.js
Critical dependencies:
۲:۴۷۹-۴۸۶ This seems to be a pre-built javascript file. Though this is possible, it's not recommended. Try to require the original source to get better results.
 @ ./~/reactstrap-tether/dist/js/tether.js 2:479-486

In the project’s github issues, I see possible solutions listed like so: “To suppress the warning (for now), add this to your webpack config file:”

The problem is, with Facebook’s create-react-app I do not have a webpack config file…

How can I go about fixing this warning? Thanks



لینک منبع